# temkinnn/rust-notes-api architecture

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

- Interactive diagram: https://gitdiagram.com/temkinnn/rust-notes-api
- Repository: https://github.com/temkinnn/rust-notes-api

## Overview

This is a Rust/Actix web API for managing users and their todos, including user–todo queries and standard CRUD operations. Requests enter through the `/api` routes, are handled by user or todo handlers, and use services and SQL repositories to access PostgreSQL; handlers serialize results and errors as HTTP responses. The excerpts show the user service delegating to its repository, but do not show the todo service implementation, so that delegation is left unverified. The README is empty, and no migration behavior is inferred.

Main entry points: [`src/main.rs`](https://github.com/temkinnn/rust-notes-api/blob/main/src/main.rs) (Server entry), [`src/handlers/todo.rs`](https://github.com/temkinnn/rust-notes-api/blob/main/src/handlers/todo.rs) (Todo routes), [`src/handlers/user.rs`](https://github.com/temkinnn/rust-notes-api/blob/main/src/handlers/user.rs) (User routes), [`src/repositories/user.rs`](https://github.com/temkinnn/rust-notes-api/blob/main/src/repositories/user.rs) (User repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Server runtime"]
  node_main["Server entry<br/>[main.rs]"]
  node_config["API configuration<br/>[config.rs]"]
end

subgraph group_api["HTTP API"]
  node_todo_handler["Todo routes<br/>[todo.rs]"]
  node_user_handler["User routes<br/>[user.rs]"]
  node_todo_service["Todo service<br/>[todo.rs]"]
  node_user_service["User service<br/>[user.rs]"]
end

subgraph group_domain["Domain models"]
  node_todo_model["Todo models<br/>[todo.rs]"]
  node_user_model["User models<br/>[user.rs]"]
  node_error_model["Error response<br/>[res.rs]"]
end

subgraph group_storage["Persistence"]
  node_dbpool["Database pool<br/>[mod.rs]"]
  node_todo_repo["Todo repository<br/>[todo.rs]"]
  node_user_repo["User repository<br/>[user.rs]"]
  node_postgres[("PostgreSQL")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_main
node_main -->|"initializes pool"| node_dbpool
node_main -->|"configures errors"| node_config
node_main -->|"registers routes"| node_todo_handler
node_main -->|"registers routes"| node_user_handler
node_dbpool -->|"connects to"| node_postgres
node_todo_handler -->|"calls"| node_todo_service
node_user_handler -->|"calls"| node_user_service
node_todo_handler -->|"constructs"| node_todo_repo
node_user_handler -->|"constructs"| node_user_repo
node_user_service -->|"delegates to"| node_user_repo
node_todo_service -.->|"delegates to"| node_todo_repo
node_todo_repo -->|"queries"| node_postgres
node_user_repo -->|"queries"| node_postgres
node_todo_handler -->|"accepts DTOs"| node_todo_model
node_user_handler -->|"accepts DTOs"| node_user_model
node_todo_repo -->|"maps rows"| node_todo_model
node_user_repo -->|"maps rows"| node_user_model
node_user_repo -->|"returns todos"| node_todo_model
node_todo_handler -->|"serializes errors"| node_error_model
node_user_handler -->|"serializes errors"| node_error_model
node_config -->|"formats errors"| node_error_model

click node_main "https://github.com/temkinnn/rust-notes-api/blob/main/src/main.rs"
click node_config "https://github.com/temkinnn/rust-notes-api/blob/main/src/config.rs"
click node_dbpool "https://github.com/temkinnn/rust-notes-api/blob/main/src/db/mod.rs"
click node_todo_handler "https://github.com/temkinnn/rust-notes-api/blob/main/src/handlers/todo.rs"
click node_user_handler "https://github.com/temkinnn/rust-notes-api/blob/main/src/handlers/user.rs"
click node_todo_service "https://github.com/temkinnn/rust-notes-api/blob/main/src/services/todo.rs"
click node_user_service "https://github.com/temkinnn/rust-notes-api/blob/main/src/services/user.rs"
click node_todo_repo "https://github.com/temkinnn/rust-notes-api/blob/main/src/repositories/todo.rs"
click node_user_repo "https://github.com/temkinnn/rust-notes-api/blob/main/src/repositories/user.rs"
click node_todo_model "https://github.com/temkinnn/rust-notes-api/blob/main/src/models/todo.rs"
click node_user_model "https://github.com/temkinnn/rust-notes-api/blob/main/src/models/user.rs"
click node_error_model "https://github.com/temkinnn/rust-notes-api/blob/main/src/models/res.rs"

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_client toneBlue
class node_todo_handler,node_user_handler,node_todo_service,node_user_service toneAmber
class node_todo_model,node_user_model,node_error_model toneMint
class node_dbpool,node_todo_repo,node_user_repo,node_postgres toneRose
```

## Components

### Server runtime

- [Server entry](https://github.com/temkinnn/rust-notes-api/blob/main/src/main.rs): `src/main.rs`
- [API configuration](https://github.com/temkinnn/rust-notes-api/blob/main/src/config.rs): `src/config.rs`

### HTTP API

- [Todo routes](https://github.com/temkinnn/rust-notes-api/blob/main/src/handlers/todo.rs): `src/handlers/todo.rs`
- [User routes](https://github.com/temkinnn/rust-notes-api/blob/main/src/handlers/user.rs): `src/handlers/user.rs`
- [Todo service](https://github.com/temkinnn/rust-notes-api/blob/main/src/services/todo.rs): `src/services/todo.rs`
- [User service](https://github.com/temkinnn/rust-notes-api/blob/main/src/services/user.rs): `src/services/user.rs`

### Domain models

- [Todo models](https://github.com/temkinnn/rust-notes-api/blob/main/src/models/todo.rs): `src/models/todo.rs`
- [User models](https://github.com/temkinnn/rust-notes-api/blob/main/src/models/user.rs): `src/models/user.rs`
- [Error response](https://github.com/temkinnn/rust-notes-api/blob/main/src/models/res.rs): `src/models/res.rs`

### Persistence

- [Database pool](https://github.com/temkinnn/rust-notes-api/blob/main/src/db/mod.rs): `src/db/mod.rs`
- [Todo repository](https://github.com/temkinnn/rust-notes-api/blob/main/src/repositories/todo.rs): `src/repositories/todo.rs`
- [User repository](https://github.com/temkinnn/rust-notes-api/blob/main/src/repositories/user.rs): `src/repositories/user.rs`
- **PostgreSQL**

### Other components

- **API client**

## Connections

- API client → Server entry: sends requests (evidence: `src/main.rs`)
- Server entry → Database pool: initializes pool (evidence: `src/main.rs`)
- Server entry → API configuration: configures errors (evidence: `src/main.rs`)
- Server entry → Todo routes: registers routes (evidence: `src/main.rs`)
- Server entry → User routes: registers routes (evidence: `src/main.rs`)
- Database pool → PostgreSQL: connects to (evidence: `src/db/mod.rs`)
- Todo routes → Todo service: calls (evidence: `src/handlers/todo.rs`)
- User routes → User service: calls (evidence: `src/handlers/user.rs`)
- Todo routes → Todo repository: constructs (evidence: `src/handlers/todo.rs`)
- User routes → User repository: constructs (evidence: `src/handlers/user.rs`)
- User service → User repository: delegates to (evidence: `src/services/user.rs`)
- Todo service → Todo repository: delegates to
- Todo repository → PostgreSQL: queries (evidence: `src/repositories/todo.rs`)
- User repository → PostgreSQL: queries (evidence: `src/repositories/user.rs`)
- Todo routes → Todo models: accepts DTOs (evidence: `src/handlers/todo.rs`)
- User routes → User models: accepts DTOs (evidence: `src/handlers/user.rs`)
- Todo repository → Todo models: maps rows (evidence: `src/repositories/todo.rs`)
- User repository → User models: maps rows (evidence: `src/repositories/user.rs`)
- User repository → Todo models: returns todos (evidence: `src/repositories/user.rs`)
- Todo routes → Error response: serializes errors (evidence: `src/handlers/todo.rs`)
- User routes → Error response: serializes errors (evidence: `src/handlers/user.rs`)
- API configuration → Error response: formats errors (evidence: `src/config.rs`)
