# patildarshan-13/climate-sustainability-intelligence-system architecture

> Architecture diagram of the GitHub repository patildarshan-13/climate-sustainability-intelligence-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/patildarshan-13/climate-sustainability-intelligence-system
- Repository: https://github.com/patildarshan-13/climate-sustainability-intelligence-system

## Overview

1. **Top-level architecture**
   - The repo is a two-tier application: a **React frontend** in `frontend/` and a **Python FastAPI backend** in `backend/`.
   - The backend is the orchestration layer for document ingestion, retrieval, and answer generation; the frontend is a thin interactive client.

2. **User-facing UI boundary**
   - The frontend is a single-page app built with **React**, **Tailwind CSS**, and a component library in `frontend/src/components/ui/`.
   - The main app surfaces three core UI paths: **file upload** (`FileUpload`), **document browsing** (`DocumentCard`), and **question answering** (`QueryInterface`).
   - It talks only to the backend over HTTP, with the backend URL injected via `REACT_APP_BACKEND_URL`.

3. **Backend API boundary**
   - `backend/server.py` is the entry point for the API service, intended to run with **Uvicorn/FastAPI**.
   - This layer likely exposes endpoints for upload, query, health, and document/listing operations; it is the only component the frontend depends on directly.
   - `backend/env.template` and the README show CORS and MongoDB configuration are externalized, so the API is environment-driven.

4. **Document ingestion pipeline**
   - Uploaded files are persisted under `backend/uploads/`, indicating the first stage is durable filesystem storage of raw documents.
   - `backend/document_processor.py` is responsible for parsing supported formats mentioned in the README: **PDF, TXT, and Markdown**.
   - This subsystem likely normalizes text, chunks content, and prepares metadata needed for later retrieval and source citations.

5. **Embedding and vector index layer**
   - `backend/vector_store.py` manages the semantic index, backed by **FAISS** on disk in `backend/data/faiss_index/`.
   - The persisted index consists of `index.faiss` plus `metadata.pkl`, so retrieval is split between vector search and a local metadata mapping.
   - This is the main low-latency search boundary: document chunks become embeddings, embeddings are stored in FAISS, and metadata preserves source references.

6. **RAG orchestration**
   - `backend/rag_engine.py` sits above the vector store and drives the retrieval-augmented generation workflow.
   - The README says the pipeline uses **SentenceTransformers + FAISS + a local Hugging Face LLM**, so query answering stays fully local with no external API dependency.
   - This layer retrieves the most relevant chunks, assembles context, and generates the final answer with document citations.

7. **Persistence model**
   - The system uses two persistence surfaces: **local filesystem** for uploaded files and FAISS artifacts, and **MongoDB** for application metadata/state as described in the README.
   - MongoDB is configured via `MONGO_URL` and `DB_NAME`; it is the durable backing store outside the vector index, likely for document records and operational metadata.
   - The FAISS store is not a database replacement; it is the semantic retrieval cache/index.

8. **Operational and development tooling**
   - Startup scripts exist for both Windows and Unix shells (`start-backend.*`, `start-frontend.*`, `run-project.ps1`) to launch the two services independently.
   - The frontend has custom CRACO plugins for **health checks** and **visual edits**, which affect local dev-server behavior but not core domain architecture.
   - Tests are split by layer: `backend_test.py` for API/backend behavior and the frontend test harness under `frontend/`.

9. **Deployment/runtime shape**
   - The runtime is designed for local development first: Python backend on port 8000 and React dev server on port 3000.
   - Because inference is local, the main scaling pressure is on the backend process, FAISS index size, and MongoDB/file storage—not on third-party AI services.
   - Any architecture diagram should show the backend as the hub connecting UI, uploaded files, vector index, and MongoDB.

10. **Key data flow to capture in a diagram**
   - **Upload path:** browser → FastAPI → filesystem upload → document parsing/chunking → embeddings → FAISS + metadata.
   - **Query path:** browser → FastAPI → FAISS similarity search → context assembly from stored metadata → local LLM generation → response with source references → browser.

