# patronsafety-create/storage_management architecture

> Architecture diagram of the GitHub repository patronsafety-create/storage_management, 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/patronsafety-create/storage_management
- Repository: https://github.com/patronsafety-create/storage_management

## Overview

This repository is a Storage ERP API whose visible runtime path is authentication: a client submits credentials to the FastAPI app, the login handler checks the user and password, then returns a JWT. A separate dependency validates bearer tokens and looks up the corresponding user. The domain layer also defines warehouse, product, price-list, and receipt/issue status models, but the supplied sources show no operational endpoints for those capabilities. The README is empty, so the map reflects only the supplied source excerpts and index.

Main entry points: [`src/api/auth.py`](https://github.com/patronsafety-create/storage_management/blob/main/src/api/auth.py) (Login handler), [`src/api/dependencies.py`](https://github.com/patronsafety-create/storage_management/blob/main/src/api/dependencies.py) (Token guard), [`src/infrastructure/database.py`](https://github.com/patronsafety-create/storage_management/blob/main/src/infrastructure/database.py) (Database sessions), [`src/api/main.py`](https://github.com/patronsafety-create/storage_management/blob/main/src/api/main.py) (FastAPI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and authentication"]
  node_app["FastAPI app<br/>[main.py]"]
  node_login["Login handler<br/>[auth.py]"]
  node_auth_guard["Token guard<br/>[dependencies.py]"]
end

subgraph group_security["Security services"]
  node_password_jwt["Password and JWT<br/>[security.py]"]
end

subgraph group_domain["ERP domain"]
  node_token_schemas["Auth schemas<br/>[auth_schemas.py]"]
  node_auth_entities["User and access entities<br/>[auth_models.py]"]
  node_warehouse_catalog["Warehouse and catalog<br/>[models.py]"]
  node_warehouse_schemas["Warehouse and catalog schemas<br/>[schemas.py]"]
  node_document_states["Inventory document states<br/>[enums.py]"]
end

subgraph group_persistence["Persistence"]
  node_db_session["Database sessions<br/>[database.py]"]
end

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

node_client -->|"sends requests"| node_app
node_app -->|"mounts router"| node_login
node_login -->|"requests session"| node_db_session
node_login -->|"queries user"| node_auth_entities
node_login -->|"verifies and issues"| node_password_jwt
node_login -->|"returns token schema"| node_token_schemas
node_auth_guard -->|"requests session"| node_db_session
node_auth_guard -->|"uses signing config"| node_password_jwt
node_auth_guard -->|"queries user"| node_auth_entities
node_auth_guard -->|"builds token data"| node_token_schemas
node_db_session -->|"connects to"| node_postgres
node_warehouse_schemas -.->|"shapes records"| node_warehouse_catalog

click node_app "https://github.com/patronsafety-create/storage_management/blob/main/src/api/main.py"
click node_login "https://github.com/patronsafety-create/storage_management/blob/main/src/api/auth.py"
click node_auth_guard "https://github.com/patronsafety-create/storage_management/blob/main/src/api/dependencies.py"
click node_token_schemas "https://github.com/patronsafety-create/storage_management/blob/main/src/domain_model/auth_schemas.py"
click node_auth_entities "https://github.com/patronsafety-create/storage_management/blob/main/src/domain_model/auth_models.py"
click node_password_jwt "https://github.com/patronsafety-create/storage_management/blob/main/src/infrastructure/security.py"
click node_db_session "https://github.com/patronsafety-create/storage_management/blob/main/src/infrastructure/database.py"
click node_warehouse_catalog "https://github.com/patronsafety-create/storage_management/blob/main/src/domain_model/models.py"
click node_warehouse_schemas "https://github.com/patronsafety-create/storage_management/blob/main/src/schemas.py"
click node_document_states "https://github.com/patronsafety-create/storage_management/blob/main/src/domain_model/enums.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_login,node_auth_guard,node_client toneBlue
class node_password_jwt,node_postgres toneAmber
class node_token_schemas,node_auth_entities,node_warehouse_catalog,node_warehouse_schemas,node_document_states toneMint
class node_db_session toneRose
```

## Components

### API and authentication

- [FastAPI app](https://github.com/patronsafety-create/storage_management/blob/main/src/api/main.py): `src/api/main.py`
- [Login handler](https://github.com/patronsafety-create/storage_management/blob/main/src/api/auth.py): `src/api/auth.py`
- [Token guard](https://github.com/patronsafety-create/storage_management/blob/main/src/api/dependencies.py): `src/api/dependencies.py`

### Security services

- [Password and JWT](https://github.com/patronsafety-create/storage_management/blob/main/src/infrastructure/security.py): `src/infrastructure/security.py`

### ERP domain

- [Auth schemas](https://github.com/patronsafety-create/storage_management/blob/main/src/domain_model/auth_schemas.py): `src/domain_model/auth_schemas.py`
- [User and access entities](https://github.com/patronsafety-create/storage_management/blob/main/src/domain_model/auth_models.py): `src/domain_model/auth_models.py`
- [Warehouse and catalog](https://github.com/patronsafety-create/storage_management/blob/main/src/domain_model/models.py): `src/domain_model/models.py`
- [Warehouse and catalog schemas](https://github.com/patronsafety-create/storage_management/blob/main/src/schemas.py): `src/schemas.py`
- [Inventory document states](https://github.com/patronsafety-create/storage_management/blob/main/src/domain_model/enums.py): `src/domain_model/enums.py`

### Persistence

- [Database sessions](https://github.com/patronsafety-create/storage_management/blob/main/src/infrastructure/database.py): `src/infrastructure/database.py`

### Other components

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

## Connections

- API client → FastAPI app: sends requests (evidence: `src/api/main.py`)
- FastAPI app → Login handler: mounts router (evidence: `src/api/main.py`)
- Login handler → Database sessions: requests session (evidence: `src/api/auth.py`)
- Login handler → User and access entities: queries user (evidence: `src/api/auth.py`)
- Login handler → Password and JWT: verifies and issues (evidence: `src/api/auth.py`)
- Login handler → Auth schemas: returns token schema (evidence: `src/api/auth.py`)
- Token guard → Database sessions: requests session (evidence: `src/api/dependencies.py`)
- Token guard → Password and JWT: uses signing config (evidence: `src/api/dependencies.py`)
- Token guard → User and access entities: queries user (evidence: `src/api/dependencies.py`)
- Token guard → Auth schemas: builds token data (evidence: `src/api/dependencies.py`)
- Database sessions → PostgreSQL: connects to (evidence: `src/infrastructure/database.py`)
- Warehouse and catalog schemas → Warehouse and catalog: shapes records
