# dmaq32/notes-api architecture

> Architecture diagram of the GitHub repository dmaq32/notes-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/dmaq32/notes-api
- Repository: https://github.com/dmaq32/notes-api

## Overview

Notes API serves registration and JWT login, then uses bearer authentication to scope note CRUD, filtering, and pagination to the current user. Creating or deleting a note publishes an event to RabbitMQ; a separate consumer records created/deleted events in the history table. The graph shows the API, persistence, and event-processing layers. Source excerpts support the shown calls; other README-described behavior is represented without inferring unsampled internal calls.

Main entry points: [`app/routers/note.py`](https://github.com/dmaq32/notes-api/blob/master/app/routers/note.py) (Note operations), [`app/routers/user.py`](https://github.com/dmaq32/notes-api/blob/master/app/routers/user.py) (Registration and login), [`app/db/config.py`](https://github.com/dmaq32/notes-api/blob/master/app/db/config.py) (Async DB sessions), [`app/rabbitmq/consumer.py`](https://github.com/dmaq32/notes-api/blob/master/app/rabbitmq/consumer.py) (Event consumer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and identity"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_user_routes["Registration and login<br/>[user.py]"]
  node_note_routes["Note operations<br/>[note.py]"]
  node_auth["JWT authentication<br/>[utils.py]"]
  node_schemas["Request and response schemas<br/>[schemas.py]"]
end

subgraph group_data["Persistence"]
  node_db_config["Async DB sessions<br/>[config.py]"]
  node_models["User, note, history models<br/>[models.py]"]
  node_postgres[("PostgreSQL")]
end

subgraph group_events["Event history"]
  node_mq_config["Broker configuration<br/>[config.py]"]
  node_rabbitmq["RabbitMQ"]
  node_consumer["Event consumer<br/>[consumer.py]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_api_app
node_api_app -->|"registers router"| node_user_routes
node_api_app -->|"registers router"| node_note_routes
node_api_app -->|"opens connection"| node_mq_config
node_user_routes -->|"validates payloads"| node_schemas
node_user_routes -->|"queries via sessions"| node_db_config
node_user_routes -->|"reads and creates users"| node_models
node_user_routes -->|"creates token"| node_auth
node_note_routes -->|"validates and shapes"| node_schemas
node_note_routes -->|"resolves current user"| node_auth
node_note_routes -->|"queries via sessions"| node_db_config
node_note_routes -->|"reads and changes notes"| node_models
node_auth -->|"loads user"| node_db_config
node_auth -->|"loads user model"| node_models
node_db_config -.->|"connects"| node_postgres
node_note_routes -->|"publishes note events"| node_rabbitmq
node_mq_config -->|"connects and configures"| node_rabbitmq
node_consumer -->|"opens connection"| node_mq_config
node_consumer -->|"binds and consumes"| node_rabbitmq
node_consumer -->|"opens session"| node_db_config
node_consumer -->|"inserts history records"| node_models

click node_api_app "https://github.com/dmaq32/notes-api/blob/master/app/main.py"
click node_user_routes "https://github.com/dmaq32/notes-api/blob/master/app/routers/user.py"
click node_note_routes "https://github.com/dmaq32/notes-api/blob/master/app/routers/note.py"
click node_auth "https://github.com/dmaq32/notes-api/blob/master/app/utils.py"
click node_schemas "https://github.com/dmaq32/notes-api/blob/master/app/db/schemas.py"
click node_db_config "https://github.com/dmaq32/notes-api/blob/master/app/db/config.py"
click node_models "https://github.com/dmaq32/notes-api/blob/master/app/db/models.py"
click node_mq_config "https://github.com/dmaq32/notes-api/blob/master/app/rabbitmq/config.py"
click node_consumer "https://github.com/dmaq32/notes-api/blob/master/app/rabbitmq/consumer.py"

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_api_app,node_user_routes,node_note_routes,node_auth,node_schemas,node_client toneBlue
class node_db_config,node_models,node_postgres toneAmber
class node_mq_config,node_rabbitmq,node_consumer toneMint
```

## Components

### API and identity

- [FastAPI app](https://github.com/dmaq32/notes-api/blob/master/app/main.py): `app/main.py`
- [Registration and login](https://github.com/dmaq32/notes-api/blob/master/app/routers/user.py): `app/routers/user.py`
- [Note operations](https://github.com/dmaq32/notes-api/blob/master/app/routers/note.py): `app/routers/note.py`
- [JWT authentication](https://github.com/dmaq32/notes-api/blob/master/app/utils.py): `app/utils.py`
- [Request and response schemas](https://github.com/dmaq32/notes-api/blob/master/app/db/schemas.py): `app/db/schemas.py`

### Persistence

- [Async DB sessions](https://github.com/dmaq32/notes-api/blob/master/app/db/config.py): `app/db/config.py`
- [User, note, history models](https://github.com/dmaq32/notes-api/blob/master/app/db/models.py): `app/db/models.py`
- **PostgreSQL**

### Event history

- [Broker configuration](https://github.com/dmaq32/notes-api/blob/master/app/rabbitmq/config.py): `app/rabbitmq/config.py`
- **RabbitMQ**
- [Event consumer](https://github.com/dmaq32/notes-api/blob/master/app/rabbitmq/consumer.py): `app/rabbitmq/consumer.py`

### Other components

- **API client**

## Connections

- API client → FastAPI app: sends requests (evidence: `README.md`)
- FastAPI app → Registration and login: registers router (evidence: `app/main.py`)
- FastAPI app → Note operations: registers router (evidence: `app/main.py`)
- FastAPI app → Broker configuration: opens connection (evidence: `app/main.py`)
- Registration and login → Request and response schemas: validates payloads (evidence: `app/routers/user.py`)
- Registration and login → Async DB sessions: queries via sessions (evidence: `app/routers/user.py`)
- Registration and login → User, note, history models: reads and creates users (evidence: `app/routers/user.py`)
- Registration and login → JWT authentication: creates token (evidence: `app/routers/user.py`)
- Note operations → Request and response schemas: validates and shapes (evidence: `app/routers/note.py`)
- Note operations → JWT authentication: resolves current user (evidence: `app/routers/note.py`)
- Note operations → Async DB sessions: queries via sessions (evidence: `app/routers/note.py`)
- Note operations → User, note, history models: reads and changes notes (evidence: `app/routers/note.py`)
- JWT authentication → Async DB sessions: loads user (evidence: `app/utils.py`)
- JWT authentication → User, note, history models: loads user model (evidence: `app/utils.py`)
- Async DB sessions → PostgreSQL: connects
- Note operations → RabbitMQ: publishes note events (evidence: `app/routers/note.py`)
- Broker configuration → RabbitMQ: connects and configures (evidence: `app/rabbitmq/config.py`)
- Event consumer → Broker configuration: opens connection (evidence: `app/rabbitmq/consumer.py`)
- Event consumer → RabbitMQ: binds and consumes (evidence: `app/rabbitmq/consumer.py`)
- Event consumer → Async DB sessions: opens session (evidence: `app/rabbitmq/consumer.py`)
- Event consumer → User, note, history models: inserts history records (evidence: `app/rabbitmq/consumer.py`)