Main entry points: [`backend/server.py`](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/server.py) (API server), [`frontend/src/App.js`](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/frontend/src/App.js) (App shell), [`backend/vector_store.py`](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/vector_store.py) (Vector store), [`backend/rag_engine.py`](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/rag_engine.py) (RAG engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_app["App shell<br/>React SPA<br/>[App.js]"]
  node_frontend_upload["File upload<br/>UI component<br/>[FileUpload.js]"]
  node_frontend_docs["Document browse<br/>UI component<br/>[DocumentCard.js]"]
  node_frontend_query["Ask question<br/>UI component<br/>[QueryInterface.js]"]
  node_frontend_ui["UI kit<br/>component library<br/>[button.jsx]"]
  node_frontend_config["Client config<br/>env config<br/>[env.template]"]
end

subgraph group_backend["Backend"]
  node_backend_server["API server<br/>FastAPI entrypoint<br/>[server.py]"]
  node_backend_ingest["Doc processor<br/>ingestion pipeline"]
  node_backend_rag["RAG engine<br/>orchestration layer<br/>[rag_engine.py]"]
  node_backend_vector["Vector store<br/>semantic index<br/>[vector_store.py]"]
  node_backend_config["Backend config<br/>env config<br/>[env.template]"]
end

subgraph group_storage["Storage"]
  node_uploads_store[("Raw uploads<br/>filesystem store")]
  node_faiss_index[("FAISS index<br/>on-disk index<br/>[index.faiss]")]
  node_faiss_meta["Index metadata<br/>metadata file<br/>[metadata.pkl]"]
  node_mongo_db[("MongoDB<br/>metadata store")]
end

subgraph group_tooling["Tooling"]
  node_run_scripts["Run scripts<br/>launch scripts<br/>[run-project.ps1]"]
  node_backend_tests["Backend tests<br/>test suite<br/>[backend_test.py]"]
  node_dev_plugins["Dev plugins<br/>dev tooling"]
end

node_frontend_app -->|"renders"| node_frontend_upload
node_frontend_app -->|"renders"| node_frontend_docs
node_frontend_app -->|"renders"| node_frontend_query
node_frontend_app -->|"uses"| node_frontend_ui
node_frontend_app -->|"calls API"| node_frontend_config
node_frontend_upload -->|"HTTP upload"| node_backend_server
node_frontend_docs -->|"HTTP list"| node_backend_server
node_frontend_query -->|"HTTP query"| node_backend_server
node_backend_server -->|"reads config"| node_backend_config
node_backend_server -->|"orchestrates"| node_backend_ingest
node_backend_server -->|"orchestrates"| node_backend_rag
node_backend_ingest -->|"stores raw files"| node_uploads_store
node_backend_ingest -->|"indexes chunks"| node_backend_vector
node_backend_vector -->|"persists"| node_faiss_index
node_backend_vector -->|"writes metadata"| node_faiss_meta
node_backend_vector -->|"records state"| node_mongo_db
node_backend_rag -->|"retrieves context"| node_backend_vector
node_backend_rag -->|"loads state"| node_mongo_db
node_backend_rag -->|"returns answers"| node_backend_server
node_run_scripts -->|"starts"| node_backend_server
node_run_scripts -->|"starts"| node_frontend_app
node_backend_tests -->|"validates"| node_backend_server
node_dev_plugins -->|"extends dev server"| node_frontend_app

click node_frontend_app "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/frontend/src/App.js"
click node_frontend_upload "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/frontend/src/components/FileUpload.js"
click node_frontend_docs "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/frontend/src/components/DocumentCard.js"
click node_frontend_query "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/frontend/src/components/QueryInterface.js"
click node_frontend_ui "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/frontend/src/components/ui/button.jsx"
click node_frontend_config "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/frontend/env.template"
click node_backend_server "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/server.py"
click node_backend_ingest "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/document_processor.py"
click node_backend_rag "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/rag_engine.py"
click node_backend_vector "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/vector_store.py"
click node_backend_config "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/env.template"
click node_uploads_store "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/uploads/14e0d0ff-6826-4064-b5e1-289d1ec3ff67.pdf"
click node_faiss_index "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/data/faiss_index/index.faiss"
click node_faiss_meta "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/data/faiss_index/metadata.pkl"
click node_run_scripts "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/run-project.ps1"
click node_backend_tests "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend_test.py"
click node_dev_plugins "https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/frontend/plugins/health-check/webpack-health-plugin.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_frontend_app,node_frontend_upload,node_frontend_docs,node_frontend_query,node_frontend_ui,node_frontend_config toneBlue
class node_backend_server,node_backend_ingest,node_backend_rag,node_backend_vector,node_backend_config toneAmber
class node_uploads_store,node_faiss_index,node_faiss_meta,node_mongo_db toneMint
class node_run_scripts,node_backend_tests,node_dev_plugins toneRose
```

## Components

### Frontend

React single-page app and UI components

- [App shell](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/frontend/src/App.js): React SPA · Top-level client composition for upload, browse, and query workflows · `frontend/src/App.js`
- [File upload](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/frontend/src/components/FileUpload.js): UI component · Upload surface for ingesting documents · `frontend/src/components/FileUpload.js`
- [Document browse](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/frontend/src/components/DocumentCard.js): UI component · Document listing and card-based browsing · `frontend/src/components/DocumentCard.js`
- [Ask question](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/frontend/src/components/QueryInterface.js): UI component · Interactive question-answering interface · `frontend/src/components/QueryInterface.js`
- [UI kit](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/frontend/src/components/ui/button.jsx): component library · Shared design-system primitives used by the app · `frontend/src/components/ui/button.jsx`
- [Client config](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/frontend/env.template): env config · Injects backend base URL for HTTP calls · `frontend/env.template`

### Backend

FastAPI service for ingestion and RAG

- [API server](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/server.py): FastAPI entrypoint · HTTP boundary for upload, query, health, and document operations · `backend/server.py`
- [Doc processor](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/document_processor.py): ingestion pipeline · Parses PDFs, TXT, and Markdown into normalized chunks · `backend/document_processor.py`
- [RAG engine](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/rag_engine.py): orchestration layer · Coordinates retrieval, context assembly, and answer generation · `backend/rag_engine.py`
- [Vector store](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/vector_store.py): semantic index · Manages embeddings and FAISS-backed retrieval · `backend/vector_store.py`
- [Backend config](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/env.template): env config · Runtime settings for CORS, MongoDB, and service behavior · `backend/env.template`

### Storage

Persistent files, vector index, and metadata surfaces

- [Raw uploads](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/uploads/14e0d0ff-6826-4064-b5e1-289d1ec3ff67.pdf): filesystem store · Durable storage for incoming documents · `backend/uploads/14e0d0ff-6826-4064-b5e1-289d1ec3ff67.pdf`
- [FAISS index](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/data/faiss_index/index.faiss): on-disk index · Persisted similarity index and metadata mapping · `backend/data/faiss_index/index.faiss`
- [Index metadata](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend/data/faiss_index/metadata.pkl): metadata file · Chunk and source-reference mapping for the vector index · `backend/data/faiss_index/metadata.pkl`
- **MongoDB**: metadata store · External application state and document metadata configured by environment

### Tooling

Startup scripts, tests, and development helpers

- [Run scripts](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/run-project.ps1): launch scripts · Cross-platform helpers for starting frontend and backend services · `run-project.ps1`
- [Backend tests](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/backend_test.py): test suite · Backend and API behavior checks · `backend_test.py`
- [Dev plugins](https://github.com/patildarshan-13/climate-sustainability-intelligence-system/blob/main/frontend/plugins/health-check/webpack-health-plugin.js): dev tooling · Health-check and visual-edit development server extensions · `frontend/plugins/health-check/webpack-health-plugin.js`

## Connections

- App shell → File upload: renders · Application shell includes upload workflow
- App shell → Document browse: renders · Application shell includes document browsing
- App shell → Ask question: renders · Application shell includes question answering
- App shell → UI kit: uses · Shared UI primitives support the main client views
- App shell → Client config: calls API · Backend base URL is injected from client environment
- File upload → API server: HTTP upload · Documents are sent to the API for ingestion
- Document browse → API server: HTTP list · Document browsing depends on backend endpoints
- Ask question → API server: HTTP query · Questions are posted to the API for retrieval and answer generation
- API server → Backend config: reads config · Server behavior is driven by environment settings
- API server → Doc processor: orchestrates · API routes delegate file processing to ingestion logic
- API server → RAG engine: orchestrates · API routes delegate question answering to the RAG layer
- Doc processor → Raw uploads: stores raw files · Incoming uploads are persisted before processing
- Doc processor → Vector store: indexes chunks · Parsed chunks are embedded and indexed
- Vector store → FAISS index: persists · Semantic index is stored on disk
- Vector store → Index metadata: writes metadata · Source references and chunk mappings are stored alongside the index
- Vector store → MongoDB: records state · Application metadata is kept outside the vector index
- RAG engine → Vector store: retrieves context · Query answering starts with similarity search over embeddings
- RAG engine → MongoDB: loads state · RAG flow can consult stored application metadata
- RAG engine → API server: returns answers · Generated responses flow back through the API layer
- Run scripts → API server: starts · Helper scripts launch the backend service
- Run scripts → App shell: starts · Helper scripts launch the frontend service
- Backend tests → API server: validates · Tests exercise API and backend behavior
- Dev plugins → App shell: extends dev server · Local development plugins alter client dev-server behavior
