# shah-kavya-03/eclipse architecture

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

- Interactive diagram: https://gitdiagram.com/shah-kavya-03/eclipse
- Repository: https://github.com/shah-kavya-03/eclipse

## Overview

Eclipse is a real-time LLM guardrail and governance product, with a V1 FastAPI service and a V2 migration split between an Express gateway, Python ML service, and React clients. The principal V2 path is chat submission through the gateway to Python guardrail evaluation and provider orchestration, with persisted conversations and audit telemetry. Admin and user-management capabilities are retained as separate branches. Some subsystem links rely on README documentation; unsampled implementation details are not inferred.

Main entry points: [`admin_frontend/src/App.jsx`](https://github.com/shah-kavya-03/eclipse/blob/main/admin_frontend/src/App.jsx) (Admin console), [`backend/routers/internal.py`](https://github.com/shah-kavya-03/eclipse/blob/main/backend/routers/internal.py) (Internal ML endpoints), [`backend/database/connection.py`](https://github.com/shah-kavya-03/eclipse/blob/main/backend/database/connection.py) (MongoDB), [`server/server.js`](https://github.com/shah-kavya-03/eclipse/blob/main/server/server.js) (Express API gateway)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User and admin clients"]
  node_chatui["Chat interface<br/>[App.jsx]"]
  node_chatstate["Chat and auth state<br/>[ChatContext.jsx]"]
  node_adminui["Admin console<br/>[App.jsx]"]
  node_adminapi["Admin API client<br/>[client.js]"]
  node_v1audit["V1 audit dashboard<br/>[audit.js]"]
end

subgraph group_gateway["V2 API gateway"]
  node_gatewayapp["Express API gateway<br/>[server.js]"]
  node_chatroutes["Chat routes<br/>[chatRoutes.js]"]
  node_chatcontroller["Chat orchestration<br/>[chatController.js]"]
  node_gatewayauth["Auth and access control<br/>[authMiddleware.js]"]
  node_mlclient["Python service client<br/>[pythonMlClient.js]"]
end

subgraph group_guardrail["Python guardrail service"]
  node_pythonapp["FastAPI service<br/>[main.py]"]
  node_internal["Internal ML endpoints<br/>[internal.py]"]
  node_threat["Threat evaluation"]
  node_pii["PII and content checks<br/>[pii_detector.py]"]
  node_injection["Injection detection"]
  node_explain["Blocked-prompt explanation<br/>[lime_explainer.py]"]
  node_llmrouter["Provider rotation<br/>[api_router.py]"]
end

subgraph group_governance["Security and governance"]
  node_analytics["Anomalies and reports"]
  node_adminctrl["Admin and telemetry<br/>[adminController.js]"]
  node_logsctrl["Logs and dashboard stats<br/>[logsController.js]"]
  node_convctrl["Conversation management"]
  node_settingsctrl["User settings"]
end

subgraph group_state["Persistence and providers"]
  node_mongodb[("MongoDB<br/>[connection.py]")]
end

node_user(("Chat user"))
node_adminuser(("Administrator"))
node_providers{{"LLM providers"}}

node_user -->|"uses"| node_chatui
node_chatui -->|"delegates to"| node_chatstate
node_chatstate -.->|"sends chat requests"| node_gatewayapp
node_adminuser -->|"uses"| node_adminui
node_adminui -->|"uses"| node_adminapi
node_adminapi -->|"calls Node API"| node_gatewayapp
node_adminapi -->|"calls Python API"| node_pythonapp
node_gatewayapp -->|"mounts routes"| node_chatroutes
node_chatroutes -->|"dispatches"| node_chatcontroller
node_chatcontroller -->|"submits prompt"| node_mlclient
node_mlclient -->|"calls internal API"| node_internal
node_pythonapp -->|"registers router"| node_internal
node_internal -->|"evaluates threats"| node_threat
node_internal -->|"explains blocks"| node_explain
node_internal -->|"requests generation"| node_llmrouter
node_internal -->|"records and analyzes"| node_analytics
node_threat -.->|"uses PII checks"| node_pii
node_threat -.->|"uses injection checks"| node_injection
node_llmrouter -->|"fails over across"| node_providers
node_adminui -.->|"requests admin data"| node_adminctrl
node_adminui -.->|"requests telemetry"| node_logsctrl
node_adminui -.->|"manages conversations"| node_convctrl
node_adminui -.->|"manages settings"| node_settingsctrl
node_gatewayapp -.->|"protects routes"| node_gatewayauth
node_convctrl -.->|"reads and writes"| node_mongodb
node_adminctrl -.->|"reads and writes"| node_mongodb
node_logsctrl -->|"reads telemetry"| node_mongodb
node_logsctrl -->|"fetches anomalies and reports"| node_mlclient
node_settingsctrl -.->|"reads and writes"| node_mongodb
node_pythonapp -->|"connects at startup"| node_mongodb
node_v1audit -->|"shows audit telemetry"| node_adminuser

click node_chatui "https://github.com/shah-kavya-03/eclipse/blob/main/frontend/src/App.jsx"
click node_chatstate "https://github.com/shah-kavya-03/eclipse/blob/main/frontend/src/context/ChatContext.jsx"
click node_adminui "https://github.com/shah-kavya-03/eclipse/blob/main/admin_frontend/src/App.jsx"
click node_adminapi "https://github.com/shah-kavya-03/eclipse/blob/main/admin_frontend/src/api/client.js"
click node_gatewayapp "https://github.com/shah-kavya-03/eclipse/blob/main/server/server.js"
click node_chatroutes "https://github.com/shah-kavya-03/eclipse/blob/main/server/routes/chatRoutes.js"
click node_chatcontroller "https://github.com/shah-kavya-03/eclipse/blob/main/server/controllers/chatController.js"
click node_gatewayauth "https://github.com/shah-kavya-03/eclipse/blob/main/server/middleware/authMiddleware.js"
click node_mlclient "https://github.com/shah-kavya-03/eclipse/blob/main/server/services/pythonMlClient.js"
click node_pythonapp "https://github.com/shah-kavya-03/eclipse/blob/main/backend/main.py"
click node_internal "https://github.com/shah-kavya-03/eclipse/blob/main/backend/routers/internal.py"
click node_threat "https://github.com/shah-kavya-03/eclipse/blob/main/backend/security/threat_classifier.py"
click node_pii "https://github.com/shah-kavya-03/eclipse/blob/main/backend/security/pii_detector.py"
click node_injection "https://github.com/shah-kavya-03/eclipse/blob/main/backend/security/injection_detector.py"
click node_explain "https://github.com/shah-kavya-03/eclipse/blob/main/backend/security/lime_explainer.py"
click node_llmrouter "https://github.com/shah-kavya-03/eclipse/blob/main/backend/llm/api_router.py"
click node_analytics "https://github.com/shah-kavya-03/eclipse/blob/main/backend/ml/anomaly_detector.py"
click node_adminctrl "https://github.com/shah-kavya-03/eclipse/blob/main/server/controllers/adminController.js"
click node_logsctrl "https://github.com/shah-kavya-03/eclipse/blob/main/server/controllers/logsController.js"
click node_convctrl "https://github.com/shah-kavya-03/eclipse/blob/main/server/controllers/conversationController.js"
click node_settingsctrl "https://github.com/shah-kavya-03/eclipse/blob/main/server/controllers/settingsController.js"
click node_mongodb "https://github.com/shah-kavya-03/eclipse/blob/main/backend/database/connection.py"
click node_v1audit "https://github.com/shah-kavya-03/eclipse/blob/main/frontend/js/audit.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_chatui,node_chatstate,node_adminui,node_adminapi,node_v1audit,node_user toneBlue
class node_gatewayapp,node_chatroutes,node_chatcontroller,node_gatewayauth,node_mlclient toneAmber
class node_pythonapp,node_internal,node_threat,node_pii,node_injection,node_explain,node_llmrouter toneMint
class node_analytics,node_adminctrl,node_logsctrl,node_convctrl,node_settingsctrl toneRose
class node_mongodb,node_adminuser,node_providers toneIndigo
```

## Components

### User and admin clients

- [Chat interface](https://github.com/shah-kavya-03/eclipse/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Chat and auth state](https://github.com/shah-kavya-03/eclipse/blob/main/frontend/src/context/ChatContext.jsx): `frontend/src/context/ChatContext.jsx`
- [Admin console](https://github.com/shah-kavya-03/eclipse/blob/main/admin_frontend/src/App.jsx): `admin_frontend/src/App.jsx`
- [Admin API client](https://github.com/shah-kavya-03/eclipse/blob/main/admin_frontend/src/api/client.js): `admin_frontend/src/api/client.js`
- [V1 audit dashboard](https://github.com/shah-kavya-03/eclipse/blob/main/frontend/js/audit.js): `frontend/js/audit.js`

### V2 API gateway

- [Express API gateway](https://github.com/shah-kavya-03/eclipse/blob/main/server/server.js): `server/server.js`
- [Chat routes](https://github.com/shah-kavya-03/eclipse/blob/main/server/routes/chatRoutes.js): `server/routes/chatRoutes.js`
- [Chat orchestration](https://github.com/shah-kavya-03/eclipse/blob/main/server/controllers/chatController.js): `server/controllers/chatController.js`
- [Auth and access control](https://github.com/shah-kavya-03/eclipse/blob/main/server/middleware/authMiddleware.js): `server/middleware/authMiddleware.js`
- [Python service client](https://github.com/shah-kavya-03/eclipse/blob/main/server/services/pythonMlClient.js): `server/services/pythonMlClient.js`

### Python guardrail service

- [FastAPI service](https://github.com/shah-kavya-03/eclipse/blob/main/backend/main.py): `backend/main.py`
- [Internal ML endpoints](https://github.com/shah-kavya-03/eclipse/blob/main/backend/routers/internal.py): `backend/routers/internal.py`
- [Threat evaluation](https://github.com/shah-kavya-03/eclipse/blob/main/backend/security/threat_classifier.py): `backend/security/threat_classifier.py`
- [PII and content checks](https://github.com/shah-kavya-03/eclipse/blob/main/backend/security/pii_detector.py): `backend/security/pii_detector.py`
- [Injection detection](https://github.com/shah-kavya-03/eclipse/blob/main/backend/security/injection_detector.py): `backend/security/injection_detector.py`
- [Blocked-prompt explanation](https://github.com/shah-kavya-03/eclipse/blob/main/backend/security/lime_explainer.py): `backend/security/lime_explainer.py`
- [Provider rotation](https://github.com/shah-kavya-03/eclipse/blob/main/backend/llm/api_router.py): `backend/llm/api_router.py`

### Security and governance

- [Anomalies and reports](https://github.com/shah-kavya-03/eclipse/blob/main/backend/ml/anomaly_detector.py): `backend/ml/anomaly_detector.py`
- [Admin and telemetry](https://github.com/shah-kavya-03/eclipse/blob/main/server/controllers/adminController.js): `server/controllers/adminController.js`
- [Logs and dashboard stats](https://github.com/shah-kavya-03/eclipse/blob/main/server/controllers/logsController.js): `server/controllers/logsController.js`
- [Conversation management](https://github.com/shah-kavya-03/eclipse/blob/main/server/controllers/conversationController.js): `server/controllers/conversationController.js`
- [User settings](https://github.com/shah-kavya-03/eclipse/blob/main/server/controllers/settingsController.js): `server/controllers/settingsController.js`

### Persistence and providers

- [MongoDB](https://github.com/shah-kavya-03/eclipse/blob/main/backend/database/connection.py): `backend/database/connection.py`

### Other components

- **Chat user**
- **Administrator**
- **LLM providers**

## Connections

- Chat user → Chat interface: uses
- Chat interface → Chat and auth state: delegates to (evidence: `frontend/src/App.jsx`)
- Chat and auth state → Express API gateway: sends chat requests
- Administrator → Admin console: uses (evidence: `admin_frontend/src/App.jsx`)
- Admin console → Admin API client: uses (evidence: `admin_frontend/src/App.jsx`)
- Admin API client → Express API gateway: calls Node API (evidence: `admin_frontend/src/api/client.js`)
- Admin API client → FastAPI service: calls Python API (evidence: `admin_frontend/src/api/client.js`)
- Express API gateway → Chat routes: mounts routes (evidence: `server/server.js`)
- Chat routes → Chat orchestration: dispatches
- Chat orchestration → Python service client: submits prompt (evidence: `server/services/pythonMlClient.js`)
- Python service client → Internal ML endpoints: calls internal API (evidence: `server/services/pythonMlClient.js`)
- FastAPI service → Internal ML endpoints: registers router (evidence: `backend/main.py`)
- Internal ML endpoints → Threat evaluation: evaluates threats (evidence: `backend/routers/internal.py`)
- Internal ML endpoints → Blocked-prompt explanation: explains blocks (evidence: `backend/routers/internal.py`)
- Internal ML endpoints → Provider rotation: requests generation (evidence: `backend/routers/internal.py`)
- Internal ML endpoints → Anomalies and reports: records and analyzes (evidence: `backend/routers/internal.py`)
- Threat evaluation → PII and content checks: uses PII checks
- Threat evaluation → Injection detection: uses injection checks
- Provider rotation → LLM providers: fails over across (evidence: `backend/llm/api_router.py`)
- Admin console → Admin and telemetry: requests admin data
- Admin console → Logs and dashboard stats: requests telemetry
- Admin console → Conversation management: manages conversations
- Admin console → User settings: manages settings
- Express API gateway → Auth and access control: protects routes
- Conversation management → MongoDB: reads and writes
- Admin and telemetry → MongoDB: reads and writes
- Logs and dashboard stats → MongoDB: reads telemetry (evidence: `server/controllers/logsController.js`)
- Logs and dashboard stats → Python service client: fetches anomalies and reports (evidence: `server/controllers/logsController.js`)
- User settings → MongoDB: reads and writes
- FastAPI service → MongoDB: connects at startup (evidence: `backend/main.py`)
- V1 audit dashboard → Administrator: shows audit telemetry
