# aravindg-atwork/admission-poc architecture

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

- Interactive diagram: https://gitdiagram.com/aravindg-atwork/admission-poc
- Repository: https://github.com/aravindg-atwork/admission-poc

## Overview

#### Purpose and entry points
MAFSU Admission Assistant is a multilingual, prospectus-grounded RAG system for three isolated undergraduate programmes. The active implementation is a pure-standard-library Python backend, designed for locked-down Windows hosts; ML capabilities are remote HTTP services. Start via `run_backend.py`; HTTP composition is in `backend/http/app.py`, with student chat and operator/admin routes in `backend/http/chat_routes.py` and `backend/http/admin_routes.py`.

#### HTTP UI and access boundary
The backend serves static student and admin interfaces from `backend/static/` and dispatches API requests through route modules. Admin functions cover operations, prompts, reviews, costs, and API-key management. Consumer credentials and revocation are handled by `backend/storage/apikeys.py`; per-project isolation is represented by `backend/storage/projects.py`.

#### Project-isolated knowledge boundary
Each programme has separate prospectus-derived data, embeddings/vector store, FAQ cache, stats, and keys under `data/projects/`. This is the principal anti-cross-contamination boundary. Persistent JSON-oriented storage is implemented in `backend/storage/vectorstore.py`, `backend/storage/faq.py`, and `backend/storage/stats.py`; exact cosine search is appropriate for the small corpus.

#### Ingestion and retrieval preparation
Prospectus PDFs are converted through OCR and structured into markdown/table-preserving content, then chunked, embedded, topic/section annotated, and persisted. The ingestion pipeline is centered on `backend/rag/ingest.py`, with document extraction in `backend/ocr.py` and `backend/pdf.py`. Embedding calls are abstracted in `backend/generation/embeddings.py` and target the standalone `services/embedding-service/app.py`.

#### Answer orchestration pipeline
A question flows through intent/language/programme logic, ordered guards, FAQ lookup, hybrid retrieval, generation, and deterministic validation. The coordinator is `backend/rag/orchestrator.py`; routing and guard policy live in `backend/rag/router.py` and `backend/rag/guards.py`. Retrieval and grounded answer assembly are in `backend/rag/answer.py` and `backend/rag/citation.py`. Guards intentionally precede cache lookup so clarification or safety/policy responses cannot be bypassed.

#### Generation, multilingual behavior, and external providers
Core deterministic domain logic—including intent, eligibility, programme selection, language, and table lookup—is in `backend/core/intent.py`, `backend/core/eligibility.py`, and `backend/core/tablelookup.py`. Prompt policy is maintained in `backend/prompts/system.py` and `backend/prompts/registry.py`. LLM/provider HTTP adapters are in `backend/generation/llm.py` and `backend/generation/providers.py`; speech is remote via `backend/generation/speech.py`, with an optional Indic TTS service at `services/indic-tts-service/app.py`.

#### Observability and adjacent integrations
Every answer can carry a trace ID; live trace streaming uses Server-Sent Events via `backend/trace/hub.py`, `backend/trace/events.py`, and `backend/http/trace_routes.py`. OCR is independently deployable at `services/ocr-service/app.py`. The repository also retains a .NET solution—core RAG abstractions in `src/AdmissionAssistant.Core/` and ASP.NET Web API UI in `src/AdmissionAssistant.Web/`—but the README identifies Python as the current deployment path. A Chrome extension integration sends order-assist interactions through `extension/orderassist-assistant/background.js` and `extension/orderassist-assistant/content.js`, backed by `backend/orderassist/routes.py`.

