# paraggarg969/et-ai-prob-8 architecture

> Architecture diagram of the GitHub repository paraggarg969/et-ai-prob-8, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/paraggarg969/et-ai-prob-8
- Repository: https://github.com/paraggarg969/et-ai-prob-8

## Overview

#### Purpose and Entry Points
GuardianRCA Hub is an industrial-safety knowledge system: it ingests plant documents, creates searchable semantic context, supports graph-oriented equipment/relationship data, and provides AI-assisted operations, root-cause analysis (RCA), and compliance responses. The unified server/frontend entry point is `server.ts`; the React client mounts at `src/main.tsx` and its primary application shell is `src/App.tsx`.

#### Client Application Boundary
The Vite/React client presents the dashboard, knowledge graph, copilot, RCA, and compliance-oriented workflows. It uses a dedicated API adapter rather than accessing persistence or AI providers directly:
- `src/App.tsx`
- `src/services/api.ts`
- `src/types.ts`

This keeps UI state and rendering separate from the Express MVC backend.

#### HTTP API and Controller Layer
Express route delegation is centralized in `server/routes/api.ts`. Controllers expose the main domain operations: agent conversations/RCA, document ingestion, source data access, and search. This is the primary boundary for client requests and server-side orchestration:
- `server/routes/api.ts`
- `server/controllers/agentController.ts`
- `server/controllers/documentController.ts`

Other domain endpoints include `server/controllers/dataController.ts` and `server/controllers/searchController.ts`.

#### Knowledge Ingestion and Semantic Retrieval
Document ingestion routes content through extraction/orchestration and then into retrieval-oriented services. Gemini supplies AI interpretation; vector/chroma services provide semantic indexing and lookup. Persisted local Chroma artifacts indicate the vector store can be backed by repository-local Chroma data:
- `server/controllers/documentController.ts`
- `server/services/geminiService.ts`
- `server/services/vectorStore.ts`

Related vector infrastructure is implemented in `server/services/chromaService.ts`, with stored data under `server/chroma_data/chroma.sqlite3`.

#### Multi-Agent Copilot, RCA, and Compliance
The agent controller is the high-level AI workflow coordinator. It selects or prompts specialized operational, root-cause, and regulatory reasoning modes, combining retrieved knowledge with Gemini generation to return cited/synthesized safety guidance, failure analyses, and compliance findings:
- `server/controllers/agentController.ts`
- `server/services/geminiService.ts`
- `server/types/index.ts`

Longer-running work can be decoupled through `server/services/jobQueue.ts`, an important control boundary for ingestion or AI-heavy tasks.

#### Persistence and Domain Model
Database access is centralized through the model layer and database configuration, rather than embedded in controllers. The intended relational schema covers documents, graph entities/links, RCA cases, and compliance records; seed support exists for initializing data:
- `server/config/database.ts`
- `server/models/dbModel.ts`
- `server/database/schema.sql`

The README identifies Neon PostgreSQL via `DATABASE_URL`; the database configuration is therefore the external persistence integration boundary.

#### Runtime and External Services
The application runs TypeScript on Node.js with Express coordinating the backend and Vite serving/building the React client. Material external dependencies are Google Gemini (`GEMINI_API_KEY`) for multimodal/LLM work, PostgreSQL/Neon for authoritative relational data, and Chroma/vector storage for RAG retrieval. Container-oriented server deployment is represented by:
- `package.json`
- `server.ts`
- `server/compose.yaml`

