# dikshabhange30/api_sentinel architecture

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

## Overview

API Sentinel is a FastAPI service for user authentication and per-user API request monitoring. Clients register or log in, then submit request records and retrieve filtered history, analytics, and security alerts through authenticated endpoints. The main route module implements these distinct stages, using password hashing, JWT-based current-user resolution, Pydantic contracts, and SQLAlchemy persistence. The README is empty; edges reflect only relationships visible in the sampled source, including the database module’s documented PostgreSQL session flow.

Main entry points: [`app/database.py`](https://github.com/dikshabhange30/api_sentinel/blob/main/app/database.py) (Database sessions), [`app/oauth2.py`](https://github.com/dikshabhange30/api_sentinel/blob/main/app/oauth2.py) (JWT authentication), [`app/main.py`](https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py) (Login), [`app/auth.py`](https://github.com/dikshabhange30/api_sentinel/blob/main/app/auth.py) (Password hashing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_routes["API workflows"]
  node_app["FastAPI application<br/>[main.py]"]
  node_accounts["Account registration<br/>[main.py]"]
  node_login["Login<br/>[main.py]"]
  node_profile["Current-user lookup<br/>[main.py]"]
  node_ingest["Request ingestion<br/>[main.py]"]
  node_history["Request history<br/>[main.py]"]
  node_analytics["Request analytics<br/>[main.py]"]
  node_security["Security alerts<br/>[main.py]"]
end

subgraph group_identity["Identity and access"]
  node_passwords["Password hashing<br/>[auth.py]"]
  node_tokens["JWT authentication<br/>[oauth2.py]"]
end

subgraph group_storage["Persistence"]
  node_sessions["Database sessions<br/>[database.py]"]
  node_models["User and request models<br/>[models.py]"]
  node_database[("Relational database")]
end

subgraph group_contracts["Data contracts"]
  node_schemas["Request and response schemas<br/>[schemas.py]"]
end

node_client(("API client"))

node_client -->|"sends API requests"| node_app
node_accounts -->|"hashes password"| node_passwords
node_login -->|"verifies password"| node_passwords
node_login -->|"creates token"| node_tokens
node_profile -->|"resolves user"| node_tokens
node_ingest -->|"requires user"| node_tokens
node_history -->|"requires user"| node_tokens
node_analytics -->|"requires user"| node_tokens
node_security -->|"requires user"| node_tokens
node_app -->|"uses contracts"| node_schemas
node_accounts -->|"queries and saves"| node_sessions
node_login -->|"queries user"| node_sessions
node_ingest -->|"saves request"| node_sessions
node_history -->|"queries requests"| node_sessions
node_analytics -->|"aggregates requests"| node_sessions
node_security -->|"checks requests"| node_sessions
node_tokens -->|"loads user"| node_sessions
node_sessions -->|"connects to"| node_database
node_sessions -->|"provides ORM base"| node_models

click node_app "https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py"
click node_accounts "https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py"
click node_login "https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py"
click node_profile "https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py"
click node_ingest "https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py"
click node_history "https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py"
click node_analytics "https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py"
click node_security "https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py"
click node_passwords "https://github.com/dikshabhange30/api_sentinel/blob/main/app/auth.py"
click node_tokens "https://github.com/dikshabhange30/api_sentinel/blob/main/app/oauth2.py"
click node_schemas "https://github.com/dikshabhange30/api_sentinel/blob/main/app/schemas.py"
click node_sessions "https://github.com/dikshabhange30/api_sentinel/blob/main/app/database.py"
click node_models "https://github.com/dikshabhange30/api_sentinel/blob/main/app/models.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_accounts,node_login,node_profile,node_ingest,node_history,node_analytics,node_security,node_client toneBlue
class node_passwords,node_tokens toneAmber
class node_sessions,node_models,node_database toneMint
class node_schemas toneRose
```

## Components

### API workflows

- [FastAPI application](https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py): `app/main.py`
- [Account registration](https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py): `app/main.py`
- [Login](https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py): `app/main.py`
- [Current-user lookup](https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py): `app/main.py`
- [Request ingestion](https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py): `app/main.py`
- [Request history](https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py): `app/main.py`
- [Request analytics](https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py): `app/main.py`
- [Security alerts](https://github.com/dikshabhange30/api_sentinel/blob/main/app/main.py): `app/main.py`

### Identity and access

- [Password hashing](https://github.com/dikshabhange30/api_sentinel/blob/main/app/auth.py): `app/auth.py`
- [JWT authentication](https://github.com/dikshabhange30/api_sentinel/blob/main/app/oauth2.py): `app/oauth2.py`

### Persistence

- [Database sessions](https://github.com/dikshabhange30/api_sentinel/blob/main/app/database.py): `app/database.py`
- [User and request models](https://github.com/dikshabhange30/api_sentinel/blob/main/app/models.py): `app/models.py`
- **Relational database**

### Data contracts

- [Request and response schemas](https://github.com/dikshabhange30/api_sentinel/blob/main/app/schemas.py): `app/schemas.py`

### Other components

- **API client**

## Connections

- API client → FastAPI application: sends API requests (evidence: `app/main.py`)
- Account registration → Password hashing: hashes password (evidence: `app/main.py`)
- Login → Password hashing: verifies password (evidence: `app/main.py`)
- Login → JWT authentication: creates token (evidence: `app/main.py`)
- Current-user lookup → JWT authentication: resolves user (evidence: `app/main.py`)
- Request ingestion → JWT authentication: requires user (evidence: `app/main.py`)
- Request history → JWT authentication: requires user (evidence: `app/main.py`)
- Request analytics → JWT authentication: requires user (evidence: `app/main.py`)
- Security alerts → JWT authentication: requires user (evidence: `app/main.py`)
- FastAPI application → Request and response schemas: uses contracts (evidence: `app/main.py`)
- Account registration → Database sessions: queries and saves (evidence: `app/main.py`)
- Login → Database sessions: queries user (evidence: `app/main.py`)
- Request ingestion → Database sessions: saves request (evidence: `app/main.py`)
- Request history → Database sessions: queries requests (evidence: `app/main.py`)
- Request analytics → Database sessions: aggregates requests (evidence: `app/main.py`)
- Security alerts → Database sessions: checks requests (evidence: `app/main.py`)
- JWT authentication → Database sessions: loads user (evidence: `app/oauth2.py`)
- Database sessions → Relational database: connects to (evidence: `app/database.py`)
- Database sessions → User and request models: provides ORM base (evidence: `app/models.py`)
