# wondertech-byte/go-task-task-manager architecture

> Architecture diagram of the GitHub repository wondertech-byte/go-task-task-manager, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wondertech-byte/go-task-task-manager
- Repository: https://github.com/wondertech-byte/go-task-task-manager

## Overview

#### Purpose and Runtime
GoTask is a single-process REST API for task management. It runs on Go, serves HTTP through Gin, persists data with GORM, and uses PostgreSQL. The executable entry point is `main.go`.

#### Application Bootstrap
`main.go` initializes configuration, establishes the database connection/migration path, creates the Gin router, registers routes, and starts the server on port 8080. Startup composition crosses these boundaries:
- `main.go`
- `config/config.go`
- `db/db.go`

#### Configuration Boundary
Environment-backed database settings are centralized in `config/config.go`, with `.env.example` defining the expected local environment contract. Configuration should remain separate from request handling and persistence logic.

#### Persistence and Schema
`db/db.go` owns PostgreSQL/GORM connection setup and database migration. The task schema is represented by `models/task.go`; GORM maps this model to the database and handlers use it for CRUD operations.
- `db/db.go`
- `models/task.go`

#### HTTP Routing Layer
`routes/routes.go` defines the versioned `/api/v1/tasks` resource surface and maps collection/item methods to task handlers. The API supports list/create, single-task retrieval, full and partial updates, and deletion.
- `routes/routes.go`
- `handlers/task_handler.go`

#### Task Request Processing
`handlers/task_handler.go` is the primary application layer: it receives Gin requests, parses path/query/body input, validates task fields, executes GORM operations, and returns HTTP responses. List requests support status filtering and pagination; mutation requests distinguish PUT replacement from PATCH partial updates.
- `handlers/task_handler.go`
- `models/task.go`
- `db/db.go`

#### Primary Flow and External Dependency
Request flow is: client → Gin router → task handler → GORM → PostgreSQL → JSON HTTP response. The key external service is PostgreSQL, provisioned independently and accessed with credentials supplied through environment configuration. There is no separate service, queue, frontend, or domain-service layer evident in the repository.

