A production-style REST API built with Go, Fiber, PostgreSQL, SQLC, Uber Zap, and Validator for managing users and dynamically calculating age from date of birth.
The application follows a clean layered architecture:
Request
→ Route
→ Handler
→ Service
→ Repository
→ SQLC
→ PostgreSQL
| Feature | Status |
|---|---|
| Create User | ✅ |
| Get User by ID | ✅ |
| Update User | ✅ |
| Delete User | ✅ |
| List Users | ✅ |
| Dynamic Age Calculation | ✅ |
| PostgreSQL Integration | ✅ |
| SQLC Generated Queries | ✅ |
| Request Validation | ✅ |
| Structured Logging (Zap) | ✅ |
| Request ID Middleware | ✅ |
| Request Duration Logging | ✅ |
| Pagination | ✅ |
| Graceful Shutdown | ✅ |
| Docker Support | ✅ |
| Unit Tests | ✅ |
- Go
- Fiber
- PostgreSQL
- SQLC
- Uber Zap
- go-playground/validator
- Docker
- Docker Compose
| Method | Endpoint | Description |
|---|---|---|
| POST | /users | Create a user |
| GET | /users/:id | Get a user by ID |
| PUT | /users/:id | Update a user |
| DELETE | /users/:id | Delete a user |
| GET | /users | List users with pagination |
{
"id": 1,
"name": "Alice Johnson",
"dob": "1998-04-23",
"age": 28
}Age is calculated dynamically from the stored date of birth and is never persisted in the database.