# neiljovianus/ramiel architecture

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

- Interactive diagram: https://gitdiagram.com/neiljovianus/ramiel
- Repository: https://github.com/neiljovianus/ramiel

## Overview

RAMIEL AI is a web-based company-support chatbot with account, session, and administration workflows. A signed-in user sends a message (optionally with files); the chat route checks access and tokens, persists conversation state, runs the AI tool loop, and stores the answer. The README is empty, so capabilities are inferred from the source index and excerpts; several substantial routes are indexed but not sampled, so their internal interactions are omitted.

Main entry points: [`backend/database.py`](https://github.com/neiljovianus/ramiel/blob/main/backend/database.py) (Application database), [`backend/main.py`](https://github.com/neiljovianus/ramiel/blob/main/backend/main.py) (API application), [`backend/routers/auth.py`](https://github.com/neiljovianus/ramiel/blob/main/backend/routers/auth.py) (Authentication and profile), [`backend/routers/chat.py`](https://github.com/neiljovianus/ramiel/blob/main/backend/routers/chat.py) (Chat endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_frontend["Chat and account UI<br/>[script.js]"]
  node_static["Frontend delivery<br/>[static.py]"]
end

subgraph group_identity["Identity and administration"]
  node_auth["Authentication and profile<br/>[auth.py]"]
  node_admin["Admin operations<br/>[admin.py]"]
  node_dev["Developer operations<br/>[dev.py]"]
  node_access["Access checks<br/>[dependencies.py]"]
  node_security["Security utilities<br/>[security.py]"]
  node_email["Email and OTP service<br/>[email_service.py]"]
end

subgraph group_conversation["Conversation and AI"]
  node_sessions["Chat sessions<br/>[sessions.py]"]
  node_chat["Chat endpoint<br/>[chat.py]"]
  node_ai_flow["AI tool loop<br/>[pipeline.py]"]
  node_ai_client["Gemini client<br/>[client.py]"]
  node_tools["Data and document tools<br/>[tools.py]"]
end

subgraph group_platform["Shared platform"]
  node_app["API application<br/>[main.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
  node_db[("Application database<br/>[database.py]")]
  node_config["Runtime configuration<br/>[config.py]"]
end

node_user(("User"))
node_gemini{{"Google Gemini"}}
node_mysql[("MySQL")]
node_smtp{{"SMTP service"}}

node_user -->|"uses"| node_frontend
node_frontend -.->|"requests API"| node_app
node_app -->|"mounts"| node_static
node_app -->|"registers"| node_chat
node_app -->|"registers"| node_auth
node_app -->|"registers"| node_sessions
node_app -->|"registers"| node_admin
node_app -->|"registers"| node_dev
node_app -->|"loads paths"| node_config
node_chat -->|"validates"| node_schemas
node_auth -->|"validates"| node_schemas
node_sessions -->|"validates"| node_schemas
node_admin -->|"checks access"| node_access
node_dev -->|"checks access"| node_access
node_auth -->|"checks access"| node_access
node_auth -->|"uses"| node_security
node_auth -->|"issues OTP"| node_email
node_access -->|"checks users"| node_db
node_auth -->|"reads and writes"| node_db
node_sessions -.->|"reads and writes"| node_db
node_admin -->|"queries"| node_db
node_dev -->|"queries"| node_db
node_chat -->|"stores messages"| node_db
node_chat -->|"generates title"| node_ai_client
node_chat -->|"processes message"| node_ai_flow
node_ai_flow -->|"sends prompts"| node_ai_client
node_ai_flow -->|"dispatches tools"| node_tools
node_ai_client -->|"calls API"| node_gemini
node_tools -->|"queries tables"| node_db
node_db -->|"connects"| node_mysql
node_email -->|"manages challenges"| node_db
node_email -->|"sends mail"| node_smtp
node_access -->|"uses auth settings"| node_config
node_db -->|"uses DB settings"| node_config
node_ai_client -->|"uses AI settings"| node_config
node_tools -.->|"uses file settings"| node_config

click node_frontend "https://github.com/neiljovianus/ramiel/blob/main/frontend/script.js"
click node_static "https://github.com/neiljovianus/ramiel/blob/main/backend/routers/static.py"
click node_app "https://github.com/neiljovianus/ramiel/blob/main/backend/main.py"
click node_auth "https://github.com/neiljovianus/ramiel/blob/main/backend/routers/auth.py"
click node_sessions "https://github.com/neiljovianus/ramiel/blob/main/backend/routers/sessions.py"
click node_admin "https://github.com/neiljovianus/ramiel/blob/main/backend/routers/admin.py"
click node_dev "https://github.com/neiljovianus/ramiel/blob/main/backend/routers/dev.py"
click node_chat "https://github.com/neiljovianus/ramiel/blob/main/backend/routers/chat.py"
click node_schemas "https://github.com/neiljovianus/ramiel/blob/main/backend/schemas.py"
click node_access "https://github.com/neiljovianus/ramiel/blob/main/backend/dependencies.py"
click node_security "https://github.com/neiljovianus/ramiel/blob/main/backend/security.py"
click node_email "https://github.com/neiljovianus/ramiel/blob/main/backend/email_service.py"
click node_ai_flow "https://github.com/neiljovianus/ramiel/blob/main/backend/ai/pipeline.py"
click node_ai_client "https://github.com/neiljovianus/ramiel/blob/main/backend/ai/client.py"
click node_tools "https://github.com/neiljovianus/ramiel/blob/main/backend/ai/tools.py"
click node_db "https://github.com/neiljovianus/ramiel/blob/main/backend/database.py"
click node_config "https://github.com/neiljovianus/ramiel/blob/main/backend/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_frontend,node_static,node_user toneBlue
class node_auth,node_admin,node_dev,node_access,node_security,node_email,node_mysql toneAmber
class node_sessions,node_chat,node_ai_flow,node_ai_client,node_tools toneMint
class node_app,node_schemas,node_db,node_config toneRose
class node_gemini,node_smtp toneIndigo
```

## Components

### Web experience

- [Chat and account UI](https://github.com/neiljovianus/ramiel/blob/main/frontend/script.js): `frontend/script.js`
- [Frontend delivery](https://github.com/neiljovianus/ramiel/blob/main/backend/routers/static.py): `backend/routers/static.py`

### Identity and administration

- [Authentication and profile](https://github.com/neiljovianus/ramiel/blob/main/backend/routers/auth.py): `backend/routers/auth.py`
- [Admin operations](https://github.com/neiljovianus/ramiel/blob/main/backend/routers/admin.py): `backend/routers/admin.py`
- [Developer operations](https://github.com/neiljovianus/ramiel/blob/main/backend/routers/dev.py): `backend/routers/dev.py`
- [Access checks](https://github.com/neiljovianus/ramiel/blob/main/backend/dependencies.py): `backend/dependencies.py`
- [Security utilities](https://github.com/neiljovianus/ramiel/blob/main/backend/security.py): `backend/security.py`
- [Email and OTP service](https://github.com/neiljovianus/ramiel/blob/main/backend/email_service.py): `backend/email_service.py`

### Conversation and AI

- [Chat sessions](https://github.com/neiljovianus/ramiel/blob/main/backend/routers/sessions.py): `backend/routers/sessions.py`
- [Chat endpoint](https://github.com/neiljovianus/ramiel/blob/main/backend/routers/chat.py): `backend/routers/chat.py`
- [AI tool loop](https://github.com/neiljovianus/ramiel/blob/main/backend/ai/pipeline.py): `backend/ai/pipeline.py`
- [Gemini client](https://github.com/neiljovianus/ramiel/blob/main/backend/ai/client.py): `backend/ai/client.py`
- [Data and document tools](https://github.com/neiljovianus/ramiel/blob/main/backend/ai/tools.py): `backend/ai/tools.py`

### Shared platform

- [API application](https://github.com/neiljovianus/ramiel/blob/main/backend/main.py): `backend/main.py`
- [Request schemas](https://github.com/neiljovianus/ramiel/blob/main/backend/schemas.py): `backend/schemas.py`
- [Application database](https://github.com/neiljovianus/ramiel/blob/main/backend/database.py): `backend/database.py`
- [Runtime configuration](https://github.com/neiljovianus/ramiel/blob/main/backend/config.py): `backend/config.py`

### Other components

- **User**
- **Google Gemini**
- **MySQL**
- **SMTP service**

## Connections

- User → Chat and account UI: uses (evidence: `frontend/script.js`)
- Chat and account UI → API application: requests API
- API application → Frontend delivery: mounts (evidence: `backend/main.py`)
- API application → Chat endpoint: registers (evidence: `backend/main.py`)
- API application → Authentication and profile: registers (evidence: `backend/main.py`)
- API application → Chat sessions: registers (evidence: `backend/main.py`)
- API application → Admin operations: registers (evidence: `backend/main.py`)
- API application → Developer operations: registers (evidence: `backend/main.py`)
- API application → Runtime configuration: loads paths (evidence: `backend/main.py`)
- Chat endpoint → Request schemas: validates (evidence: `backend/routers/chat.py`)
- Authentication and profile → Request schemas: validates (evidence: `backend/routers/auth.py`)
- Chat sessions → Request schemas: validates (evidence: `backend/routers/sessions.py`)
- Admin operations → Access checks: checks access (evidence: `backend/routers/admin.py`)
- Developer operations → Access checks: checks access (evidence: `backend/routers/dev.py`)
- Authentication and profile → Access checks: checks access (evidence: `backend/routers/auth.py`)
- Authentication and profile → Security utilities: uses (evidence: `backend/routers/auth.py`)
- Authentication and profile → Email and OTP service: issues OTP (evidence: `backend/routers/auth.py`)
- Access checks → Application database: checks users (evidence: `backend/dependencies.py`)
- Authentication and profile → Application database: reads and writes (evidence: `backend/routers/auth.py`)
- Chat sessions → Application database: reads and writes (evidence: `backend/routers/sessions.py`)
- Admin operations → Application database: queries (evidence: `backend/routers/admin.py`)
- Developer operations → Application database: queries (evidence: `backend/routers/dev.py`)
- Chat endpoint → Application database: stores messages (evidence: `backend/routers/chat.py`)
- Chat endpoint → Gemini client: generates title (evidence: `backend/routers/chat.py`)
- Chat endpoint → AI tool loop: processes message (evidence: `backend/routers/chat.py`)
- AI tool loop → Gemini client: sends prompts (evidence: `backend/ai/pipeline.py`)
- AI tool loop → Data and document tools: dispatches tools (evidence: `backend/ai/pipeline.py`)
- Gemini client → Google Gemini: calls API (evidence: `backend/ai/client.py`)
- Data and document tools → Application database: queries tables (evidence: `backend/ai/tools.py`)
- Application database → MySQL: connects (evidence: `backend/database.py`)
- Email and OTP service → Application database: manages challenges (evidence: `backend/email_service.py`)
- Email and OTP service → SMTP service: sends mail (evidence: `backend/email_service.py`)
- Access checks → Runtime configuration: uses auth settings (evidence: `backend/dependencies.py`)
- Application database → Runtime configuration: uses DB settings (evidence: `backend/database.py`)
- Gemini client → Runtime configuration: uses AI settings (evidence: `backend/ai/client.py`)
- Data and document tools → Runtime configuration: uses file settings (evidence: `backend/ai/tools.py`)