Main entry points: [`server/routes/api.ts`](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/routes/api.ts) (API Routes), [`server/controllers/agentController.ts`](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/controllers/agentController.ts) (Agent Controller), [`server/controllers/documentController.ts`](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/controllers/documentController.ts) (Document Controller), [`server/models/dbModel.ts`](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/models/dbModel.ts) (Database Model Layer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React Client"]
  node_client_app["Application Shell<br/>React UI<br/>[App.tsx]"]
  node_client_main["Client Mount<br/>React bootstrap<br/>[main.tsx]"]
  node_api_adapter["API Adapter<br/>client service<br/>[api.ts]"]
  node_client_types["Client Types<br/>TypeScript contracts<br/>[types.ts]"]
end

subgraph group_api["Express Backend"]
  node_entry{{"Unified Entry<br/>Node/Express runtime<br/>[server.ts]"}}
  node_routes["API Routes<br/>Express router<br/>[api.ts]"]
  node_agent_controller["Agent Controller<br/>AI workflow controller<br/>[agentController.ts]"]
  node_document_controller["Document Controller<br/>ingestion controller"]
  node_data_controller["Data Controller<br/>domain controller<br/>[dataController.ts]"]
  node_search_controller["Search Controller"]
  node_deployment["Container Deployment<br/>Compose deployment<br/>[compose.yaml]"]
  node_shared_types["Server Contracts<br/>TypeScript contracts<br/>[index.ts]"]
end

subgraph group_knowledge["AI &amp; Retrieval"]
  node_gemini{{"Gemini Service<br/>LLM integration<br/>[geminiService.ts]"}}
  node_vector_store["Vector Store<br/>semantic retrieval<br/>[vectorStore.ts]"]
  node_chroma_service["Chroma Service<br/>vector infrastructure<br/>[chromaService.ts]"]
  node_job_queue["Job Queue<br/>async work boundary<br/>[jobQueue.ts]"]
end

subgraph group_data["Data Stores"]
  node_models["Database Model Layer<br/>persistence access<br/>[dbModel.ts]"]
  node_database_config[("PostgreSQL Configuration<br/>Neon integration<br/>[database.ts]")]
  node_schema["Relational Schema<br/>SQL schema<br/>[schema.sql]"]
  node_chroma_data[("Chroma Local Data<br/>vector database<br/>[chroma.sqlite3]")]
end

node_client_main -->|"mounts"| node_client_app
node_client_app -->|"uses"| node_api_adapter
node_client_app -.->|"uses"| node_client_types
node_api_adapter -->|"HTTP requests"| node_routes
node_entry -->|"mounts"| node_routes
node_deployment -->|"runs"| node_entry
node_routes -->|"agent and RCA"| node_agent_controller
node_routes -->|"document ingestion"| node_document_controller
node_routes -->|"source data"| node_data_controller
node_routes -->|"search"| node_search_controller
node_agent_controller -->|"generation"| node_gemini
node_agent_controller -->|"retrieved context"| node_vector_store
node_agent_controller -.->|"uses"| node_shared_types
node_document_controller -->|"queues heavy work"| node_job_queue
node_document_controller -->|"content interpretation"| node_gemini
node_document_controller -->|"indexes"| node_vector_store
node_search_controller -->|"semantic lookup"| node_vector_store
node_vector_store -->|"uses"| node_chroma_service
node_chroma_service -->|"persists vectors"| node_chroma_data
node_data_controller -->|"queries"| node_models
node_document_controller -->|"stores metadata"| node_models
node_agent_controller -->|"reads cases and records"| node_models
node_models -->|"connects through"| node_database_config
node_schema -.->|"defines data model"| node_models

click node_entry "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server.ts"
click node_client_app "https://github.com/paraggarg969/et-ai-prob-8/blob/main/src/App.tsx"
click node_client_main "https://github.com/paraggarg969/et-ai-prob-8/blob/main/src/main.tsx"
click node_api_adapter "https://github.com/paraggarg969/et-ai-prob-8/blob/main/src/services/api.ts"
click node_client_types "https://github.com/paraggarg969/et-ai-prob-8/blob/main/src/types.ts"
click node_routes "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/routes/api.ts"
click node_agent_controller "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/controllers/agentController.ts"
click node_document_controller "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/controllers/documentController.ts"
click node_data_controller "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/controllers/dataController.ts"
click node_search_controller "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/controllers/searchController.ts"
click node_gemini "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/services/geminiService.ts"
click node_vector_store "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/services/vectorStore.ts"
click node_chroma_service "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/services/chromaService.ts"
click node_job_queue "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/services/jobQueue.ts"
click node_models "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/models/dbModel.ts"
click node_database_config "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/config/database.ts"
click node_schema "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/database/schema.sql"
click node_chroma_data "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/chroma_data/chroma.sqlite3"
click node_deployment "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/compose.yaml"
click node_shared_types "https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/types/index.ts"

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_client_app,node_client_main,node_api_adapter,node_client_types toneBlue
class node_entry,node_routes,node_agent_controller,node_document_controller,node_data_controller,node_search_controller,node_deployment,node_shared_types toneAmber
class node_gemini,node_vector_store,node_chroma_service,node_job_queue toneMint
class node_models,node_database_config,node_schema,node_chroma_data toneRose
```

## Components

### React Client

- [Application Shell](https://github.com/paraggarg969/et-ai-prob-8/blob/main/src/App.tsx): React UI · Dashboard, graph, copilot, RCA, and compliance workflows. · `src/App.tsx`
- [Client Mount](https://github.com/paraggarg969/et-ai-prob-8/blob/main/src/main.tsx): React bootstrap · `src/main.tsx`
- [API Adapter](https://github.com/paraggarg969/et-ai-prob-8/blob/main/src/services/api.ts): client service · Client-only boundary for backend requests. · `src/services/api.ts`
- [Client Types](https://github.com/paraggarg969/et-ai-prob-8/blob/main/src/types.ts): TypeScript contracts · `src/types.ts`

### Express Backend

- [Unified Entry](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server.ts): Node/Express runtime · Starts the server and frontend integration. · `server.ts`
- [API Routes](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/routes/api.ts): Express router · Central route delegation boundary. · `server/routes/api.ts`
- [Agent Controller](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/controllers/agentController.ts): AI workflow controller · Coordinates copilot, RCA, and compliance reasoning. · `server/controllers/agentController.ts`
- [Document Controller](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/controllers/documentController.ts): ingestion controller · Accepts and orchestrates document ingestion. · `server/controllers/documentController.ts`
- [Data Controller](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/controllers/dataController.ts): domain controller · Exposes source and graph-oriented data. · `server/controllers/dataController.ts`
- [Search Controller](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/controllers/searchController.ts): search controller · `server/controllers/searchController.ts`
- [Container Deployment](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/compose.yaml): Compose deployment · `server/compose.yaml`
- [Server Contracts](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/types/index.ts): TypeScript contracts · Agent workflow and domain type definitions. · `server/types/index.ts`

### AI & Retrieval

- [Gemini Service](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/services/geminiService.ts): LLM integration · Interprets content and generates safety guidance. · `server/services/geminiService.ts`
- [Vector Store](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/services/vectorStore.ts): semantic retrieval · Indexes and retrieves document context. · `server/services/vectorStore.ts`
- [Chroma Service](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/services/chromaService.ts): vector infrastructure · `server/services/chromaService.ts`
- [Job Queue](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/services/jobQueue.ts): async work boundary · Decouples ingestion and AI-heavy tasks. · `server/services/jobQueue.ts`

### Data Stores

- [Database Model Layer](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/models/dbModel.ts): persistence access · Centralizes relational data access. · `server/models/dbModel.ts`
- [PostgreSQL Configuration](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/config/database.ts): Neon integration · Connects authoritative relational persistence through DATABASE_URL. · `server/config/database.ts`
- [Relational Schema](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/database/schema.sql): SQL schema · Documents, graph entities, RCA cases, and compliance records. · `server/database/schema.sql`
- [Chroma Local Data](https://github.com/paraggarg969/et-ai-prob-8/blob/main/server/chroma_data/chroma.sqlite3): vector database · Repository-local Chroma persistence. · `server/chroma_data/chroma.sqlite3`

## Connections

- Client Mount → Application Shell: mounts
- Application Shell → API Adapter: uses
- Application Shell → Client Types: uses
- API Adapter → API Routes: HTTP requests
- Unified Entry → API Routes: mounts
- Container Deployment → Unified Entry: runs
- API Routes → Agent Controller: agent and RCA
- API Routes → Document Controller: document ingestion
- API Routes → Data Controller: source data
- API Routes → Search Controller: search
- Agent Controller → Gemini Service: generation
- Agent Controller → Vector Store: retrieved context
- Agent Controller → Server Contracts: uses
- Document Controller → Job Queue: queues heavy work
- Document Controller → Gemini Service: content interpretation
- Document Controller → Vector Store: indexes
- Search Controller → Vector Store: semantic lookup
- Vector Store → Chroma Service: uses
- Chroma Service → Chroma Local Data: persists vectors
- Data Controller → Database Model Layer: queries
- Document Controller → Database Model Layer: stores metadata
- Agent Controller → Database Model Layer: reads cases and records
- Database Model Layer → PostgreSQL Configuration: connects through
- Relational Schema → Database Model Layer: defines data model
