The backend code base for lingo.
Lingo is an app that let's users communicate with one another without having knowledge of the each other's language. It tries to break the language barrier among humans. It does this by using instant translation. This prevents the user from going back and forth to translate messages.
-
express: This will be used to handle regular http requests.
-
socket.io: This is used for real-time communication.
-
MongoDB: Database to store users message.
-
Redis: Database to store user sessions.
-
google-translate-api: Node implementation of google translate api.
Figma design can be found here by Lois Dagana
In other to run the app, you have to have docker installed.
Create a .env in the main directory then copy and paste the text below.
MONGO_URI="mongodb://lingo_user:lingo_pwd@mongo/lingo_db"
PORT=3000
SECRET="4274fffc957f5a2f5dabe93ea26c3b6c5ed95e9aac8111e2614d7adcb809986a"
The SECRET variable can be changed to any value you desire but its safe to keep it random.
Then run the command below:
docker compose up -d # or docker-compose up -dAPI routes for basic crud operations:
GET 127.0.0.1:9000/
Response:
{"msg":"Lingo up"}GET 127.0.0.1:9000/api/users/
Response:
[
{
"_id": "630aaff5960b85d32420f516",
"username": "Eteims",
"friends": [],
"groups": [
"French",
"Spanish"
],
"createdAt": "2022-08-27T23:59:49.972Z",
"updatedAt": "2022-08-28T00:02:17.882Z",
"__v": 0,
"lang": "English"
},
{
"_id": "630ab174044d4c24d5e27d36",
"username": "Alice",
"friends": [],
"groups": [],
"createdAt": "2022-08-28T00:06:12.227Z",
"updatedAt": "2022-08-28T00:06:12.227Z",
"__v": 0
},
]GET 127.0.0.1:9000/api/users/630aaff5960b85d32420f516
Response:
{
"_id": "630aaff5960b85d32420f516",
"username": "Eteims",
"friends": [],
"groups": [
"French",
"Spanish"
],
"createdAt": "2022-08-27T23:59:49.972Z",
"updatedAt": "2022-08-28T00:02:17.882Z",
"__v": 0,
"lang": "English"
}POST 127.0.0.1:9000/api/users/signup
Request body:
{
"username": "Alice",
"password": "alice123"
}POST 127.0.0.1:9000/api/users/login
Request body:
{
"username": "Alice",
"password": "alice123"
}PATCH 127.0.0.1:9000/api/users/lang
Request body:
{
"lang": "English",
"groups": ["Spanish", "Igbo", "French"]
}DELETE 127.0.0.1:9000/api/users/
Note: User most be signed in!
Response:
{ "detail": "User successfully deleted" }-
Setup environments
- setup typescript environment for express.
- setup database mongodb via docker.
- Run a simple test app.
-
Create database schema for users.
-
Implement login functionality.
