How snxxze/task-management-api works
This is a layered Go REST API for task and project management. Its main workflow is an HTTP request routed to a handler, processed by a service, and persisted through a repository using GORM and PostgreSQL; protected endpoints first validate a JWT. The README documents authentication, project/task CRUD and user-profile APIs, as well as database migration and seed behavior. The sampled code confirms the auth and task paths and route registration. Some project, user, bootstrap, and database wiring is not shown in excerpts, so those links are documented only where supported.
Main entry points: routes.go Route registration · database.go PostgreSQL database · auth_service.go Auth service · task_service.go Task service
Components 18
API entry
- Server startup
cmd/server/main.go - Route registration
internal/routes/routes.go
Identity
- JWT middleware
internal/middleware/auth_middleware.go - Auth handlers
internal/handlers/auth_handler.go - Auth service
internal/services/auth_service.go - JWT utilities
internal/util/jwt.go
Domain APIs
- Project handlers
internal/handlers/project_handler.go - Project service
internal/services/project_service.go - Task handlers
internal/handlers/task_handler.go - Task service
internal/services/task_service.go - User handlers
internal/handlers/user_handler.go - User service
internal/services/user_service.go
Persistence
- Project repository
internal/repositories/project_repository.go - Task repository
internal/repositories/task_repository.go - User repository
internal/repositories/user_repository.go - PostgreSQL database
internal/database/database.go - Domain models
internal/models
Other components
- API client
Connections 23
- API client → Route registration: sends requests
internal/routes/routes.go - Server startup → Route registration: registers routes
cmd/server/main.go - Route registration → Auth handlers: routes auth
internal/routes/routes.go - Route registration → Project handlers: routes projects
internal/routes/routes.go - Route registration → Task handlers: routes tasks
internal/routes/routes.go - Route registration → User handlers: routes users
internal/routes/routes.go - Route registration → JWT middleware: protects routes
internal/routes/routes.go - JWT middleware → JWT utilities: parses tokens
internal/middleware/auth_middleware.go - Auth handlers → Auth service: calls service
internal/handlers/auth_handler.go - Auth service → User repository: checks and creates users
internal/services/auth_service.go - Auth service → JWT utilities: generates tokens
internal/services/auth_service.go - Project handlers → Project service: calls service
internal/handlers/project_handler.go - Task handlers → Task service: calls service
internal/handlers/task_handler.go - Task service → Task repository: reads and writes tasks
internal/services/task_service.go - Task service → Project repository: checks project access
internal/services/task_service.go - Project repository → PostgreSQL database: queries through GORM
- Task repository → PostgreSQL database: queries through GORM
internal/repositories/task_repository.go - User repository → PostgreSQL database: persists users
- Server startup → PostgreSQL database: connects and migrates
cmd/server/main.go - PostgreSQL database → Domain models: migrates models
internal/database/database.go - Project service → Project repository: uses repository
- User handlers → User service: uses service
- User service → User repository: uses repository