Main entry points: [`backend/rag/orchestrator.py`](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/rag/orchestrator.py) (Answer orchestrator), [`backend/http/app.py`](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/http/app.py) (HTTP app), [`backend/rag/ingest.py`](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/rag/ingest.py) (Prospectus ingestion), [`backend/http/admin_routes.py`](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/http/admin_routes.py) (Admin routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["Python HTTP backend"]
  node_entry["Backend entry point<br/>Python launcher<br/>[run_backend.py]"]
  node_app["HTTP app<br/>HTTP composition<br/>[app.py]"]
  node_chat["Student chat routes<br/>API routes<br/>[chat_routes.py]"]
  node_admin["Admin routes<br/>Operations API<br/>[admin_routes.py]"]
  node_trace_routes["Trace SSE routes<br/>SSE API<br/>[trace_routes.py]"]
  node_trace["Trace hub<br/>Live trace stream<br/>[hub.py]"]
end

subgraph group_rag["RAG pipeline"]
  node_orchestrator["Answer orchestrator<br/>RAG coordinator<br/>[orchestrator.py]"]
  node_routing["Intent and guard policy<br/>Routing policy<br/>[router.py]"]
  node_guards["Safety and clarification guards<br/>Guard policy<br/>[guards.py]"]
  node_answer["Hybrid retrieval and answers<br/>Grounded answer assembly<br/>[answer.py]"]
  node_citation["Citation validation<br/>Grounding validator<br/>[citation.py]"]
  node_ingest["Prospectus ingestion<br/>Ingestion pipeline<br/>[ingest.py]"]
  node_extraction["PDF and OCR extraction<br/>Document extraction<br/>[ocr.py]"]
  node_core["Deterministic domain logic<br/>Intent, eligibility, tables<br/>[intent.py]"]
  node_generation["LLM and embedding adapters<br/>Provider HTTP adapters<br/>[llm.py]"]
end

subgraph group_storage["Project-isolated storage"]
  node_projects[("Project isolation<br/>Project registry<br/>[projects.py]")]
  node_knowledge[("Programme knowledge stores<br/>JSON vector, FAQ, stats")]
  node_apikeys[("Consumer API keys<br/>Credential store<br/>[apikeys.py]")]
end

subgraph group_remote["Remote ML services"]
  node_embedding_service{{"Embedding service<br/>Remote ML service<br/>[app.py]"}}
  node_ocr_service{{"OCR service<br/>[app.py]"}}
end

subgraph group_adjacent["Adjacent integrations"]
  node_orderassist["Order-assist integration<br/>Extension API<br/>[routes.py]"]
  node_extension["Chrome extension<br/>Browser integration<br/>[background.js]"]
  node_legacy["Legacy .NET solution<br/>Retained implementation"]
end

node_entry -->|"starts"| node_app
node_app -->|"dispatches chat"| node_chat
node_app -->|"dispatches admin"| node_admin
node_app -->|"dispatches SSE"| node_trace_routes
node_chat -->|"questions"| node_orchestrator
node_admin -->|"manages projects"| node_projects
node_admin -->|"manages keys"| node_apikeys
node_orchestrator -->|"routes"| node_routing
node_routing -->|"applies first"| node_guards
node_orchestrator -->|"retrieves after guards"| node_answer
node_orchestrator -->|"validates output"| node_citation
node_orchestrator -->|"uses domain decisions"| node_core
node_answer -->|"searches/cache lookup"| node_knowledge
node_answer -->|"generates grounded response"| node_generation
node_generation -->|"embeddings"| node_embedding_service
node_ingest -->|"extracts PDFs"| node_extraction
node_ingest -->|"embeds chunks"| node_embedding_service
node_ingest -->|"persists by project"| node_knowledge
node_projects -->|"scopes stores"| node_knowledge
node_trace_routes -->|"streams events"| node_trace
node_orchestrator -->|"emits trace"| node_trace
node_extension -->|"order-assist requests"| node_orderassist
node_orderassist -->|"uses answer flow"| node_orchestrator
node_extraction -.->|"optional remote OCR"| node_ocr_service

click node_entry "https://github.com/aravindg-atwork/admission-poc/blob/main/run_backend.py"
click node_app "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/http/app.py"
click node_chat "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/http/chat_routes.py"
click node_admin "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/http/admin_routes.py"
click node_trace_routes "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/http/trace_routes.py"
click node_orchestrator "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/rag/orchestrator.py"
click node_routing "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/rag/router.py"
click node_guards "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/rag/guards.py"
click node_answer "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/rag/answer.py"
click node_citation "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/rag/citation.py"
click node_ingest "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/rag/ingest.py"
click node_extraction "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/ocr.py"
click node_core "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/core/intent.py"
click node_generation "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/generation/llm.py"
click node_projects "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/storage/projects.py"
click node_apikeys "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/storage/apikeys.py"
click node_embedding_service "https://github.com/aravindg-atwork/admission-poc/blob/main/services/embedding-service/app.py"
click node_ocr_service "https://github.com/aravindg-atwork/admission-poc/blob/main/services/ocr-service/app.py"
click node_trace "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/trace/hub.py"
click node_orderassist "https://github.com/aravindg-atwork/admission-poc/blob/main/backend/orderassist/routes.py"
click node_extension "https://github.com/aravindg-atwork/admission-poc/blob/main/extension/orderassist-assistant/background.js"

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_entry,node_app,node_chat,node_admin,node_trace_routes,node_trace toneBlue
class node_orchestrator,node_routing,node_guards,node_answer,node_citation,node_ingest,node_extraction,node_core,node_generation toneAmber
class node_projects,node_knowledge,node_apikeys toneMint
class node_embedding_service,node_ocr_service toneRose
class node_orderassist,node_extension,node_legacy toneIndigo
```

## Components

### Python HTTP backend

- [Backend entry point](https://github.com/aravindg-atwork/admission-poc/blob/main/run_backend.py): Python launcher · `run_backend.py`
- [HTTP app](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/http/app.py): HTTP composition · Serves static UIs and dispatches routes. · `backend/http/app.py`
- [Student chat routes](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/http/chat_routes.py): API routes · `backend/http/chat_routes.py`
- [Admin routes](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/http/admin_routes.py): Operations API · `backend/http/admin_routes.py`
- [Trace SSE routes](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/http/trace_routes.py): SSE API · `backend/http/trace_routes.py`
- [Trace hub](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/trace/hub.py): Live trace stream · `backend/trace/hub.py`

### RAG pipeline

- [Answer orchestrator](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/rag/orchestrator.py): RAG coordinator · Runs ordered guards, cache, retrieval, generation, and validation. · `backend/rag/orchestrator.py`
- [Intent and guard policy](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/rag/router.py): Routing policy · Guards run before FAQ lookup. · `backend/rag/router.py`
- [Safety and clarification guards](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/rag/guards.py): Guard policy · `backend/rag/guards.py`
- [Hybrid retrieval and answers](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/rag/answer.py): Grounded answer assembly · `backend/rag/answer.py`
- [Citation validation](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/rag/citation.py): Grounding validator · `backend/rag/citation.py`
- [Prospectus ingestion](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/rag/ingest.py): Ingestion pipeline · Chunks, annotates, embeds, and persists prospectus content. · `backend/rag/ingest.py`
- [PDF and OCR extraction](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/ocr.py): Document extraction · `backend/ocr.py`
- [Deterministic domain logic](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/core/intent.py): Intent, eligibility, tables · `backend/core/intent.py`
- [LLM and embedding adapters](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/generation/llm.py): Provider HTTP adapters · `backend/generation/llm.py`

### Project-isolated storage

- [Project isolation](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/storage/projects.py): Project registry · Separates the three undergraduate programmes. · `backend/storage/projects.py`
- **Programme knowledge stores**: JSON vector, FAQ, stats · Per-project embeddings, prospectus data, FAQ cache, and statistics.
- [Consumer API keys](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/storage/apikeys.py): Credential store · Manages credentials and revocation. · `backend/storage/apikeys.py`

### Remote ML services

- [Embedding service](https://github.com/aravindg-atwork/admission-poc/blob/main/services/embedding-service/app.py): Remote ML service · `services/embedding-service/app.py`
- [OCR service](https://github.com/aravindg-atwork/admission-poc/blob/main/services/ocr-service/app.py): Remote OCR service · `services/ocr-service/app.py`

### Adjacent integrations

- [Order-assist integration](https://github.com/aravindg-atwork/admission-poc/blob/main/backend/orderassist/routes.py): Extension API · `backend/orderassist/routes.py`
- [Chrome extension](https://github.com/aravindg-atwork/admission-poc/blob/main/extension/orderassist-assistant/background.js): Browser integration · `extension/orderassist-assistant/background.js`
- **Legacy .NET solution**: Retained implementation · Not the current deployment path.

## Connections

- Backend entry point → HTTP app: starts
- HTTP app → Student chat routes: dispatches chat
- HTTP app → Admin routes: dispatches admin
- HTTP app → Trace SSE routes: dispatches SSE
- Student chat routes → Answer orchestrator: questions
- Admin routes → Project isolation: manages projects
- Admin routes → Consumer API keys: manages keys
- Answer orchestrator → Intent and guard policy: routes
- Intent and guard policy → Safety and clarification guards: applies first
- Answer orchestrator → Hybrid retrieval and answers: retrieves after guards
- Answer orchestrator → Citation validation: validates output
- Answer orchestrator → Deterministic domain logic: uses domain decisions
- Hybrid retrieval and answers → Programme knowledge stores: searches/cache lookup
- Hybrid retrieval and answers → LLM and embedding adapters: generates grounded response
- LLM and embedding adapters → Embedding service: embeddings
- Prospectus ingestion → PDF and OCR extraction: extracts PDFs
- Prospectus ingestion → Embedding service: embeds chunks
- Prospectus ingestion → Programme knowledge stores: persists by project
- Project isolation → Programme knowledge stores: scopes stores
- Trace SSE routes → Trace hub: streams events
- Answer orchestrator → Trace hub: emits trace
- Chrome extension → Order-assist integration: order-assist requests
- Order-assist integration → Answer orchestrator: uses answer flow
- PDF and OCR extraction → OCR service: optional remote OCR
