# ladsonsa/user-crud-api architecture

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

- Interactive diagram: https://gitdiagram.com/ladsonsa/user-crud-api
- Repository: https://github.com/ladsonsa/user-crud-api

## Overview

User CRUD API is a layered FastAPI service for registering, authenticating, and managing users. Requests enter through the API routes, pass through controllers and services to domain workflows, and use a repository for persistence. Authentication validates credentials and issues JWTs; protected individual-user operations enforce ownership. The README documents the broad layer flow, while sampled source and the SOURCE INDEX substantiate key dependency wiring and calls; some routing and security details are documented rather than fully sampled.

Main entry points: [`app/repositories/sqlalchemy_user_repository.py`](https://github.com/ladsonsa/user-crud-api/blob/main/app/repositories/sqlalchemy_user_repository.py) (User repository), [`app/services/user_service.py`](https://github.com/ladsonsa/user-crud-api/blob/main/app/services/user_service.py) (User service), [`app/config/dependencies.py`](https://github.com/ladsonsa/user-crud-api/blob/main/app/config/dependencies.py) (Dependency assembly), [`app/router/routes/user_router.py`](https://github.com/ladsonsa/user-crud-api/blob/main/app/router/routes/user_router.py) (User routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_auth_route["Auth routes<br/>[auth_router.py]"]
  node_user_route["User routes<br/>[user_router.py]"]
  node_auth_controller["Auth controller<br/>[auth_controller.py]"]
  node_user_controller["User controller<br/>[user_controller.py]"]
  node_dto["Request/response DTOs"]
end

subgraph group_security["Identity &amp; Access"]
  node_authn["JWT authentication<br/>[authentication.py]"]
  node_authorization["Ownership checks<br/>[authorization.py]"]
  node_password["Password hashing<br/>[password.py]"]
  node_token["JWT tokens<br/>[token.py]"]
end

subgraph group_domain["User Operations"]
  node_auth_service["Auth service<br/>[auth_service.py]"]
  node_auth_workflow["Credential validation"]
  node_user_service["User service<br/>[user_service.py]"]
  node_create_user["Create user<br/>[create_user.py]"]
  node_list_users["List users<br/>[list_users.py]"]
  node_get_user["Get user<br/>[get_user.py]"]
  node_update_user["Update user<br/>[update_user.py]"]
  node_delete_user["Delete user<br/>[delete_user.py]"]
end

subgraph group_persistence["Persistence"]
  node_repository["User repository"]
  node_user_model["User ORM model<br/>[user_model.py]"]
  node_session["DB session<br/>[session.py]"]
  node_database[("PostgreSQL")]
end

subgraph group_runtime["Application Runtime"]
  node_main["FastAPI app<br/>[main.py]"]
  node_dependencies["Dependency assembly<br/>[dependencies.py]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_main
node_main -->|"registers routes"| node_auth_route
node_main -->|"registers routes"| node_user_route
node_auth_route -->|"dispatches to"| node_auth_controller
node_user_route -->|"dispatches to"| node_user_controller
node_auth_route -->|"validates payload"| node_dto
node_user_route -->|"validates payload"| node_dto
node_auth_controller -->|"calls"| node_auth_service
node_user_controller -->|"calls"| node_user_service
node_auth_service -->|"executes"| node_auth_workflow
node_auth_service -->|"issues token"| node_token
node_auth_workflow -->|"verifies password"| node_password
node_authn -->|"validates JWT"| node_token
node_user_route -->|"requires identity"| node_authn
node_authn -->|"resolves user for"| node_authorization
node_authorization -->|"guards operations"| node_user_controller
node_user_service -->|"executes"| node_create_user
node_user_service -->|"executes"| node_list_users
node_user_service -->|"executes"| node_get_user
node_user_service -->|"executes"| node_update_user
node_user_service -->|"executes"| node_delete_user
node_dependencies -->|"assembles"| node_user_service
node_dependencies -->|"assembles"| node_auth_service
node_dependencies -->|"constructs"| node_repository
node_dependencies -->|"gets session"| node_session
node_create_user -->|"persists via"| node_repository
node_list_users -->|"queries via"| node_repository
node_get_user -->|"queries via"| node_repository
node_update_user -->|"updates via"| node_repository
node_delete_user -->|"deletes via"| node_repository
node_auth_workflow -->|"looks up user"| node_repository
node_repository -->|"queries and persists"| node_user_model
node_repository -->|"reads/writes"| node_database
node_session -->|"connects to"| node_database

click node_main "https://github.com/ladsonsa/user-crud-api/blob/main/app/main.py"
click node_auth_route "https://github.com/ladsonsa/user-crud-api/blob/main/app/router/routes/auth_router.py"
click node_user_route "https://github.com/ladsonsa/user-crud-api/blob/main/app/router/routes/user_router.py"
click node_auth_controller "https://github.com/ladsonsa/user-crud-api/blob/main/app/controllers/auth_controller.py"
click node_user_controller "https://github.com/ladsonsa/user-crud-api/blob/main/app/controllers/user_controller.py"
click node_dto "https://github.com/ladsonsa/user-crud-api/tree/main/app/dtos"
click node_authn "https://github.com/ladsonsa/user-crud-api/blob/main/app/security/authentication.py"
click node_authorization "https://github.com/ladsonsa/user-crud-api/blob/main/app/security/authorization.py"
click node_password "https://github.com/ladsonsa/user-crud-api/blob/main/app/security/password.py"
click node_token "https://github.com/ladsonsa/user-crud-api/blob/main/app/security/token.py"
click node_auth_service "https://github.com/ladsonsa/user-crud-api/blob/main/app/services/auth_service.py"
click node_auth_workflow "https://github.com/ladsonsa/user-crud-api/blob/main/app/workflows/authenticate_user.py"
click node_user_service "https://github.com/ladsonsa/user-crud-api/blob/main/app/services/user_service.py"
click node_create_user "https://github.com/ladsonsa/user-crud-api/blob/main/app/workflows/create_user.py"
click node_list_users "https://github.com/ladsonsa/user-crud-api/blob/main/app/workflows/list_users.py"
click node_get_user "https://github.com/ladsonsa/user-crud-api/blob/main/app/workflows/get_user.py"
click node_update_user "https://github.com/ladsonsa/user-crud-api/blob/main/app/workflows/update_user.py"
click node_delete_user "https://github.com/ladsonsa/user-crud-api/blob/main/app/workflows/delete_user.py"
click node_dependencies "https://github.com/ladsonsa/user-crud-api/blob/main/app/config/dependencies.py"
click node_repository "https://github.com/ladsonsa/user-crud-api/blob/main/app/repositories/sqlalchemy_user_repository.py"
click node_user_model "https://github.com/ladsonsa/user-crud-api/blob/main/app/models/user_model.py"
click node_session "https://github.com/ladsonsa/user-crud-api/blob/main/app/database/session.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_auth_route,node_user_route,node_auth_controller,node_user_controller,node_dto,node_client toneBlue
class node_authn,node_authorization,node_password,node_token toneAmber
class node_auth_service,node_auth_workflow,node_user_service,node_create_user,node_list_users,node_get_user,node_update_user,node_delete_user toneMint
class node_repository,node_user_model,node_session,node_database toneRose
class node_main,node_dependencies toneIndigo
```

## Components

### HTTP API

- [Auth routes](https://github.com/ladsonsa/user-crud-api/blob/main/app/router/routes/auth_router.py): `app/router/routes/auth_router.py`
- [User routes](https://github.com/ladsonsa/user-crud-api/blob/main/app/router/routes/user_router.py): `app/router/routes/user_router.py`
- [Auth controller](https://github.com/ladsonsa/user-crud-api/blob/main/app/controllers/auth_controller.py): `app/controllers/auth_controller.py`
- [User controller](https://github.com/ladsonsa/user-crud-api/blob/main/app/controllers/user_controller.py): `app/controllers/user_controller.py`
- [Request/response DTOs](https://github.com/ladsonsa/user-crud-api/tree/main/app/dtos): `app/dtos`

### Identity & Access

- [JWT authentication](https://github.com/ladsonsa/user-crud-api/blob/main/app/security/authentication.py): `app/security/authentication.py`
- [Ownership checks](https://github.com/ladsonsa/user-crud-api/blob/main/app/security/authorization.py): `app/security/authorization.py`
- [Password hashing](https://github.com/ladsonsa/user-crud-api/blob/main/app/security/password.py): `app/security/password.py`
- [JWT tokens](https://github.com/ladsonsa/user-crud-api/blob/main/app/security/token.py): `app/security/token.py`

### User Operations

- [Auth service](https://github.com/ladsonsa/user-crud-api/blob/main/app/services/auth_service.py): `app/services/auth_service.py`
- [Credential validation](https://github.com/ladsonsa/user-crud-api/blob/main/app/workflows/authenticate_user.py): `app/workflows/authenticate_user.py`
- [User service](https://github.com/ladsonsa/user-crud-api/blob/main/app/services/user_service.py): `app/services/user_service.py`
- [Create user](https://github.com/ladsonsa/user-crud-api/blob/main/app/workflows/create_user.py): `app/workflows/create_user.py`
- [List users](https://github.com/ladsonsa/user-crud-api/blob/main/app/workflows/list_users.py): `app/workflows/list_users.py`
- [Get user](https://github.com/ladsonsa/user-crud-api/blob/main/app/workflows/get_user.py): `app/workflows/get_user.py`
- [Update user](https://github.com/ladsonsa/user-crud-api/blob/main/app/workflows/update_user.py): `app/workflows/update_user.py`
- [Delete user](https://github.com/ladsonsa/user-crud-api/blob/main/app/workflows/delete_user.py): `app/workflows/delete_user.py`

### Persistence

- [User repository](https://github.com/ladsonsa/user-crud-api/blob/main/app/repositories/sqlalchemy_user_repository.py): `app/repositories/sqlalchemy_user_repository.py`
- [User ORM model](https://github.com/ladsonsa/user-crud-api/blob/main/app/models/user_model.py): `app/models/user_model.py`
- [DB session](https://github.com/ladsonsa/user-crud-api/blob/main/app/database/session.py): `app/database/session.py`
- **PostgreSQL**

### Application Runtime

- [FastAPI app](https://github.com/ladsonsa/user-crud-api/blob/main/app/main.py): `app/main.py`
- [Dependency assembly](https://github.com/ladsonsa/user-crud-api/blob/main/app/config/dependencies.py): `app/config/dependencies.py`

### Other components

- **API client**

## Connections

- API client → FastAPI app: sends requests (evidence: `README.md`)
- FastAPI app → Auth routes: registers routes (evidence: `app/main.py`)
- FastAPI app → User routes: registers routes (evidence: `app/main.py`)
- Auth routes → Auth controller: dispatches to (evidence: `app/router/routes/auth_router.py`)
- User routes → User controller: dispatches to (evidence: `app/router/routes/user_router.py`)
- Auth routes → Request/response DTOs: validates payload (evidence: `app/router/routes/auth_router.py`)
- User routes → Request/response DTOs: validates payload (evidence: `app/router/routes/user_router.py`)
- Auth controller → Auth service: calls (evidence: `app/controllers/auth_controller.py`)
- User controller → User service: calls (evidence: `app/controllers/user_controller.py`)
- Auth service → Credential validation: executes (evidence: `app/services/auth_service.py`)
- Auth service → JWT tokens: issues token (evidence: `app/services/auth_service.py`)
- Credential validation → Password hashing: verifies password (evidence: `app/workflows/authenticate_user.py`)
- JWT authentication → JWT tokens: validates JWT (evidence: `app/security/authentication.py`)
- User routes → JWT authentication: requires identity (evidence: `README.md`)
- JWT authentication → Ownership checks: resolves user for (evidence: `README.md`)
- Ownership checks → User controller: guards operations (evidence: `README.md`)
- User service → Create user: executes (evidence: `app/services/user_service.py`)
- User service → List users: executes (evidence: `app/services/user_service.py`)
- User service → Get user: executes (evidence: `app/services/user_service.py`)
- User service → Update user: executes (evidence: `app/services/user_service.py`)
- User service → Delete user: executes (evidence: `app/services/user_service.py`)
- Dependency assembly → User service: assembles (evidence: `app/config/dependencies.py`)
- Dependency assembly → Auth service: assembles (evidence: `app/config/dependencies.py`)
- Dependency assembly → User repository: constructs (evidence: `app/config/dependencies.py`)
- Dependency assembly → DB session: gets session (evidence: `app/config/dependencies.py`)
- Create user → User repository: persists via (evidence: `app/workflows/create_user.py`)
- List users → User repository: queries via (evidence: `app/workflows/list_users.py`)
- Get user → User repository: queries via (evidence: `app/workflows/get_user.py`)
- Update user → User repository: updates via (evidence: `app/workflows/update_user.py`)
- Delete user → User repository: deletes via (evidence: `app/workflows/delete_user.py`)
- Credential validation → User repository: looks up user (evidence: `app/workflows/authenticate_user.py`)
- User repository → User ORM model: queries and persists (evidence: `app/repositories/sqlalchemy_user_repository.py`)
- User repository → PostgreSQL: reads/writes (evidence: `README.md`)
- DB session → PostgreSQL: connects to (evidence: `app/database/session.py`)
