# snxxze/task-management-api architecture

> Architecture diagram of the GitHub repository snxxze/task-management-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/snxxze/task-management-api
- Repository: https://github.com/snxxze/task-management-api

## Overview

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: [`internal/routes/routes.go`](https://github.com/snxxze/task-management-api/blob/main/internal/routes/routes.go) (Route registration), [`internal/database/database.go`](https://github.com/snxxze/task-management-api/blob/main/internal/database/database.go) (PostgreSQL database), [`internal/services/auth_service.go`](https://github.com/snxxze/task-management-api/blob/main/internal/services/auth_service.go) (Auth service), [`internal/services/task_service.go`](https://github.com/snxxze/task-management-api/blob/main/internal/services/task_service.go) (Task service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry"]
  node_server["Server startup<br/>[main.go]"]
  node_routes["Route registration<br/>[routes.go]"]
end

subgraph group_identity["Identity"]
  node_middleware["JWT middleware<br/>[auth_middleware.go]"]
  node_auth_handler["Auth handlers<br/>[auth_handler.go]"]
  node_auth_service["Auth service<br/>[auth_service.go]"]
  node_jwt["JWT utilities<br/>[jwt.go]"]
end

subgraph group_domain["Domain APIs"]
  node_project_handler["Project handlers<br/>[project_handler.go]"]
  node_project_service["Project service<br/>[project_service.go]"]
  node_task_handler["Task handlers<br/>[task_handler.go]"]
  node_task_service["Task service<br/>[task_service.go]"]
  node_user_handler["User handlers<br/>[user_handler.go]"]
  node_user_service["User service<br/>[user_service.go]"]
end

subgraph group_persistence["Persistence"]
  node_project_repo["Project repository"]
  node_task_repo["Task repository<br/>[task_repository.go]"]
  node_user_repo["User repository<br/>[user_repository.go]"]
  node_database[("PostgreSQL database<br/>[database.go]")]
  node_models["Domain models"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_routes
node_server -->|"registers routes"| node_routes
node_routes -->|"routes auth"| node_auth_handler
node_routes -->|"routes projects"| node_project_handler
node_routes -->|"routes tasks"| node_task_handler
node_routes -->|"routes users"| node_user_handler
node_routes -->|"protects routes"| node_middleware
node_middleware -->|"parses tokens"| node_jwt
node_auth_handler -->|"calls service"| node_auth_service
node_auth_service -->|"checks and creates users"| node_user_repo
node_auth_service -->|"generates tokens"| node_jwt
node_project_handler -->|"calls service"| node_project_service
node_task_handler -->|"calls service"| node_task_service
node_task_service -->|"reads and writes tasks"| node_task_repo
node_task_service -->|"checks project access"| node_project_repo
node_project_repo -.->|"queries through GORM"| node_database
node_task_repo -->|"queries through GORM"| node_database
node_user_repo -.->|"persists users"| node_database
node_server -->|"connects and migrates"| node_database
node_database -->|"migrates models"| node_models
node_project_service -.->|"uses repository"| node_project_repo
node_user_handler -.->|"uses service"| node_user_service
node_user_service -.->|"uses repository"| node_user_repo

click node_server "https://github.com/snxxze/task-management-api/blob/main/cmd/server/main.go"
click node_routes "https://github.com/snxxze/task-management-api/blob/main/internal/routes/routes.go"
click node_middleware "https://github.com/snxxze/task-management-api/blob/main/internal/middleware/auth_middleware.go"
click node_auth_handler "https://github.com/snxxze/task-management-api/blob/main/internal/handlers/auth_handler.go"
click node_auth_service "https://github.com/snxxze/task-management-api/blob/main/internal/services/auth_service.go"
click node_jwt "https://github.com/snxxze/task-management-api/blob/main/internal/util/jwt.go"
click node_project_handler "https://github.com/snxxze/task-management-api/blob/main/internal/handlers/project_handler.go"
click node_project_service "https://github.com/snxxze/task-management-api/blob/main/internal/services/project_service.go"
click node_task_handler "https://github.com/snxxze/task-management-api/blob/main/internal/handlers/task_handler.go"
click node_task_service "https://github.com/snxxze/task-management-api/blob/main/internal/services/task_service.go"
click node_user_handler "https://github.com/snxxze/task-management-api/blob/main/internal/handlers/user_handler.go"
click node_user_service "https://github.com/snxxze/task-management-api/blob/main/internal/services/user_service.go"
click node_project_repo "https://github.com/snxxze/task-management-api/blob/main/internal/repositories/project_repository.go"
click node_task_repo "https://github.com/snxxze/task-management-api/blob/main/internal/repositories/task_repository.go"
click node_user_repo "https://github.com/snxxze/task-management-api/blob/main/internal/repositories/user_repository.go"
click node_database "https://github.com/snxxze/task-management-api/blob/main/internal/database/database.go"
click node_models "https://github.com/snxxze/task-management-api/tree/main/internal/models"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_routes,node_client toneBlue
class node_middleware,node_auth_handler,node_auth_service,node_jwt toneAmber
class node_project_handler,node_project_service,node_task_handler,node_task_service,node_user_handler,node_user_service toneMint
class node_project_repo,node_task_repo,node_user_repo,node_database,node_models toneRose
```

## Components

### API entry

- [Server startup](https://github.com/snxxze/task-management-api/blob/main/cmd/server/main.go): `cmd/server/main.go`
- [Route registration](https://github.com/snxxze/task-management-api/blob/main/internal/routes/routes.go): `internal/routes/routes.go`

### Identity

- [JWT middleware](https://github.com/snxxze/task-management-api/blob/main/internal/middleware/auth_middleware.go): `internal/middleware/auth_middleware.go`
- [Auth handlers](https://github.com/snxxze/task-management-api/blob/main/internal/handlers/auth_handler.go): `internal/handlers/auth_handler.go`
- [Auth service](https://github.com/snxxze/task-management-api/blob/main/internal/services/auth_service.go): `internal/services/auth_service.go`
- [JWT utilities](https://github.com/snxxze/task-management-api/blob/main/internal/util/jwt.go): `internal/util/jwt.go`

### Domain APIs

- [Project handlers](https://github.com/snxxze/task-management-api/blob/main/internal/handlers/project_handler.go): `internal/handlers/project_handler.go`
- [Project service](https://github.com/snxxze/task-management-api/blob/main/internal/services/project_service.go): `internal/services/project_service.go`
- [Task handlers](https://github.com/snxxze/task-management-api/blob/main/internal/handlers/task_handler.go): `internal/handlers/task_handler.go`
- [Task service](https://github.com/snxxze/task-management-api/blob/main/internal/services/task_service.go): `internal/services/task_service.go`
- [User handlers](https://github.com/snxxze/task-management-api/blob/main/internal/handlers/user_handler.go): `internal/handlers/user_handler.go`
- [User service](https://github.com/snxxze/task-management-api/blob/main/internal/services/user_service.go): `internal/services/user_service.go`

### Persistence

- [Project repository](https://github.com/snxxze/task-management-api/blob/main/internal/repositories/project_repository.go): `internal/repositories/project_repository.go`
- [Task repository](https://github.com/snxxze/task-management-api/blob/main/internal/repositories/task_repository.go): `internal/repositories/task_repository.go`
- [User repository](https://github.com/snxxze/task-management-api/blob/main/internal/repositories/user_repository.go): `internal/repositories/user_repository.go`
- [PostgreSQL database](https://github.com/snxxze/task-management-api/blob/main/internal/database/database.go): `internal/database/database.go`
- [Domain models](https://github.com/snxxze/task-management-api/tree/main/internal/models): `internal/models`

### Other components

- **API client**

## Connections

- API client → Route registration: sends requests (evidence: `internal/routes/routes.go`)
- Server startup → Route registration: registers routes (evidence: `cmd/server/main.go`)
- Route registration → Auth handlers: routes auth (evidence: `internal/routes/routes.go`)
- Route registration → Project handlers: routes projects (evidence: `internal/routes/routes.go`)
- Route registration → Task handlers: routes tasks (evidence: `internal/routes/routes.go`)
- Route registration → User handlers: routes users (evidence: `internal/routes/routes.go`)
- Route registration → JWT middleware: protects routes (evidence: `internal/routes/routes.go`)
- JWT middleware → JWT utilities: parses tokens (evidence: `internal/middleware/auth_middleware.go`)
- Auth handlers → Auth service: calls service (evidence: `internal/handlers/auth_handler.go`)
- Auth service → User repository: checks and creates users (evidence: `internal/services/auth_service.go`)
- Auth service → JWT utilities: generates tokens (evidence: `internal/services/auth_service.go`)
- Project handlers → Project service: calls service (evidence: `internal/handlers/project_handler.go`)
- Task handlers → Task service: calls service (evidence: `internal/handlers/task_handler.go`)
- Task service → Task repository: reads and writes tasks (evidence: `internal/services/task_service.go`)
- Task service → Project repository: checks project access (evidence: `internal/services/task_service.go`)
- Project repository → PostgreSQL database: queries through GORM
- Task repository → PostgreSQL database: queries through GORM (evidence: `internal/repositories/task_repository.go`)
- User repository → PostgreSQL database: persists users
- Server startup → PostgreSQL database: connects and migrates (evidence: `cmd/server/main.go`)
- PostgreSQL database → Domain models: migrates models (evidence: `internal/database/database.go`)
- Project service → Project repository: uses repository
- User handlers → User service: uses service
- User service → User repository: uses repository
