# mrterrestrial/fastapi-jwtauth architecture

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

- Interactive diagram: https://gitdiagram.com/mrterrestrial/fastapi-jwtauth
- Repository: https://github.com/mrterrestrial/fastapi-jwtauth

## Overview

This is a FastAPI user-authentication API. Clients register accounts, log in with a password to receive a JWT cookie, and use that cookie to access their profile. The API entry point registers the routes; route handlers use a shared SQLAlchemy session and the User model, while database configuration binds sessions and metadata to SQLite. The graph follows the sampled routes and README capabilities; it does not imply unsampled behavior beyond those descriptions.

Main entry points: [`run.py`](https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/run.py) (FastAPI app), [`app/routes/profile.py`](https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/routes/profile.py) (Profile route), [`app/routes/login.py`](https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/routes/login.py) (Login), [`app/routes/register.py`](https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/routes/register.py) (Registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routes"]
  node_app["FastAPI app<br/>[run.py]"]
  node_index["Root route<br/>[index.py]"]
  node_profile["Profile route<br/>[profile.py]"]
end

subgraph group_auth["Identity and tokens"]
  node_register["Registration<br/>[register.py]"]
  node_login["Login<br/>[login.py]"]
  node_jwt["JWT validation<br/>[profile.py]"]
end

subgraph group_storage["Persistence"]
  node_user["User model<br/>[user_model.py]"]
  node_sessions["DB sessions<br/>[db.py]"]
  node_database["SQLite config<br/>[database.py]"]
  node_sqlite[("SQLite store<br/>[app.db]")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_app -->|"registers route"| node_index
node_app -->|"registers route"| node_register
node_app -->|"registers route"| node_login
node_app -->|"registers route"| node_profile
node_client -->|"posts account"| node_register
node_register -->|"gets session"| node_sessions
node_register -->|"creates user"| node_user
node_client -->|"posts credentials"| node_login
node_login -->|"gets session"| node_sessions
node_login -->|"queries user"| node_user
node_login -->|"sets JWT cookie"| node_client
node_client -->|"requests profile"| node_profile
node_profile -->|"validates cookie"| node_jwt
node_profile -->|"gets session"| node_sessions
node_profile -->|"queries user"| node_user
node_sessions -->|"opens session"| node_database
node_user -->|"uses metadata"| node_database
node_database -->|"configures store"| node_sqlite

click node_app "https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/run.py"
click node_index "https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/routes/index.py"
click node_register "https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/routes/register.py"
click node_login "https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/routes/login.py"
click node_jwt "https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/routes/profile.py"
click node_profile "https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/routes/profile.py"
click node_user "https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/models/user_model.py"
click node_sessions "https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/utils/db.py"
click node_database "https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/config/database.py"
click node_sqlite "https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app.db"

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_index,node_profile,node_client toneBlue
class node_register,node_login,node_jwt toneAmber
class node_user,node_sessions,node_database,node_sqlite toneMint
```

## Components

### API routes

- [FastAPI app](https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/run.py): `run.py`
- [Root route](https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/routes/index.py): `app/routes/index.py`
- [Profile route](https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/routes/profile.py): `app/routes/profile.py`

### Identity and tokens

- [Registration](https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/routes/register.py): `app/routes/register.py`
- [Login](https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/routes/login.py): `app/routes/login.py`
- [JWT validation](https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/routes/profile.py): `app/routes/profile.py`

### Persistence

- [User model](https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/models/user_model.py): `app/models/user_model.py`
- [DB sessions](https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app/utils/db.py): `app/utils/db.py`
- [SQLite config](https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/config/database.py): `config/database.py`
- [SQLite store](https://github.com/mrterrestrial/fastapi-jwtauth/blob/master/app.db): `app.db`

### Other components

- **API client**

## Connections

- API client → FastAPI app: sends requests (evidence: `README.md`)
- FastAPI app → Root route: registers route (evidence: `run.py`)
- FastAPI app → Registration: registers route (evidence: `run.py`)
- FastAPI app → Login: registers route (evidence: `run.py`)
- FastAPI app → Profile route: registers route (evidence: `run.py`)
- API client → Registration: posts account (evidence: `README.md`)
- Registration → DB sessions: gets session (evidence: `app/routes/register.py`)
- Registration → User model: creates user (evidence: `app/routes/register.py`)
- API client → Login: posts credentials (evidence: `README.md`)
- Login → DB sessions: gets session (evidence: `app/routes/login.py`)
- Login → User model: queries user (evidence: `app/routes/login.py`)
- Login → API client: sets JWT cookie (evidence: `README.md`)
- API client → Profile route: requests profile (evidence: `README.md`)
- Profile route → JWT validation: validates cookie (evidence: `app/routes/profile.py`)
- Profile route → DB sessions: gets session (evidence: `app/routes/profile.py`)
- Profile route → User model: queries user (evidence: `app/routes/profile.py`)
- DB sessions → SQLite config: opens session (evidence: `app/utils/db.py`)
- User model → SQLite config: uses metadata (evidence: `app/models/user_model.py`)
- SQLite config → SQLite store: configures store (evidence: `config/database.py`)
