# thrigunchandra/c2_rbac architecture

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

- Interactive diagram: https://gitdiagram.com/thrigunchandra/c2_rbac
- Repository: https://github.com/thrigunchandra/c2_rbac

## Overview

This is a learning-oriented FastAPI authentication and RBAC API. A user registers or logs in; registration stores an Argon2 password hash, while login returns a signed, expiring JWT. Protected requests pass through token validation, and admin-only endpoints list, update, or delete users. The main internal layers are route handlers, authentication/security helpers, SQLAlchemy models and sessions, and configuration. PostgreSQL is the documented backing store. Edges reflect shown calls or README statements; unsampled runtime behavior is not inferred.

Main entry points: [`app/routes/auth.py`](https://github.com/thrigunchandra/c2_rbac/blob/main/app/routes/auth.py) (Auth endpoints), [`app/main.py`](https://github.com/thrigunchandra/c2_rbac/blob/main/app/main.py) (FastAPI application), [`app/routes/admin.py`](https://github.com/thrigunchandra/c2_rbac/blob/main/app/routes/admin.py) (Admin endpoints), [`app/database.py`](https://github.com/thrigunchandra/c2_rbac/blob/main/app/database.py) (Engine and sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routing"]
  node_application["FastAPI application<br/>[main.py]"]
  node_auth_routes["Auth endpoints<br/>[auth.py]"]
  node_admin_routes["Admin endpoints<br/>[admin.py]"]
  node_schemas["Request and response schemas<br/>[schemas.py]"]
end

subgraph group_identity["Authentication and RBAC"]
  node_dependencies["Token and admin checks<br/>[dependencies.py]"]
  node_security["Password and JWT helpers<br/>[security.py]"]
end

subgraph group_data["Persistence"]
  node_user_model["User model<br/>[models.py]"]
  node_db_sessions["Engine and sessions<br/>[database.py]"]
  node_postgres[("PostgreSQL")]
end

subgraph group_settings["Configuration"]
  node_config["Environment configuration<br/>[config.py]"]
end

node_user(("API user"))

node_user -->|"sends requests"| node_application
node_application -->|"registers router"| node_auth_routes
node_application -->|"registers router"| node_admin_routes
node_application -->|"creates tables via"| node_db_sessions
node_application -->|"creates tables from"| node_user_model
node_auth_routes -->|"uses request schemas"| node_schemas
node_auth_routes -->|"opens sessions"| node_db_sessions
node_auth_routes -->|"queries and stores"| node_user_model
node_auth_routes -->|"hashes and issues tokens"| node_security
node_auth_routes -->|"uses access checks"| node_dependencies
node_admin_routes -->|"uses admin schemas"| node_schemas
node_admin_routes -->|"gets database session"| node_db_sessions
node_admin_routes -->|"queries and updates"| node_user_model
node_admin_routes -->|"requires admin"| node_dependencies
node_dependencies -->|"decodes tokens"| node_security
node_db_sessions -->|"reads database URL"| node_config
node_security -->|"reads token settings"| node_config
node_db_sessions -->|"connects to"| node_postgres

click node_application "https://github.com/thrigunchandra/c2_rbac/blob/main/app/main.py"
click node_auth_routes "https://github.com/thrigunchandra/c2_rbac/blob/main/app/routes/auth.py"
click node_admin_routes "https://github.com/thrigunchandra/c2_rbac/blob/main/app/routes/admin.py"
click node_schemas "https://github.com/thrigunchandra/c2_rbac/blob/main/app/schemas.py"
click node_dependencies "https://github.com/thrigunchandra/c2_rbac/blob/main/app/dependencies.py"
click node_security "https://github.com/thrigunchandra/c2_rbac/blob/main/app/security.py"
click node_user_model "https://github.com/thrigunchandra/c2_rbac/blob/main/app/models.py"
click node_db_sessions "https://github.com/thrigunchandra/c2_rbac/blob/main/app/database.py"
click node_config "https://github.com/thrigunchandra/c2_rbac/blob/main/app/config.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_application,node_auth_routes,node_admin_routes,node_schemas,node_user toneBlue
class node_dependencies,node_security toneAmber
class node_user_model,node_db_sessions,node_postgres toneMint
class node_config toneRose
```

## Components

### API routing

- [FastAPI application](https://github.com/thrigunchandra/c2_rbac/blob/main/app/main.py): `app/main.py`
- [Auth endpoints](https://github.com/thrigunchandra/c2_rbac/blob/main/app/routes/auth.py): `app/routes/auth.py`
- [Admin endpoints](https://github.com/thrigunchandra/c2_rbac/blob/main/app/routes/admin.py): `app/routes/admin.py`
- [Request and response schemas](https://github.com/thrigunchandra/c2_rbac/blob/main/app/schemas.py): `app/schemas.py`

### Authentication and RBAC

- [Token and admin checks](https://github.com/thrigunchandra/c2_rbac/blob/main/app/dependencies.py): `app/dependencies.py`
- [Password and JWT helpers](https://github.com/thrigunchandra/c2_rbac/blob/main/app/security.py): `app/security.py`

### Persistence

- [User model](https://github.com/thrigunchandra/c2_rbac/blob/main/app/models.py): `app/models.py`
- [Engine and sessions](https://github.com/thrigunchandra/c2_rbac/blob/main/app/database.py): `app/database.py`
- **PostgreSQL**

### Configuration

- [Environment configuration](https://github.com/thrigunchandra/c2_rbac/blob/main/app/config.py): `app/config.py`

### Other components

- **API user**

## Connections

- API user → FastAPI application: sends requests (evidence: `README.md`)
- FastAPI application → Auth endpoints: registers router (evidence: `app/main.py`)
- FastAPI application → Admin endpoints: registers router (evidence: `app/main.py`)
- FastAPI application → Engine and sessions: creates tables via (evidence: `app/main.py`)
- FastAPI application → User model: creates tables from (evidence: `app/main.py`)
- Auth endpoints → Request and response schemas: uses request schemas (evidence: `app/routes/auth.py`)
- Auth endpoints → Engine and sessions: opens sessions (evidence: `app/routes/auth.py`)
- Auth endpoints → User model: queries and stores (evidence: `app/routes/auth.py`)
- Auth endpoints → Password and JWT helpers: hashes and issues tokens (evidence: `app/routes/auth.py`)
- Auth endpoints → Token and admin checks: uses access checks (evidence: `app/routes/auth.py`)
- Admin endpoints → Request and response schemas: uses admin schemas (evidence: `app/routes/admin.py`)
- Admin endpoints → Engine and sessions: gets database session (evidence: `app/routes/admin.py`)
- Admin endpoints → User model: queries and updates (evidence: `app/routes/admin.py`)
- Admin endpoints → Token and admin checks: requires admin (evidence: `app/routes/admin.py`)
- Token and admin checks → Password and JWT helpers: decodes tokens (evidence: `app/dependencies.py`)
- Engine and sessions → Environment configuration: reads database URL (evidence: `app/database.py`)
- Password and JWT helpers → Environment configuration: reads token settings (evidence: `app/security.py`)
- Engine and sessions → PostgreSQL: connects to (evidence: `README.md`)
