Steps to run:
- Clone the repo
- Update config/config.go with correct postgres db credentials
- Run
cd cmd && go run .
The server starts at port 8765 by default
This Project exposes 4 APIs
- GET
/v1/users
- GET
/v1/users/:user_id
- POST
/v1/users
- PUT
/v1/users/:user_id
Sample Payload to create a user:
{
"first_name": "Prince",
"last_name": "Raj",
"dob": "2001-05-24T00:00:00Z",
"mobile": "8977777777",
"profile_picture": "https://image.link",
"metadata": {
"os": "android",
"ver": "25",
"play_store_services_ver": "1",
"hni": false
}
}
Features:
- API versioning
- Pagination
- Config management via env vars
- 3-tier architecture code architecture
- Log levels implemented
- Centralised Error handling
- Dependency injection
- Go generate to generate error message code
TODO:
- Add validation for mobile number
- Split mobile no into two columns. Country code and mobile no
- Breakdown user table to add the mobile no in another table, so that users can add multiple mobile numbers.