# shlokgit-04/samajh architecture

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

- Interactive diagram: https://gitdiagram.com/shlokgit-04/samajh
- Repository: https://github.com/shlokgit-04/samajh

## Overview

Samajh is an Indian paperwork assistant: users can get plain-language document readings, verified form and scheme guidance, application tracking, profile-based recommendations, and nearby office listings. The main AI workflow runs from document upload or a chat question through the document/chat routes to prompts, tools, and Gemma; signed-in users can also save encrypted scans. Other routes serve accounts, tracker data, recommendations, centres, and printable PDFs. The README documents capabilities whose route implementations were not sampled; their internal connections are shown only where evidenced.

Main entry points: [`app/routes_docs.py`](https://github.com/shlokgit-04/samajh/blob/master/app/routes_docs.py) (Read and ask), [`app/routes_reco.py`](https://github.com/shlokgit-04/samajh/blob/master/app/routes_reco.py) (Scheme recommendations), [`app/store.py`](https://github.com/shlokgit-04/samajh/blob/master/app/store.py) (User record store), [`app/routes_pdf.py`](https://github.com/shlokgit-04/samajh/blob/master/app/routes_pdf.py) (Printable checklists)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User workflows"]
  node_web["Web experience<br/>[app.js]"]
end

subgraph group_guidance["Guidance and AI"]
  node_doc_chat["Read and ask<br/>[routes_docs.py]"]
  node_prompts["AI instructions<br/>[prompts.py]"]
  node_model["Gemma client<br/>[gemini_client.py]"]
  node_schemas["Validated readings<br/>[schemas.py]"]
  node_tools["Knowledge tools<br/>[tools.py]"]
  node_forms_data["Form knowledge<br/>[forms.json]"]
  node_schemes_data["Scheme knowledge<br/>[schemes.json]"]
end

subgraph group_accounts["Accounts and records"]
  node_auth["Accounts and rights<br/>[routes_auth.py]"]
  node_security["Sessions and encryption<br/>[security.py]"]
  node_scans["Encrypted scan vault<br/>[routes_scans.py]"]
  node_tracker["Application tracker<br/>[routes_tracker.py]"]
  node_store[("User record store<br/>[store.py]")]
end

subgraph group_services["Directories and PDFs"]
  node_reco["Scheme recommendations<br/>[routes_reco.py]"]
  node_centres_data["Office directory<br/>[centres.json]"]
  node_pdf_routes["Printable checklists<br/>[routes_pdf.py]"]
  node_pdf_render["PDF renderer<br/>[pdf.py]"]
  node_forms_db[("Optional Supabase forms")]
end

node_person(("Paperwork user"))

node_person -->|"uses"| node_web
node_person -->|"uploads or asks"| node_doc_chat
node_doc_chat -->|"uses prompts"| node_prompts
node_doc_chat -->|"requests analysis"| node_model
node_doc_chat -->|"runs chat tools"| node_tools
node_doc_chat -->|"validates results"| node_schemas
node_person -->|"registers or signs in"| node_auth
node_auth -->|"creates sessions"| node_security
node_auth -->|"reads and updates"| node_store
node_doc_chat -->|"saves scans"| node_store
node_doc_chat -->|"encrypts scans"| node_security
node_scans -->|"reads and writes"| node_store
node_scans -->|"encrypts and decrypts"| node_security
node_tracker -->|"persists applications"| node_store
node_reco -->|"filters centres"| node_tools
node_reco -->|"searches directory"| node_centres_data
node_reco -->|"serves forms"| node_forms_data
node_reco -->|"serves schemes"| node_schemes_data
node_pdf_routes -->|"builds PDFs"| node_pdf_render
node_pdf_routes -->|"reads form details"| node_forms_data
node_pdf_routes -->|"reads scheme details"| node_schemes_data
node_forms_db -.->|"optional forms backend"| node_forms_data

click node_web "https://github.com/shlokgit-04/samajh/blob/master/static/app.js"
click node_doc_chat "https://github.com/shlokgit-04/samajh/blob/master/app/routes_docs.py"
click node_prompts "https://github.com/shlokgit-04/samajh/blob/master/app/prompts.py"
click node_model "https://github.com/shlokgit-04/samajh/blob/master/app/gemini_client.py"
click node_schemas "https://github.com/shlokgit-04/samajh/blob/master/app/schemas.py"
click node_tools "https://github.com/shlokgit-04/samajh/blob/master/app/tools.py"
click node_forms_data "https://github.com/shlokgit-04/samajh/blob/master/data/forms.json"
click node_schemes_data "https://github.com/shlokgit-04/samajh/blob/master/data/schemes.json"
click node_auth "https://github.com/shlokgit-04/samajh/blob/master/app/routes_auth.py"
click node_security "https://github.com/shlokgit-04/samajh/blob/master/app/security.py"
click node_scans "https://github.com/shlokgit-04/samajh/blob/master/app/routes_scans.py"
click node_tracker "https://github.com/shlokgit-04/samajh/blob/master/app/routes_tracker.py"
click node_store "https://github.com/shlokgit-04/samajh/blob/master/app/store.py"
click node_reco "https://github.com/shlokgit-04/samajh/blob/master/app/routes_reco.py"
click node_centres_data "https://github.com/shlokgit-04/samajh/blob/master/data/centres.json"
click node_pdf_routes "https://github.com/shlokgit-04/samajh/blob/master/app/routes_pdf.py"
click node_pdf_render "https://github.com/shlokgit-04/samajh/blob/master/app/pdf.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_web,node_person toneBlue
class node_doc_chat,node_prompts,node_model,node_schemas,node_tools,node_forms_data,node_schemes_data toneAmber
class node_auth,node_security,node_scans,node_tracker,node_store toneMint
class node_reco,node_centres_data,node_pdf_routes,node_pdf_render,node_forms_db toneRose
```

## Components

### User workflows

- [Web experience](https://github.com/shlokgit-04/samajh/blob/master/static/app.js): `static/app.js`

### Guidance and AI

- [Read and ask](https://github.com/shlokgit-04/samajh/blob/master/app/routes_docs.py): `app/routes_docs.py`
- [AI instructions](https://github.com/shlokgit-04/samajh/blob/master/app/prompts.py): `app/prompts.py`
- [Gemma client](https://github.com/shlokgit-04/samajh/blob/master/app/gemini_client.py): `app/gemini_client.py`
- [Validated readings](https://github.com/shlokgit-04/samajh/blob/master/app/schemas.py): `app/schemas.py`
- [Knowledge tools](https://github.com/shlokgit-04/samajh/blob/master/app/tools.py): `app/tools.py`
- [Form knowledge](https://github.com/shlokgit-04/samajh/blob/master/data/forms.json): `data/forms.json`
- [Scheme knowledge](https://github.com/shlokgit-04/samajh/blob/master/data/schemes.json): `data/schemes.json`

### Accounts and records

- [Accounts and rights](https://github.com/shlokgit-04/samajh/blob/master/app/routes_auth.py): `app/routes_auth.py`
- [Sessions and encryption](https://github.com/shlokgit-04/samajh/blob/master/app/security.py): `app/security.py`
- [Encrypted scan vault](https://github.com/shlokgit-04/samajh/blob/master/app/routes_scans.py): `app/routes_scans.py`
- [Application tracker](https://github.com/shlokgit-04/samajh/blob/master/app/routes_tracker.py): `app/routes_tracker.py`
- [User record store](https://github.com/shlokgit-04/samajh/blob/master/app/store.py): `app/store.py`

### Directories and PDFs

- [Scheme recommendations](https://github.com/shlokgit-04/samajh/blob/master/app/routes_reco.py): `app/routes_reco.py`
- [Office directory](https://github.com/shlokgit-04/samajh/blob/master/data/centres.json): `data/centres.json`
- [Printable checklists](https://github.com/shlokgit-04/samajh/blob/master/app/routes_pdf.py): `app/routes_pdf.py`
- [PDF renderer](https://github.com/shlokgit-04/samajh/blob/master/app/pdf.py): `app/pdf.py`
- **Optional Supabase forms**

### Other components

- **Paperwork user**

## Connections

- Paperwork user → Web experience: uses (evidence: `README.md`)
- Paperwork user → Read and ask: uploads or asks (evidence: `README.md`)
- Read and ask → AI instructions: uses prompts (evidence: `app/routes_docs.py`)
- Read and ask → Gemma client: requests analysis (evidence: `app/routes_docs.py`)
- Read and ask → Knowledge tools: runs chat tools (evidence: `app/routes_docs.py`)
- Read and ask → Validated readings: validates results (evidence: `README.md`)
- Paperwork user → Accounts and rights: registers or signs in (evidence: `README.md`)
- Accounts and rights → Sessions and encryption: creates sessions (evidence: `app/routes_auth.py`)
- Accounts and rights → User record store: reads and updates (evidence: `app/routes_auth.py`)
- Read and ask → User record store: saves scans (evidence: `app/routes_docs.py`)
- Read and ask → Sessions and encryption: encrypts scans (evidence: `app/routes_docs.py`)
- Encrypted scan vault → User record store: reads and writes (evidence: `app/routes_scans.py`)
- Encrypted scan vault → Sessions and encryption: encrypts and decrypts (evidence: `app/routes_scans.py`)
- Application tracker → User record store: persists applications (evidence: `README.md`)
- Scheme recommendations → Knowledge tools: filters centres (evidence: `app/routes_reco.py`)
- Scheme recommendations → Office directory: searches directory (evidence: `README.md`)
- Scheme recommendations → Form knowledge: serves forms (evidence: `README.md`)
- Scheme recommendations → Scheme knowledge: serves schemes (evidence: `README.md`)
- Printable checklists → PDF renderer: builds PDFs (evidence: `app/routes_pdf.py`)
- Printable checklists → Form knowledge: reads form details (evidence: `app/routes_pdf.py`)
- Printable checklists → Scheme knowledge: reads scheme details (evidence: `README.md`)
- Optional Supabase forms → Form knowledge: optional forms backend (evidence: `README.md`)
