# tharunhack/rust-crud-apis architecture

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

- Interactive diagram: https://gitdiagram.com/tharunhack/rust-crud-apis
- Repository: https://github.com/tharunhack/rust-crud-apis

## Overview

This is a small Actix Web REST API for PostgreSQL-backed user CRUD. Requests enter the registered `/users` routes, whose handlers validate and execute the requested operation through Diesel, then return JSON or an appropriate HTTP status. The handlers use shared connection-pool setup and typed user/schema definitions. The README documents all five operations; source excerpts show their handler implementations and route registration. Migration files are present in the tree, but their runtime relationship is not shown.

Main entry points: [`src/handlers.rs`](https://github.com/tharunhack/rust-crud-apis/blob/main/src/handlers.rs) (User CRUD handlers), [`src/main.rs`](https://github.com/tharunhack/rust-crud-apis/blob/main/src/main.rs) (Actix server), [`src/db.rs`](https://github.com/tharunhack/rust-crud-apis/blob/main/src/db.rs) (Postgres pool), [`src/models.rs`](https://github.com/tharunhack/rust-crud-apis/blob/main/src/models.rs) (User models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["Actix server<br/>[main.rs]"]
  node_user_handlers["User CRUD handlers<br/>[handlers.rs]"]
end

subgraph group_data["Data access"]
  node_db_pool["Postgres pool<br/>[db.rs]"]
  node_user_models["User models<br/>[models.rs]"]
  node_user_schema["Users schema<br/>[schema.rs]"]
end

node_client(("API client"))
node_postgres[("PostgreSQL")]

node_client -->|"sends HTTP"| node_server
node_server -->|"registers routes"| node_user_handlers
node_server -->|"creates pool"| node_db_pool
node_user_handlers -->|"acquires connections"| node_db_pool
node_user_handlers -->|"uses typed records"| node_user_models
node_user_handlers -->|"queries users table"| node_user_schema
node_db_pool -.->|"manages connections"| node_postgres
node_user_handlers -->|"returns HTTP responses"| node_client

click node_server "https://github.com/tharunhack/rust-crud-apis/blob/main/src/main.rs"
click node_user_handlers "https://github.com/tharunhack/rust-crud-apis/blob/main/src/handlers.rs"
click node_db_pool "https://github.com/tharunhack/rust-crud-apis/blob/main/src/db.rs"
click node_user_models "https://github.com/tharunhack/rust-crud-apis/blob/main/src/models.rs"
click node_user_schema "https://github.com/tharunhack/rust-crud-apis/blob/main/src/schema.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_server,node_user_handlers,node_client toneBlue
class node_db_pool,node_user_models,node_user_schema,node_postgres toneAmber
```

## Components

### HTTP API

- [Actix server](https://github.com/tharunhack/rust-crud-apis/blob/main/src/main.rs): `src/main.rs`
- [User CRUD handlers](https://github.com/tharunhack/rust-crud-apis/blob/main/src/handlers.rs): `src/handlers.rs`

### Data access

- [Postgres pool](https://github.com/tharunhack/rust-crud-apis/blob/main/src/db.rs): `src/db.rs`
- [User models](https://github.com/tharunhack/rust-crud-apis/blob/main/src/models.rs): `src/models.rs`
- [Users schema](https://github.com/tharunhack/rust-crud-apis/blob/main/src/schema.rs): `src/schema.rs`

### Other components

- **API client**
- **PostgreSQL**

## Connections

- API client → Actix server: sends HTTP (evidence: `README.md`)
- Actix server → User CRUD handlers: registers routes (evidence: `src/main.rs`)
- Actix server → Postgres pool: creates pool (evidence: `src/main.rs`)
- User CRUD handlers → Postgres pool: acquires connections (evidence: `src/handlers.rs`)
- User CRUD handlers → User models: uses typed records (evidence: `src/handlers.rs`)
- User CRUD handlers → Users schema: queries users table (evidence: `src/handlers.rs`)
- Postgres pool → PostgreSQL: manages connections
- User CRUD handlers → API client: returns HTTP responses (evidence: `src/handlers.rs`)
