go-version = 1.17.2
MONGO_URI=mongodb://admin:OuOp66RvQpGma6u0@SG-sud-47257.servers.mongodirector.com:27017/admin
DB=sud
PORT=3000
APP_ENV=development
JWT_SECRET=dfsodhfjksh35453d45jk4534f5hs45d3l45fhadkhfadhu345234
https://rocky-island-43692.herokuapp.com
may not be available at all times
[POST] /api/user
{
"name": "Test",
"dob": "25-10-2001",
"address":"abc street",
"description":"summa",
"createdAt":"2021-10-14T11:28:15.997Z"
}
{
"data": {
"InsertedID": "61681484a8c956597ac3936d"
},
"message": "User inserted successfully",
"success": true
}
/api/auth
Usually I would send a username and password and use bcrypt to verify the password
{
"id":"61681484a8c956597ac3936d"
}
{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiVGVzdCJdLCJleHAiOjE2MzQyOTc0MjgsImlhdCI6MTYzNDIxMTAyOCwianRpIjoiNjE2ODE0ODRhOGM5NTY1OTdhYzM5MzZkIn0.6bCMPGAiAdJS5oHwH8H3t5YPAppE_Z9flJ0GJtrFJgE",
"user": {
"_id": "61681484a8c956597ac3936d",
"name": "Test",
"dob": "25-10-2001",
"address": "abc street",
"description": "summa",
"createdAt": "2021-10-14T11:29:07.831Z"
}
}
[GET] /api/user
[GET] /api/user/:id
[PUT] /api/user/:id
{
"name": "Test",
"dob": "25-10-2001",
"address":"abc street",
"description":"summa",
"createdAt":"2021-10-14T11:28:15.997Z"
}
{
"message": "User updated successfully",
"success": true
}
[DELETE] /api/user/:id
The Implementation would go like the following: - Build an API so that the Frontend sends the current location of that device
- Step 1
I set it up in Redis Using the GEOADD functionality Now we have a system for querying users’ location - Step 2
There are 2 approaches
Approach 1 : Calculate the distance between my location and my friends location and if the distance is below a certain radius like 4km I return it back
GEODIST x N friends || complexity: O( N log(M))
Approach 2 : Find everyone within radius 4km(assumption) and filter out only my friends
GEORADIUS + N friends || complexity: O(N(M+log(P)))
M is the number of elements inside the bounding box of the circular area
We can also use neo4j to do the same kind of queries but the execution speed will be slower when compared to Redis
I had a logging system built with Rust + Redis where all the data will be pushed to Redis Streams and then asynchronously pushed to Timescale DB and then visualized in Grafana. Mostly logging can be like an trackable event like user.created, user.updated and many more For my case I’ve done it as an HTTP API but if I were to reimplement it would be using GRCP/WebSocket/Direct function calls. Friend and Follow implementation that I have done for my personal project