# mindaandreea/iot_device_app_template architecture

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

- Interactive diagram: https://gitdiagram.com/mindaandreea/iot_device_app_template
- Repository: https://github.com/mindaandreea/iot_device_app_template

## Overview

This is a FastAPI foundation for IoT and AI-powered applications. The shown user workflow is registration or login, followed by authenticated device creation and credential provisioning; devices can later authenticate using those credentials. Shared configuration and SQLAlchemy sessions support the API and its models. The tree also contains AI, telemetry, and notification modules, but their files are only minimal stubs in the available index, so their runtime capabilities and connections cannot be established here.

Main entry points: [`backend/app/core/database.py`](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/core/database.py) (Database sessions), [`backend/app/devices/router.py`](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/devices/router.py) (Device endpoints), [`backend/app/auth/router.py`](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/auth/router.py) (Auth endpoints), [`backend/app/devices/device_dependencies.py`](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/devices/device_dependencies.py) (Device authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API workflows"]
  node_app["FastAPI app<br/>[main.py]"]
  node_auth_routes["Auth endpoints<br/>[router.py]"]
  node_device_routes["Device endpoints<br/>[router.py]"]
end

subgraph group_identity["Identity and access"]
  node_auth_dependencies["User authentication<br/>[dependencies.py]"]
  node_auth_security["Password and tokens<br/>[security.py]"]
  node_auth_models["User model<br/>[models.py]"]
  node_auth_schemas["Auth schemas<br/>[schemas.py]"]
end

subgraph group_device["Device lifecycle"]
  node_device_models["Device models<br/>[models.py]"]
  node_device_schemas["Device schemas<br/>[schemas.py]"]
  node_device_auth["Device authentication"]
  node_device_provisioning["Credential provisioning<br/>[provisioning.py]"]
  node_device_security["Device key security<br/>[security.py]"]
end

subgraph group_platform["Runtime foundation"]
  node_settings["Settings<br/>[config.py]"]
  node_db_sessions["Database sessions<br/>[database.py]"]
  node_sql_store[("SQL database")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_app -->|"registers routes"| node_auth_routes
node_app -->|"registers routes"| node_device_routes
node_auth_routes -->|"hashes and issues"| node_auth_security
node_auth_routes -->|"queries and stores"| node_auth_models
node_auth_routes -->|"validates and returns"| node_auth_schemas
node_auth_routes -->|"gets session"| node_db_sessions
node_auth_dependencies -->|"decodes token"| node_auth_security
node_auth_dependencies -->|"loads user"| node_auth_models
node_auth_dependencies -->|"gets session"| node_db_sessions
node_device_routes -->|"requires user"| node_auth_dependencies
node_device_routes -->|"queries and stores"| node_device_models
node_device_routes -->|"validates and returns"| node_device_schemas
node_device_routes -->|"gets session"| node_db_sessions
node_device_routes -->|"creates or deactivates"| node_device_provisioning
node_device_routes -->|"authenticates device"| node_device_auth
node_device_auth -->|"loads device credentials"| node_device_models
node_device_auth -->|"verifies key"| node_device_security
node_device_auth -->|"gets session"| node_db_sessions
node_device_provisioning -->|"creates credential"| node_device_models
node_device_provisioning -->|"generates and hashes"| node_device_security
node_auth_security -->|"reads token settings"| node_settings
node_auth_models -->|"uses ORM base"| node_db_sessions
node_device_models -->|"uses ORM base"| node_db_sessions
node_db_sessions -->|"reads database URL"| node_settings
node_db_sessions -.->|"opens connections"| node_sql_store

click node_app "https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/main.py"
click node_auth_routes "https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/auth/router.py"
click node_device_routes "https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/devices/router.py"
click node_auth_dependencies "https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/auth/dependencies.py"
click node_auth_security "https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/auth/security.py"
click node_auth_models "https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/auth/models.py"
click node_auth_schemas "https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/auth/schemas.py"
click node_device_models "https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/devices/models.py"
click node_device_schemas "https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/devices/schemas.py"
click node_device_auth "https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/devices/device_dependencies.py"
click node_device_provisioning "https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/devices/provisioning.py"
click node_device_security "https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/devices/security.py"
click node_settings "https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/core/config.py"
click node_db_sessions "https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/core/database.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_auth_routes,node_device_routes,node_client toneBlue
class node_auth_dependencies,node_auth_security,node_auth_models,node_auth_schemas toneAmber
class node_device_models,node_device_schemas,node_device_auth,node_device_provisioning,node_device_security toneMint
class node_settings,node_db_sessions,node_sql_store toneRose
```

## Components

### API workflows

- [FastAPI app](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/main.py): `backend/app/main.py`
- [Auth endpoints](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/auth/router.py): `backend/app/auth/router.py`
- [Device endpoints](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/devices/router.py): `backend/app/devices/router.py`

### Identity and access

- [User authentication](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/auth/dependencies.py): `backend/app/auth/dependencies.py`
- [Password and tokens](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/auth/security.py): `backend/app/auth/security.py`
- [User model](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/auth/models.py): `backend/app/auth/models.py`
- [Auth schemas](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/auth/schemas.py): `backend/app/auth/schemas.py`

### Device lifecycle

- [Device models](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/devices/models.py): `backend/app/devices/models.py`
- [Device schemas](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/devices/schemas.py): `backend/app/devices/schemas.py`
- [Device authentication](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/devices/device_dependencies.py): `backend/app/devices/device_dependencies.py`
- [Credential provisioning](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/devices/provisioning.py): `backend/app/devices/provisioning.py`
- [Device key security](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/devices/security.py): `backend/app/devices/security.py`

### Runtime foundation

- [Settings](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/core/config.py): `backend/app/core/config.py`
- [Database sessions](https://github.com/mindaandreea/iot_device_app_template/blob/main/backend/app/core/database.py): `backend/app/core/database.py`
- **SQL database**

### Other components

- **API client**

## Connections

- API client → FastAPI app: sends requests (evidence: `backend/app/main.py`)
- FastAPI app → Auth endpoints: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Device endpoints: registers routes (evidence: `backend/app/main.py`)
- Auth endpoints → Password and tokens: hashes and issues (evidence: `backend/app/auth/router.py`)
- Auth endpoints → User model: queries and stores (evidence: `backend/app/auth/router.py`)
- Auth endpoints → Auth schemas: validates and returns (evidence: `backend/app/auth/router.py`)
- Auth endpoints → Database sessions: gets session (evidence: `backend/app/auth/router.py`)
- User authentication → Password and tokens: decodes token (evidence: `backend/app/auth/dependencies.py`)
- User authentication → User model: loads user (evidence: `backend/app/auth/dependencies.py`)
- User authentication → Database sessions: gets session (evidence: `backend/app/auth/dependencies.py`)
- Device endpoints → User authentication: requires user (evidence: `backend/app/devices/router.py`)
- Device endpoints → Device models: queries and stores (evidence: `backend/app/devices/router.py`)
- Device endpoints → Device schemas: validates and returns (evidence: `backend/app/devices/router.py`)
- Device endpoints → Database sessions: gets session (evidence: `backend/app/devices/router.py`)
- Device endpoints → Credential provisioning: creates or deactivates (evidence: `backend/app/devices/router.py`)
- Device endpoints → Device authentication: authenticates device (evidence: `backend/app/devices/router.py`)
- Device authentication → Device models: loads device credentials (evidence: `backend/app/devices/device_dependencies.py`)
- Device authentication → Device key security: verifies key (evidence: `backend/app/devices/device_dependencies.py`)
- Device authentication → Database sessions: gets session (evidence: `backend/app/devices/device_dependencies.py`)
- Credential provisioning → Device models: creates credential (evidence: `backend/app/devices/provisioning.py`)
- Credential provisioning → Device key security: generates and hashes (evidence: `backend/app/devices/provisioning.py`)
- Password and tokens → Settings: reads token settings (evidence: `backend/app/auth/security.py`)
- User model → Database sessions: uses ORM base (evidence: `backend/app/auth/models.py`)
- Device models → Database sessions: uses ORM base (evidence: `backend/app/devices/models.py`)
- Database sessions → Settings: reads database URL (evidence: `backend/app/core/database.py`)
- Database sessions → SQL database: opens connections
