A Go-based REST API with clean architecture.
We'll build:
- Register - User registration system
- Login - User authentication
- JWT Auth - Token-based security
- Projects - Project management
- Tasks - Task tracking
- Role-based Access - Permission system
- Pagination - Efficient data loading
- Middleware - Request/response handling
- Clean Architecture - Maintainable code structure
- User Registration & Login
- JWT Authentication
- Projects & Tasks Management
- Role-based Access Control
- Pagination & Middleware
- Folder structure
- Go modules
- Environment config
- Docker + PostgreSQL
- Migration tool
- Users table
- Password hashing (bcrypt)
- JWT tokens
- Auth middleware
- Relational schema
- Authorization rules
- Logging
- Error response format
- Pagination
- Testing
- No business logic in handlers - Keep handlers thin, delegate to services
- No DB queries in handlers - Repository pattern for data access
- Layer separation - Handler → Service → Repository
- Dependency inversion - Depend on interfaces, not concrete implementations
- No JWT parsing in handlers - Use middleware for token validation
- Context-based auth - Pass user context through request lifecycle
- Secure defaults - Fail closed, validate inputs
- No direct SQL in services - Use repository abstractions
- Transaction management - Handle database transactions properly
- Query optimization - Use proper indexes and efficient queries
- Everything injected via constructor - Explicit dependencies
- No global variables - Pass dependencies explicitly
- Proper error wrapping - Use
fmt.Errorfwith%wverb for error chains - Context passed everywhere - Enable cancellation and timeouts
- No panic - Return errors, don't crash the application
- Consistent response format - Standardized JSON structure
- HTTP status codes - Use appropriate codes (200, 201, 400, 401, 404, 500)
- Input validation - Validate all incoming data
- Structured logging - Use structured logs with appropriate levels
- Unit tests - Test business logic in isolation
- Integration tests - Test API endpoints end-to-end
- Mocking - Use interfaces for testable code
- Health checks - Implement readiness and liveness probes Migration apply command migrate -path migrations -database "postgres://admin:password@localhost:5433/project_management?sslmode=disable" up