# lohith-07-coder/sentrimail architecture

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

- Interactive diagram: https://gitdiagram.com/lohith-07-coder/sentrimail
- Repository: https://github.com/lohith-07-coder/sentrimail

## Overview

SentriMail is a role-based complaint triage platform. Customers submit or track complaints, while admins review, respond to, and analyze cases. The principal workflow routes submissions through complaint lifecycle processing, AI analysis and prioritization, then persistence and either automatic response or human review. Authentication, transcription, escalation, analytics, and multilingual handling are distinct capabilities. The graph combines excerpted calls with README-documented relationships; some feature links are documented but their implementation was not sampled.

Main entry points: [`app/services/complaint_service.py`](https://github.com/lohith-07-coder/sentrimail/blob/main/app/services/complaint_service.py) (Complaint lifecycle), [`app/main.py`](https://github.com/lohith-07-coder/sentrimail/blob/main/app/main.py) (FastAPI application), [`app/routers/user.py`](https://github.com/lohith-07-coder/sentrimail/blob/main/app/routers/user.py) (Customer routes), [`app/routers/admin.py`](https://github.com/lohith-07-coder/sentrimail/blob/main/app/routers/admin.py) (Admin routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Web and API"]
  node_app["FastAPI application<br/>[main.py]"]
  node_user_routes["Customer routes<br/>[user.py]"]
  node_admin_routes["Admin routes<br/>[admin.py]"]
  node_auth_routes["Auth routes<br/>[auth.py]"]
  node_api_routes["Analysis API<br/>[api.py]"]
  node_views["Web templates"]
end

subgraph group_domain["Complaint workflow"]
  node_submission["Complaint lifecycle"]
  node_complaint_schema["Complaint requests<br/>[complaint.py]"]
  node_priority["Priority scoring<br/>[priority.py]"]
  node_analytics["Complaint analytics"]
end

subgraph group_identity["Identity and access"]
  node_auth["Authentication service<br/>[auth_service.py]"]
  node_security["Token security<br/>[security.py]"]
end

subgraph group_storage["Persistence"]
  node_complaint_repo["Complaint repository"]
  node_user_repo["User repository<br/>[user_repository.py]"]
  node_database["Database adapter<br/>[database.py]"]
  node_mongo[("MongoDB")]
  node_json_store[("JSON fallback")]
end

subgraph group_support["AI and operations"]
  node_ai["AI analysis<br/>[ai_service.py]"]
  node_transcription["Audio transcription"]
  node_email["Resolution email<br/>[email_service.py]"]
  node_scheduler["SLA escalation"]
  node_dataset["Dataset loading<br/>[loaders.py]"]
  node_dataset_schema["Dataset schema<br/>[schema.py]"]
end

node_customer(("Customer"))
node_admin(("Support admin"))

node_customer -->|"uses"| node_views
node_admin -->|"uses"| node_views
node_views -->|"submits"| node_user_routes
node_views -->|"authenticates"| node_auth_routes
node_views -->|"reviews"| node_admin_routes
node_app -->|"registers"| node_user_routes
node_app -->|"registers"| node_admin_routes
node_app -->|"registers"| node_auth_routes
node_app -->|"registers"| node_api_routes
node_user_routes -->|"processes"| node_submission
node_user_routes -->|"reads and writes"| node_complaint_repo
node_admin_routes -->|"reads and updates"| node_complaint_repo
node_admin_routes -->|"backfills analysis"| node_submission
node_submission -->|"analyzes"| node_ai
node_submission -->|"creates complaint"| node_complaint_repo
node_submission -->|"scores priority"| node_priority
node_submission -->|"sends resolution"| node_email
node_api_routes -->|"analyzes"| node_ai
node_api_routes -->|"transcribes"| node_transcription
node_api_routes -->|"validates"| node_complaint_schema
node_user_routes -->|"validates"| node_complaint_schema
node_auth_routes -->|"authenticates"| node_auth
node_auth_routes -->|"records login"| node_user_repo
node_auth -->|"manages users"| node_user_repo
node_auth -->|"verifies tokens"| node_security
node_complaint_repo -->|"accesses store"| node_database
node_user_repo -->|"accesses store"| node_database
node_app -->|"initializes"| node_database
node_database -->|"uses primary"| node_mongo
node_database -->|"falls back"| node_json_store
node_app -->|"schedules hourly"| node_scheduler
node_scheduler -->|"escalates cases"| node_complaint_repo
node_admin_routes -->|"shows metrics"| node_analytics
node_dataset -->|"uses schema"| node_dataset_schema
node_submission -.->|"accepts audio input"| node_transcription

click node_app "https://github.com/lohith-07-coder/sentrimail/blob/main/app/main.py"
click node_user_routes "https://github.com/lohith-07-coder/sentrimail/blob/main/app/routers/user.py"
click node_admin_routes "https://github.com/lohith-07-coder/sentrimail/blob/main/app/routers/admin.py"
click node_auth_routes "https://github.com/lohith-07-coder/sentrimail/blob/main/app/routers/auth.py"
click node_api_routes "https://github.com/lohith-07-coder/sentrimail/blob/main/app/routers/api.py"
click node_views "https://github.com/lohith-07-coder/sentrimail/tree/main/templates"
click node_submission "https://github.com/lohith-07-coder/sentrimail/blob/main/app/services/complaint_service.py"
click node_complaint_schema "https://github.com/lohith-07-coder/sentrimail/blob/main/app/schemas/complaint.py"
click node_priority "https://github.com/lohith-07-coder/sentrimail/blob/main/app/core/priority.py"
click node_complaint_repo "https://github.com/lohith-07-coder/sentrimail/blob/main/app/repositories/complaint_repository.py"
click node_user_repo "https://github.com/lohith-07-coder/sentrimail/blob/main/app/repositories/user_repository.py"
click node_database "https://github.com/lohith-07-coder/sentrimail/blob/main/app/core/database.py"
click node_json_store "https://github.com/lohith-07-coder/sentrimail/tree/main/data"
click node_ai "https://github.com/lohith-07-coder/sentrimail/blob/main/app/services/ai_service.py"
click node_transcription "https://github.com/lohith-07-coder/sentrimail/blob/main/app/services/transcription_service.py"
click node_email "https://github.com/lohith-07-coder/sentrimail/blob/main/app/services/email_service.py"
click node_auth "https://github.com/lohith-07-coder/sentrimail/blob/main/app/services/auth_service.py"
click node_security "https://github.com/lohith-07-coder/sentrimail/blob/main/app/core/security.py"
click node_scheduler "https://github.com/lohith-07-coder/sentrimail/blob/main/app/services/complaint_service.py"
click node_analytics "https://github.com/lohith-07-coder/sentrimail/blob/main/app/services/complaint_service.py"
click node_dataset "https://github.com/lohith-07-coder/sentrimail/blob/main/ml/dataset/loaders.py"
click node_dataset_schema "https://github.com/lohith-07-coder/sentrimail/blob/main/ml/dataset/schema.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_user_routes,node_admin_routes,node_auth_routes,node_api_routes,node_views toneBlue
class node_submission,node_complaint_schema,node_priority,node_analytics toneAmber
class node_auth,node_security toneMint
class node_complaint_repo,node_user_repo,node_database,node_mongo,node_json_store toneRose
class node_ai,node_transcription,node_email,node_scheduler,node_dataset,node_dataset_schema,node_customer,node_admin toneIndigo
```

## Components

### Web and API

- [FastAPI application](https://github.com/lohith-07-coder/sentrimail/blob/main/app/main.py): `app/main.py`
- [Customer routes](https://github.com/lohith-07-coder/sentrimail/blob/main/app/routers/user.py): `app/routers/user.py`
- [Admin routes](https://github.com/lohith-07-coder/sentrimail/blob/main/app/routers/admin.py): `app/routers/admin.py`
- [Auth routes](https://github.com/lohith-07-coder/sentrimail/blob/main/app/routers/auth.py): `app/routers/auth.py`
- [Analysis API](https://github.com/lohith-07-coder/sentrimail/blob/main/app/routers/api.py): `app/routers/api.py`
- [Web templates](https://github.com/lohith-07-coder/sentrimail/tree/main/templates): `templates`

### Complaint workflow

- [Complaint lifecycle](https://github.com/lohith-07-coder/sentrimail/blob/main/app/services/complaint_service.py): `app/services/complaint_service.py`
- [Complaint requests](https://github.com/lohith-07-coder/sentrimail/blob/main/app/schemas/complaint.py): `app/schemas/complaint.py`
- [Priority scoring](https://github.com/lohith-07-coder/sentrimail/blob/main/app/core/priority.py): `app/core/priority.py`
- [Complaint analytics](https://github.com/lohith-07-coder/sentrimail/blob/main/app/services/complaint_service.py): `app/services/complaint_service.py`

### Identity and access

- [Authentication service](https://github.com/lohith-07-coder/sentrimail/blob/main/app/services/auth_service.py): `app/services/auth_service.py`
- [Token security](https://github.com/lohith-07-coder/sentrimail/blob/main/app/core/security.py): `app/core/security.py`

### Persistence

- [Complaint repository](https://github.com/lohith-07-coder/sentrimail/blob/main/app/repositories/complaint_repository.py): `app/repositories/complaint_repository.py`
- [User repository](https://github.com/lohith-07-coder/sentrimail/blob/main/app/repositories/user_repository.py): `app/repositories/user_repository.py`
- [Database adapter](https://github.com/lohith-07-coder/sentrimail/blob/main/app/core/database.py): `app/core/database.py`
- **MongoDB**
- [JSON fallback](https://github.com/lohith-07-coder/sentrimail/tree/main/data): `data`

### AI and operations

- [AI analysis](https://github.com/lohith-07-coder/sentrimail/blob/main/app/services/ai_service.py): `app/services/ai_service.py`
- [Audio transcription](https://github.com/lohith-07-coder/sentrimail/blob/main/app/services/transcription_service.py): `app/services/transcription_service.py`
- [Resolution email](https://github.com/lohith-07-coder/sentrimail/blob/main/app/services/email_service.py): `app/services/email_service.py`
- [SLA escalation](https://github.com/lohith-07-coder/sentrimail/blob/main/app/services/complaint_service.py): `app/services/complaint_service.py`
- [Dataset loading](https://github.com/lohith-07-coder/sentrimail/blob/main/ml/dataset/loaders.py): `ml/dataset/loaders.py`
- [Dataset schema](https://github.com/lohith-07-coder/sentrimail/blob/main/ml/dataset/schema.py): `ml/dataset/schema.py`

### Other components

- **Customer**
- **Support admin**

## Connections

- Customer → Web templates: uses (evidence: `README.md`)
- Support admin → Web templates: uses (evidence: `README.md`)
- Web templates → Customer routes: submits (evidence: `README.md`)
- Web templates → Auth routes: authenticates (evidence: `README.md`)
- Web templates → Admin routes: reviews (evidence: `README.md`)
- FastAPI application → Customer routes: registers (evidence: `app/main.py`)
- FastAPI application → Admin routes: registers (evidence: `app/main.py`)
- FastAPI application → Auth routes: registers (evidence: `app/main.py`)
- FastAPI application → Analysis API: registers (evidence: `app/main.py`)
- Customer routes → Complaint lifecycle: processes (evidence: `README.md`)
- Customer routes → Complaint repository: reads and writes (evidence: `app/routers/user.py`)
- Admin routes → Complaint repository: reads and updates (evidence: `app/routers/admin.py`)
- Admin routes → Complaint lifecycle: backfills analysis (evidence: `app/routers/admin.py`)
- Complaint lifecycle → AI analysis: analyzes (evidence: `app/services/complaint_service.py`)
- Complaint lifecycle → Complaint repository: creates complaint (evidence: `app/services/complaint_service.py`)
- Complaint lifecycle → Priority scoring: scores priority
- Complaint lifecycle → Resolution email: sends resolution (evidence: `README.md`)
- Analysis API → AI analysis: analyzes (evidence: `app/routers/api.py`)
- Analysis API → Audio transcription: transcribes (evidence: `app/routers/api.py`)
- Analysis API → Complaint requests: validates (evidence: `app/routers/api.py`)
- Customer routes → Complaint requests: validates (evidence: `app/routers/user.py`)
- Auth routes → Authentication service: authenticates (evidence: `app/routers/auth.py`)
- Auth routes → User repository: records login (evidence: `app/routers/auth.py`)
- Authentication service → User repository: manages users (evidence: `app/services/auth_service.py`)
- Authentication service → Token security: verifies tokens (evidence: `app/services/auth_service.py`)
- Complaint repository → Database adapter: accesses store (evidence: `app/repositories/complaint_repository.py`)
- User repository → Database adapter: accesses store (evidence: `app/repositories/user_repository.py`)
- FastAPI application → Database adapter: initializes (evidence: `app/main.py`)
- Database adapter → MongoDB: uses primary (evidence: `README.md`)
- Database adapter → JSON fallback: falls back (evidence: `README.md`)
- FastAPI application → SLA escalation: schedules hourly (evidence: `app/main.py`)
- SLA escalation → Complaint repository: escalates cases (evidence: `README.md`)
- Admin routes → Complaint analytics: shows metrics (evidence: `README.md`)
- Dataset loading → Dataset schema: uses schema (evidence: `ml/dataset/loaders.py`)
- Complaint lifecycle → Audio transcription: accepts audio input
