# osod-b/iam-rest-fastapi architecture

> Architecture diagram of the GitHub repository osod-b/iam-rest-fastapi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/osod-b/iam-rest-fastapi
- Repository: https://github.com/osod-b/iam-rest-fastapi

## Overview

This is a FastAPI backend for self-managed authentication, client-record CRUD, and manager-only file import/export. The main workflow is an HTTP request entering the app, passing middleware, reaching a controller and service, and then using repositories or Redis as needed; responses return through the controller. Authentication includes registration and email activation, login activation, password recovery, and token refresh. The README also lists view/admin services, but their wiring and behavior are not shown in the sampled source, so those branches are represented cautiously. Repository internals and file-service implementation were not sampled.

Main entry points: [`src/app/main.py`](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/app/main.py) (FastAPI app), [`src/services/authService.py`](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/services/authService.py) (Auth workflows), [`src/controllers/logInController.py`](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/controllers/logInController.py) (Auth routes), [`src/controllers/signUpController.py`](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/controllers/signUpController.py) (Registration routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API runtime"]
  node_app["FastAPI app<br/>[main.py]"]
  node_middleware["Middleware setup<br/>[middle.py]"]
end

subgraph group_auth["Authentication"]
  node_auth_routes["Auth routes<br/>[logInController.py]"]
  node_signup_routes["Registration routes"]
  node_auth_service["Auth workflows<br/>[authService.py]"]
  node_jwt["JWT handling<br/>[jwtService.py]"]
  node_auth_helpers["Auth helpers<br/>[authHelpers.py]"]
  node_user_schema["User schemas<br/>[user.py]"]
  node_user_validation["User validation<br/>[users.py]"]
end

subgraph group_clients["Client records"]
  node_crud_routes["Client routes<br/>[crudController.py]"]
  node_client_service["Client workflows<br/>[crudService.py]"]
  node_client_schema["Client schemas<br/>[client.py]"]
  node_client_validation["Client validation<br/>[clients.py]"]
  node_view_admin["View and admin<br/>[viewService.py]"]
end

subgraph group_files["File exchange"]
  node_files_routes["File routes<br/>[filesController.py]"]
  node_files_service["File workflows<br/>[filesService.py]"]
  node_storage[("File storage")]
end

subgraph group_state["State and persistence"]
  node_user_repo["User repository<br/>[repositories.py]"]
  node_user_model["User model<br/>[user.py]"]
  node_client_repo["Client repository<br/>[repositories.py]"]
  node_client_model["Client model<br/>[client.py]"]
  node_redis[("Redis sessions<br/>[redis.py]")]
  node_database[("SQL database<br/>[schema.py]")]
end

node_user(("API caller"))

node_user -->|"sends requests"| node_app
node_app -->|"configures"| node_middleware
node_app -->|"dispatches"| node_auth_routes
node_app -->|"dispatches"| node_signup_routes
node_app -->|"dispatches"| node_crud_routes
node_app -->|"dispatches"| node_files_routes
node_app -->|"initializes"| node_database
node_auth_routes -->|"calls"| node_auth_service
node_signup_routes -->|"calls"| node_auth_service
node_auth_routes -->|"provides"| node_user_repo
node_signup_routes -->|"provides"| node_user_repo
node_auth_service -->|"queries and updates"| node_user_repo
node_auth_service -->|"stores session data"| node_redis
node_auth_service -->|"creates and refreshes tokens"| node_jwt
node_auth_service -->|"uses"| node_auth_helpers
node_auth_routes -->|"checks token presence"| node_jwt
node_signup_routes -->|"checks token presence"| node_jwt
node_user_repo -->|"builds records"| node_user_model
node_auth_routes -->|"accepts login input"| node_user_schema
node_signup_routes -->|"accepts registration input"| node_user_schema
node_auth_service -->|"uses validators"| node_user_validation
node_crud_routes -->|"calls"| node_client_service
node_crud_routes -->|"provides"| node_client_repo
node_client_service -->|"reads and writes"| node_client_repo
node_client_repo -->|"builds records"| node_client_model
node_crud_routes -->|"checks tokens"| node_jwt
node_crud_routes -->|"accepts client input"| node_client_schema
node_client_service -->|"uses UUID validator"| node_client_validation
node_files_routes -->|"calls"| node_files_service
node_files_routes -->|"provides export repository"| node_client_repo
node_files_routes -->|"checks tokens"| node_jwt
node_files_service -.->|"imports and exports"| node_storage
node_app -.->|"available service"| node_view_admin

click node_app "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/app/main.py"
click node_middleware "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/app/middle.py"
click node_auth_routes "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/controllers/logInController.py"
click node_signup_routes "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/controllers/signUpController.py"
click node_auth_service "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/services/authService.py"
click node_jwt "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/services/jwtService.py"
click node_auth_helpers "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/utils/authHelpers.py"
click node_user_repo "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/utils/repositories.py"
click node_user_model "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/models/user.py"
click node_user_schema "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/schemas/user.py"
click node_user_validation "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/validators/users.py"
click node_crud_routes "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/controllers/crudController.py"
click node_client_service "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/services/crudService.py"
click node_client_repo "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/utils/repositories.py"
click node_client_model "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/models/client.py"
click node_client_schema "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/schemas/client.py"
click node_client_validation "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/validators/clients.py"
click node_files_routes "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/controllers/filesController.py"
click node_files_service "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/services/filesService.py"
click node_storage "https://github.com/osod-b/iam-rest-fastapi/tree/main/storage"
click node_redis "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/app/redis.py"
click node_database "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/db/schema.py"
click node_view_admin "https://github.com/osod-b/iam-rest-fastapi/blob/main/src/services/viewService.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_app,node_middleware toneBlue
class node_auth_routes,node_signup_routes,node_auth_service,node_jwt,node_auth_helpers,node_user_schema,node_user_validation toneAmber
class node_crud_routes,node_client_service,node_client_schema,node_client_validation,node_view_admin,node_user toneMint
class node_files_routes,node_files_service,node_storage toneRose
class node_user_repo,node_user_model,node_client_repo,node_client_model,node_redis,node_database toneIndigo
```

## Components

### API runtime

- [FastAPI app](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/app/main.py): `src/app/main.py`
- [Middleware setup](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/app/middle.py): `src/app/middle.py`

### Authentication

- [Auth routes](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/controllers/logInController.py): `src/controllers/logInController.py`
- [Registration routes](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/controllers/signUpController.py): `src/controllers/signUpController.py`
- [Auth workflows](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/services/authService.py): `src/services/authService.py`
- [JWT handling](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/services/jwtService.py): `src/services/jwtService.py`
- [Auth helpers](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/utils/authHelpers.py): `src/utils/authHelpers.py`
- [User schemas](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/schemas/user.py): `src/schemas/user.py`
- [User validation](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/validators/users.py): `src/validators/users.py`

### Client records

- [Client routes](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/controllers/crudController.py): `src/controllers/crudController.py`
- [Client workflows](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/services/crudService.py): `src/services/crudService.py`
- [Client schemas](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/schemas/client.py): `src/schemas/client.py`
- [Client validation](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/validators/clients.py): `src/validators/clients.py`
- [View and admin](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/services/viewService.py): `src/services/viewService.py`

### File exchange

- [File routes](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/controllers/filesController.py): `src/controllers/filesController.py`
- [File workflows](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/services/filesService.py): `src/services/filesService.py`
- [File storage](https://github.com/osod-b/iam-rest-fastapi/tree/main/storage): `storage`

### State and persistence

- [User repository](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/utils/repositories.py): `src/utils/repositories.py`
- [User model](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/models/user.py): `src/models/user.py`
- [Client repository](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/utils/repositories.py): `src/utils/repositories.py`
- [Client model](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/models/client.py): `src/models/client.py`
- [Redis sessions](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/app/redis.py): `src/app/redis.py`
- [SQL database](https://github.com/osod-b/iam-rest-fastapi/blob/main/src/db/schema.py): `src/db/schema.py`

### Other components

- **API caller**

## Connections

- API caller → FastAPI app: sends requests
- FastAPI app → Middleware setup: configures
- FastAPI app → Auth routes: dispatches
- FastAPI app → Registration routes: dispatches
- FastAPI app → Client routes: dispatches
- FastAPI app → File routes: dispatches
- FastAPI app → SQL database: initializes
- Auth routes → Auth workflows: calls
- Registration routes → Auth workflows: calls
- Auth routes → User repository: provides
- Registration routes → User repository: provides
- Auth workflows → User repository: queries and updates
- Auth workflows → Redis sessions: stores session data
- Auth workflows → JWT handling: creates and refreshes tokens
- Auth workflows → Auth helpers: uses
- Auth routes → JWT handling: checks token presence
- Registration routes → JWT handling: checks token presence
- User repository → User model: builds records
- Auth routes → User schemas: accepts login input
- Registration routes → User schemas: accepts registration input
- Auth workflows → User validation: uses validators
- Client routes → Client workflows: calls
- Client routes → Client repository: provides
- Client workflows → Client repository: reads and writes
- Client repository → Client model: builds records
- Client routes → JWT handling: checks tokens
- Client routes → Client schemas: accepts client input
- Client workflows → Client validation: uses UUID validator
- File routes → File workflows: calls
- File routes → Client repository: provides export repository
- File routes → JWT handling: checks tokens
- File workflows → File storage: imports and exports
- FastAPI app → View and admin: available service
