# fiftysaw-png/todorest architecture

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

- Interactive diagram: https://gitdiagram.com/fiftysaw-png/todorest
- Repository: https://github.com/fiftysaw-png/todorest

## Overview

This is a small in-memory ToDo REST API. A client sends requests to the HTTP server, whose routes dispatch to handlers; handlers decode and validate JSON, invoke task-list operations, and serialize results or errors. The domain layer stores tasks in a mutex-protected map and models completion state. The README documents different endpoint methods and IDs than the sampled router, so the graph follows the implemented routes. No persistent or external service is shown.

Main entry points: [`http/handlers.go`](https://github.com/fiftysaw-png/todorest/blob/main/http/handlers.go) (Request Handlers), [`todo/list.go`](https://github.com/fiftysaw-png/todorest/blob/main/todo/list.go) (Task List), [`main.go`](https://github.com/fiftysaw-png/todorest/blob/main/main.go) (Application Setup), [`http/server.go`](https://github.com/fiftysaw-png/todorest/blob/main/http/server.go) (HTTP Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_main["Application Setup<br/>[main.go]"]
end

subgraph group_http["HTTP API"]
  node_server["HTTP Server<br/>[server.go]"]
  node_handlers["Request Handlers<br/>[handlers.go]"]
  node_dto["JSON DTOs<br/>[dto.go]"]
end

subgraph group_domain["Task Domain"]
  node_tasklist[("Task List<br/>[list.go]")]
  node_task["Task Model<br/>[task.go]"]
  node_errors["Domain Errors<br/>[errors.go]"]
end

node_client(("API Client"))

node_main -->|"creates"| node_tasklist
node_main -->|"constructs"| node_handlers
node_main -->|"starts"| node_server
node_client -->|"sends requests"| node_server
node_server -->|"routes requests"| node_handlers
node_handlers -->|"decodes and validates"| node_dto
node_handlers -->|"invokes operations"| node_tasklist
node_handlers -->|"creates tasks"| node_task
node_handlers -->|"checks errors"| node_errors
node_tasklist -->|"updates completion"| node_task
node_tasklist -->|"returns errors"| node_errors

click node_main "https://github.com/fiftysaw-png/todorest/blob/main/main.go"
click node_server "https://github.com/fiftysaw-png/todorest/blob/main/http/server.go"
click node_handlers "https://github.com/fiftysaw-png/todorest/blob/main/http/handlers.go"
click node_dto "https://github.com/fiftysaw-png/todorest/blob/main/http/dto.go"
click node_tasklist "https://github.com/fiftysaw-png/todorest/blob/main/todo/list.go"
click node_task "https://github.com/fiftysaw-png/todorest/blob/main/todo/task.go"
click node_errors "https://github.com/fiftysaw-png/todorest/blob/main/todo/errors.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_client toneBlue
class node_server,node_handlers,node_dto toneAmber
class node_tasklist,node_task,node_errors toneMint
```

## Components

### Runtime

- [Application Setup](https://github.com/fiftysaw-png/todorest/blob/main/main.go): `main.go`

### HTTP API

- [HTTP Server](https://github.com/fiftysaw-png/todorest/blob/main/http/server.go): `http/server.go`
- [Request Handlers](https://github.com/fiftysaw-png/todorest/blob/main/http/handlers.go): `http/handlers.go`
- [JSON DTOs](https://github.com/fiftysaw-png/todorest/blob/main/http/dto.go): `http/dto.go`

### Task Domain

- [Task List](https://github.com/fiftysaw-png/todorest/blob/main/todo/list.go): `todo/list.go`
- [Task Model](https://github.com/fiftysaw-png/todorest/blob/main/todo/task.go): `todo/task.go`
- [Domain Errors](https://github.com/fiftysaw-png/todorest/blob/main/todo/errors.go): `todo/errors.go`

### Other components

- **API Client**

## Connections

- Application Setup → Task List: creates (evidence: `main.go`)
- Application Setup → Request Handlers: constructs (evidence: `main.go`)
- Application Setup → HTTP Server: starts (evidence: `main.go`)
- API Client → HTTP Server: sends requests (evidence: `README.md`)
- HTTP Server → Request Handlers: routes requests (evidence: `http/server.go`)
- Request Handlers → JSON DTOs: decodes and validates (evidence: `http/handlers.go`)
- Request Handlers → Task List: invokes operations (evidence: `http/handlers.go`)
- Request Handlers → Task Model: creates tasks (evidence: `http/handlers.go`)
- Request Handlers → Domain Errors: checks errors (evidence: `http/handlers.go`)
- Task List → Task Model: updates completion (evidence: `todo/list.go`)
- Task List → Domain Errors: returns errors (evidence: `todo/list.go`)
