A web server with a RESTful API that exposes an API that translate a text from one language to another.
- Created a web server with a RESTful API using NodeJS to translate a text from one language to another using google-traslate-api
- Target Language is defined by user and can be requested by API
- Caching of data is done to avoid repeated hits to the translation API using redis
- Server implemented with extensible architecture for switching caching startegy or switching translation service.
- Wrote Tests to test the APIs using mocha and chai
- Linting of code is done using ESLint
Redis | RDBMS |
---|---|
Redis stores everything in primary memory. | RDBMS stores everything in secondary memory. |
In Redis, Read and Write operations are extremely fast because of storing data in primary memory. | In RDBMS, Read and Write operations are slow because of storing data in secondary memory. |
NodeJS
andExpressJS
(NodeJS based application framework)Google Translate
npm package as an external service for actual translationredis
used as database cache.Mocha and Chai
as testing frameworkESLint
for code analysis
📷📷📷📷📷📷📷 Start with Smile😄😄
- Install NodeJS⏬
- Download Redis and open the
redis-server
file for starting the server (neccesary to run the app) - Open the terminal window and write
git clone https://github.com/GovindCodes/TranslationCaching.git
- Install Dependencies
npm install
This will download all the node modules to your local computer.:clock1::relieved::sun_with_face:
- Next thing to write on terminal is
npm start
This will run the software on port 3000
- HURRAHHH💥 You are ready to go to localhost:3000 on your browser and enjoy the traslation caching.
we can observe here that first time the loading time was 2.24 Sec
and 2nd time whe i serched for same data it got cached and loading time reduced to 839 milliSec
Run
npn test
Make sure the server file is not already running only the redis server should run
and the test written in test\task.js
will run using mocha
ESlint Configuratin file can be found in
.eslintrc.js
Key is taken as Input text + desired languae Iso code
as string
The value returned from the translation Api is stored in value.
Key | Value |
---|---|
Happyhi | प्रसन्न |
Hellofr | Bonjour |