Main entry points: [`handlers/task_handler.go`](https://github.com/wondertech-byte/go-task-task-manager/blob/master/handlers/task_handler.go) (Task handler), [`main.go`](https://github.com/wondertech-byte/go-task-task-manager/blob/master/main.go) (Application entry point), [`db/db.go`](https://github.com/wondertech-byte/go-task-task-manager/blob/master/db/db.go) (Database setup), [`config/config.go`](https://github.com/wondertech-byte/go-task-task-manager/blob/master/config/config.go) (Environment config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bootstrap["Bootstrap"]
  node_main["Application entry point<br/>Go executable<br/>[main.go]"]
  node_config["Environment config<br/>configuration<br/>[config.go]"]
  node_env_example["Local env contract<br/>environment template<br/>[.env.example]"]
end

subgraph group_http["HTTP API"]
  node_router["Gin router<br/>HTTP router<br/>[main.go]"]
  node_routes["Task routes<br/>route definitions<br/>[routes.go]"]
  node_handler["Task handler<br/>request handler<br/>[task_handler.go]"]
  node_list_query["List filtering<br/>query handling<br/>[task_handler.go]"]
  node_mutation["Task mutations<br/>update handling<br/>[task_handler.go]"]
  node_json_response["JSON response<br/>HTTP response<br/>[task_handler.go]"]
end

subgraph group_persistence["Persistence"]
  node_database["Database setup<br/>GORM connection<br/>[db.go]"]
  node_task_model["Task schema<br/>GORM model<br/>[task.go]"]
  node_gorm{{"GORM"}}
end

node_client(("API client<br/>external client"))
node_postgres[("PostgreSQL<br/>external database")]

node_env_example -.->|"documents"| node_config
node_main -->|"loads"| node_config
node_main -->|"initializes"| node_database
node_main -->|"creates"| node_router
node_main -->|"registers"| node_routes
node_config -->|"database credentials"| node_database
node_database -->|"configures"| node_gorm
node_database -->|"migrates"| node_task_model
node_gorm -->|"connects"| node_postgres
node_client -->|"HTTP request"| node_router
node_router -->|"dispatches"| node_routes
node_routes -->|"maps task methods"| node_handler
node_handler -->|"processes list requests"| node_list_query
node_handler -->|"processes writes"| node_mutation
node_handler -->|"uses"| node_task_model
node_handler -->|"executes CRUD"| node_gorm
node_handler -->|"returns"| node_json_response
node_json_response -->|"HTTP response"| node_client

click node_main "https://github.com/wondertech-byte/go-task-task-manager/blob/master/main.go"
click node_config "https://github.com/wondertech-byte/go-task-task-manager/blob/master/config/config.go"
click node_env_example "https://github.com/wondertech-byte/go-task-task-manager/blob/master/.env.example"
click node_router "https://github.com/wondertech-byte/go-task-task-manager/blob/master/main.go"
click node_routes "https://github.com/wondertech-byte/go-task-task-manager/blob/master/routes/routes.go"
click node_handler "https://github.com/wondertech-byte/go-task-task-manager/blob/master/handlers/task_handler.go"
click node_list_query "https://github.com/wondertech-byte/go-task-task-manager/blob/master/handlers/task_handler.go"
click node_mutation "https://github.com/wondertech-byte/go-task-task-manager/blob/master/handlers/task_handler.go"
click node_database "https://github.com/wondertech-byte/go-task-task-manager/blob/master/db/db.go"
click node_task_model "https://github.com/wondertech-byte/go-task-task-manager/blob/master/models/task.go"
click node_json_response "https://github.com/wondertech-byte/go-task-task-manager/blob/master/handlers/task_handler.go"

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_main,node_config,node_env_example toneBlue
class node_router,node_routes,node_handler,node_list_query,node_mutation,node_json_response toneAmber
class node_database,node_task_model,node_gorm toneMint
class node_client,node_postgres toneNeutral
```

## Components

### Bootstrap

- [Application entry point](https://github.com/wondertech-byte/go-task-task-manager/blob/master/main.go): Go executable · Composes startup and starts HTTP on port 8080. · `main.go`
- [Environment config](https://github.com/wondertech-byte/go-task-task-manager/blob/master/config/config.go): configuration · Centralizes database settings. · `config/config.go`
- [Local env contract](https://github.com/wondertech-byte/go-task-task-manager/blob/master/.env.example): environment template · `.env.example`

### HTTP API

- [Gin router](https://github.com/wondertech-byte/go-task-task-manager/blob/master/main.go): HTTP router · `main.go`
- [Task routes](https://github.com/wondertech-byte/go-task-task-manager/blob/master/routes/routes.go): route definitions · Defines the versioned /api/v1/tasks resource. · `routes/routes.go`
- [Task handler](https://github.com/wondertech-byte/go-task-task-manager/blob/master/handlers/task_handler.go): request handler · Validates input, performs CRUD, and returns JSON responses. · `handlers/task_handler.go`
- [List filtering](https://github.com/wondertech-byte/go-task-task-manager/blob/master/handlers/task_handler.go): query handling · Supports status filtering and pagination. · `handlers/task_handler.go`
- [Task mutations](https://github.com/wondertech-byte/go-task-task-manager/blob/master/handlers/task_handler.go): update handling · Distinguishes PUT replacement from PATCH partial updates. · `handlers/task_handler.go`
- [JSON response](https://github.com/wondertech-byte/go-task-task-manager/blob/master/handlers/task_handler.go): HTTP response · `handlers/task_handler.go`

### Persistence

- [Database setup](https://github.com/wondertech-byte/go-task-task-manager/blob/master/db/db.go): GORM connection · Connects to PostgreSQL and runs migrations. · `db/db.go`
- [Task schema](https://github.com/wondertech-byte/go-task-task-manager/blob/master/models/task.go): GORM model · `models/task.go`
- **GORM**: ORM · Maps task CRUD operations to PostgreSQL.

### Other components

- **API client**: external client
- **PostgreSQL**: external database · Independently provisioned task datastore.

## Connections

- Local env contract → Environment config: documents
- Application entry point → Environment config: loads
- Application entry point → Database setup: initializes
- Application entry point → Gin router: creates
- Application entry point → Task routes: registers
- Environment config → Database setup: database credentials
- Database setup → GORM: configures
- Database setup → Task schema: migrates
- GORM → PostgreSQL: connects
- API client → Gin router: HTTP request
- Gin router → Task routes: dispatches
- Task routes → Task handler: maps task methods
- Task handler → List filtering: processes list requests
- Task handler → Task mutations: processes writes
- Task handler → Task schema: uses
- Task handler → GORM: executes CRUD
- Task handler → JSON response: returns
- JSON response → API client: HTTP response
