# riyapatil04/ai-placement-mail-organizer architecture

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

- Interactive diagram: https://gitdiagram.com/riyapatil04/ai-placement-mail-organizer
- Repository: https://github.com/riyapatil04/ai-placement-mail-organizer

## Overview

AI Placement Mail Organizer fetches Gmail messages into a local SQLite-backed email list, which the React dashboard displays and can refresh on demand. The backend also exposes separate AI classification and placement-extraction test routes; the sampled sync path does not invoke them or persist analysis results. The README describes eligibility checks and Google Calendar syncing as product goals, but no implementation for either is shown, so they appear only as unverified planned branches. Edges reflect excerpts or README statements; unsampled behavior is not assumed.

Main entry points: [`backend/app/main.py`](https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/main.py) (FastAPI routes), [`backend/app/services/sync_service.py`](https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/services/sync_service.py) (Sync orchestrator), [`backend/app/models/email.py`](https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/models/email.py) (Email records), [`backend/app/database/db.py`](https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/database/db.py) (SQLite database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Dashboard"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_app_shell["App shell<br/>[App.jsx]"]
end

subgraph group_api["Backend API"]
  node_fastapi["FastAPI routes<br/>[main.py]"]
end

subgraph group_mail["Email ingestion"]
  node_sync["Sync orchestrator<br/>[sync_service.py]"]
  node_gmail_fetch["Gmail fetch<br/>[gmail_service.py]"]
  node_email_model["Email records<br/>[email.py]"]
  node_sqlite[("SQLite database<br/>[db.py]")]
end

subgraph group_analysis["Placement analysis"]
  node_analysis_model["Analysis records<br/>[email_analysis.py]"]
  node_ai_service["AI analysis<br/>[ai_service.py]"]
  node_prompts["Prompt templates"]
  node_eligibility["Eligibility checks"]
  node_calendar["Calendar sync"]
end

node_user(("User"))
node_gmail["Gmail"]
node_ollama["Ollama"]

node_user -->|"uses"| node_dashboard
node_app_shell -->|"renders"| node_dashboard
node_dashboard -->|"requests data"| node_api_client
node_api_client -->|"HTTP requests"| node_fastapi
node_fastapi -->|"dispatches sync"| node_sync
node_sync -->|"fetches messages"| node_gmail_fetch
node_gmail_fetch -->|"reads messages"| node_gmail
node_sync -->|"creates records"| node_email_model
node_sync -->|"commits records"| node_sqlite
node_fastapi -->|"queries emails"| node_email_model
node_fastapi -->|"creates tables"| node_sqlite
node_email_model -->|"defines mapping"| node_sqlite
node_analysis_model -->|"defines mapping"| node_sqlite
node_fastapi -->|"calls test routes"| node_ai_service
node_ai_service -->|"sends prompts"| node_ollama
node_ai_service -->|"loads templates"| node_prompts
node_email_model -->|"relates to"| node_analysis_model
node_user -.->|"expects checks"| node_eligibility
node_user -.->|"expects date sync"| node_calendar

click node_dashboard "https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/frontend/src/pages/Dashboard.jsx"
click node_api_client "https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/frontend/src/services/api.js"
click node_app_shell "https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/frontend/src/App.jsx"
click node_fastapi "https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/main.py"
click node_sync "https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/services/sync_service.py"
click node_gmail_fetch "https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/services/gmail_service.py"
click node_email_model "https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/models/email.py"
click node_analysis_model "https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/models/email_analysis.py"
click node_sqlite "https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/database/db.py"
click node_ai_service "https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/services/ai_service.py"
click node_prompts "https://github.com/riyapatil04/ai-placement-mail-organizer/tree/main/backend/app/prompts"
click node_eligibility "https://github.com/riyapatil04/ai-placement-mail-organizer/tree/main/backend/app/services"
click node_calendar "https://github.com/riyapatil04/ai-placement-mail-organizer/tree/main/backend/app/services"

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_dashboard,node_api_client,node_app_shell,node_user toneBlue
class node_fastapi toneAmber
class node_sync,node_gmail_fetch,node_email_model,node_sqlite toneMint
class node_analysis_model,node_ai_service,node_prompts,node_eligibility,node_calendar toneRose
class node_gmail,node_ollama toneIndigo
```

## Components

### Dashboard

- [Dashboard](https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [API client](https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [App shell](https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`

### Backend API

- [FastAPI routes](https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/main.py): `backend/app/main.py`

### Email ingestion

- [Sync orchestrator](https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/services/sync_service.py): `backend/app/services/sync_service.py`
- [Gmail fetch](https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/services/gmail_service.py): `backend/app/services/gmail_service.py`
- [Email records](https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/models/email.py): `backend/app/models/email.py`
- [SQLite database](https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/database/db.py): `backend/app/database/db.py`

### Placement analysis

- [Analysis records](https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/models/email_analysis.py): `backend/app/models/email_analysis.py`
- [AI analysis](https://github.com/riyapatil04/ai-placement-mail-organizer/blob/main/backend/app/services/ai_service.py): `backend/app/services/ai_service.py`
- [Prompt templates](https://github.com/riyapatil04/ai-placement-mail-organizer/tree/main/backend/app/prompts): `backend/app/prompts`
- [Eligibility checks](https://github.com/riyapatil04/ai-placement-mail-organizer/tree/main/backend/app/services): `backend/app/services`
- [Calendar sync](https://github.com/riyapatil04/ai-placement-mail-organizer/tree/main/backend/app/services): `backend/app/services`

### Other components

- **User**
- **Gmail**
- **Ollama**

## Connections

- User → Dashboard: uses (evidence: `frontend/src/pages/Dashboard.jsx`)
- App shell → Dashboard: renders (evidence: `frontend/src/App.jsx`)
- Dashboard → API client: requests data (evidence: `frontend/src/pages/Dashboard.jsx`)
- API client → FastAPI routes: HTTP requests (evidence: `frontend/src/services/api.js`)
- FastAPI routes → Sync orchestrator: dispatches sync (evidence: `backend/app/main.py`)
- Sync orchestrator → Gmail fetch: fetches messages (evidence: `backend/app/services/sync_service.py`)
- Gmail fetch → Gmail: reads messages (evidence: `backend/app/services/gmail_service.py`)
- Sync orchestrator → Email records: creates records (evidence: `backend/app/services/sync_service.py`)
- Sync orchestrator → SQLite database: commits records (evidence: `backend/app/services/sync_service.py`)
- FastAPI routes → Email records: queries emails (evidence: `backend/app/main.py`)
- FastAPI routes → SQLite database: creates tables (evidence: `backend/app/main.py`)
- Email records → SQLite database: defines mapping (evidence: `backend/app/models/email.py`)
- Analysis records → SQLite database: defines mapping (evidence: `backend/app/models/email_analysis.py`)
- FastAPI routes → AI analysis: calls test routes (evidence: `backend/app/main.py`)
- AI analysis → Ollama: sends prompts (evidence: `backend/app/services/ai_service.py`)
- AI analysis → Prompt templates: loads templates (evidence: `backend/app/services/ai_service.py`)
- Email records → Analysis records: relates to (evidence: `backend/app/models/email.py`)
- User → Eligibility checks: expects checks (evidence: `README.md`)
- User → Calendar sync: expects date sync (evidence: `README.md`)
