# mohammedhuzef/etp_sludgeops architecture

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

- Interactive diagram: https://gitdiagram.com/mohammedhuzef/etp_sludgeops
- Repository: https://github.com/mohammedhuzef/etp_sludgeops

## Overview

This is an ETP sludge-operations application with a React workflow for generation, characterisation, dewatering, storage/disposal and compliance, alongside an Express regulatory/AI backend. The frontend context coordinates operational state; backend routes expose regulatory data and AI services. The README is only a Vite template and documents no product capabilities. Some major views and services are indexed but unsampled, so their internal behavior and unshown connections are omitted.

Main entry points: [`src/App.tsx`](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/App.tsx) (Application Router), [`src/context/ETPContext.tsx`](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/context/ETPContext.tsx) (ETP State Context), [`src/components/modules/ComplianceCenterView.tsx`](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/modules/ComplianceCenterView.tsx) (Compliance Center), [`server/src/routes/documents.ts`](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/routes/documents.ts) (Documents Route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Operations UI"]
  node_app["Application Router<br/>[App.tsx]"]
  node_dashboard["Operations Dashboard<br/>[DashboardView.tsx]"]
  node_generation["Sludge Generation"]
  node_characterisation["Batch Characterisation"]
  node_dewatering["Dewatering<br/>[DewateringView.tsx]"]
  node_storage["Storage and Dispatch"]
  node_complianceui["Compliance Center"]
  node_plant["Plant Design"]
  node_layout["Navigation and Alerts<br/>[Sidebar.tsx]"]
  node_groqclient["AI API Client<br/>[groqService.ts]"]
  node_ragui["Regulatory Assistant"]
  node_aipanel["AI Advice Panel<br/>[GroqAIPanel.tsx]"]
end

subgraph group_state["Operational Data"]
  node_context["ETP State Context<br/>[ETPContext.tsx]"]
  node_calculations["Operational Calculations<br/>[calculations.ts]"]
  node_mockdata["Initial Sample Data<br/>[mockData.ts]"]
  node_types["Operational Types<br/>[index.ts]"]
end

subgraph group_api["Regulatory API"]
  node_apiindex["HTTP Server and Routes<br/>[index.ts]"]
  node_complianceapi["Compliance Route<br/>[compliance.ts]"]
  node_documentsapi["Documents Route<br/>[documents.ts]"]
  node_aiapi["AI Route<br/>[ai.ts]"]
end

subgraph group_services["Compliance and AI"]
  node_engine["Compliance Evaluator"]
  node_ragengine["Regulatory RAG<br/>[ragEngine.ts]"]
  node_groqservice["Server AI Service<br/>[groqAiService.ts]"]
  node_pdf["PDF Extraction<br/>[pdfExtractor.ts]"]
  node_ruleextract["Rule Extraction<br/>[ruleExtractor.ts]"]
end

subgraph group_persistence["Persistence"]
  node_database[("Regulatory Data Store<br/>[database.ts]")]
  node_supabase["Supabase Report Service<br/>[supabaseService.ts]"]
end

node_operator(("Operator"))
node_supabaseext[("Supabase")]

node_operator -->|"uses"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_generation
node_app -->|"routes to"| node_characterisation
node_app -->|"routes to"| node_dewatering
node_app -->|"routes to"| node_storage
node_app -->|"routes to"| node_complianceui
node_app -->|"routes to"| node_plant
node_app -->|"provides state"| node_context
node_context -->|"loads defaults"| node_mockdata
node_context -->|"evaluates metrics"| node_calculations
node_context -->|"uses types"| node_types
node_dewatering -->|"calculates"| node_calculations
node_dewatering -->|"reads state"| node_context
node_storage -->|"reads state"| node_context
node_complianceui -->|"reads state"| node_context
node_complianceui -->|"renders"| node_aipanel
node_complianceui -->|"renders"| node_ragui
node_complianceui -->|"requests advice"| node_groqclient
node_ragui -->|"queries"| node_groqclient
node_groqclient -->|"posts AI requests"| node_aiapi
node_apiindex -->|"registers route"| node_complianceapi
node_apiindex -->|"registers route"| node_documentsapi
node_apiindex -->|"registers route"| node_aiapi
node_complianceapi -->|"runs evaluation"| node_engine
node_engine -->|"reads rules and saves findings"| node_database
node_documentsapi -->|"manages documents"| node_database
node_documentsapi -->|"extracts PDF"| node_pdf
node_documentsapi -->|"extracts rules"| node_ruleextract
node_documentsapi -->|"stores reports"| node_supabase
node_aiapi -->|"requests generation"| node_groqservice
node_aiapi -->|"queries corpus"| node_ragengine
node_aiapi -->|"uses report service"| node_supabase
node_ragengine -->|"reads regulatory records"| node_database
node_supabase -->|"accesses"| node_supabaseext

click node_app "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/App.tsx"
click node_dashboard "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/modules/DashboardView.tsx"
click node_generation "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/modules/SludgeGenerationView.tsx"
click node_characterisation "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/modules/CharacterisationView.tsx"
click node_dewatering "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/modules/DewateringView.tsx"
click node_storage "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/modules/StorageDisposalView.tsx"
click node_complianceui "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/modules/ComplianceCenterView.tsx"
click node_plant "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/modules/Plant3DDesignView.tsx"
click node_layout "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/layout/Sidebar.tsx"
click node_context "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/context/ETPContext.tsx"
click node_calculations "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/utils/calculations.ts"
click node_mockdata "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/utils/mockData.ts"
click node_types "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/types/index.ts"
click node_groqclient "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/services/groqService.ts"
click node_ragui "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/common/RagAssistantModal.tsx"
click node_aipanel "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/common/GroqAIPanel.tsx"
click node_apiindex "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/index.ts"
click node_complianceapi "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/routes/compliance.ts"
click node_documentsapi "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/routes/documents.ts"
click node_aiapi "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/routes/ai.ts"
click node_engine "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/services/complianceEngine.ts"
click node_ragengine "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/services/ragEngine.ts"
click node_groqservice "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/services/groqAiService.ts"
click node_pdf "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/services/pdfExtractor.ts"
click node_ruleextract "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/services/ruleExtractor.ts"
click node_database "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/db/database.ts"
click node_supabase "https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/services/supabaseService.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_app,node_dashboard,node_generation,node_characterisation,node_dewatering,node_storage,node_complianceui,node_plant,node_layout,node_groqclient,node_ragui,node_aipanel toneBlue
class node_context,node_calculations,node_mockdata,node_types,node_supabaseext toneAmber
class node_apiindex,node_complianceapi,node_documentsapi,node_aiapi toneMint
class node_engine,node_ragengine,node_groqservice,node_pdf,node_ruleextract toneRose
class node_database,node_supabase,node_operator toneIndigo
```

## Components

### Operations UI

- [Application Router](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/App.tsx): `src/App.tsx`
- [Operations Dashboard](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/modules/DashboardView.tsx): `src/components/modules/DashboardView.tsx`
- [Sludge Generation](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/modules/SludgeGenerationView.tsx): `src/components/modules/SludgeGenerationView.tsx`
- [Batch Characterisation](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/modules/CharacterisationView.tsx): `src/components/modules/CharacterisationView.tsx`
- [Dewatering](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/modules/DewateringView.tsx): `src/components/modules/DewateringView.tsx`
- [Storage and Dispatch](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/modules/StorageDisposalView.tsx): `src/components/modules/StorageDisposalView.tsx`
- [Compliance Center](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/modules/ComplianceCenterView.tsx): `src/components/modules/ComplianceCenterView.tsx`
- [Plant Design](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/modules/Plant3DDesignView.tsx): `src/components/modules/Plant3DDesignView.tsx`
- [Navigation and Alerts](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/layout/Sidebar.tsx): `src/components/layout/Sidebar.tsx`
- [AI API Client](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/services/groqService.ts): `src/services/groqService.ts`
- [Regulatory Assistant](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/common/RagAssistantModal.tsx): `src/components/common/RagAssistantModal.tsx`
- [AI Advice Panel](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/components/common/GroqAIPanel.tsx): `src/components/common/GroqAIPanel.tsx`

### Operational Data

- [ETP State Context](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/context/ETPContext.tsx): `src/context/ETPContext.tsx`
- [Operational Calculations](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/utils/calculations.ts): `src/utils/calculations.ts`
- [Initial Sample Data](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/utils/mockData.ts): `src/utils/mockData.ts`
- [Operational Types](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/src/types/index.ts): `src/types/index.ts`

### Regulatory API

- [HTTP Server and Routes](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/index.ts): `server/src/index.ts`
- [Compliance Route](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/routes/compliance.ts): `server/src/routes/compliance.ts`
- [Documents Route](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/routes/documents.ts): `server/src/routes/documents.ts`
- [AI Route](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/routes/ai.ts): `server/src/routes/ai.ts`

### Compliance and AI

- [Compliance Evaluator](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/services/complianceEngine.ts): `server/src/services/complianceEngine.ts`
- [Regulatory RAG](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/services/ragEngine.ts): `server/src/services/ragEngine.ts`
- [Server AI Service](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/services/groqAiService.ts): `server/src/services/groqAiService.ts`
- [PDF Extraction](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/services/pdfExtractor.ts): `server/src/services/pdfExtractor.ts`
- [Rule Extraction](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/services/ruleExtractor.ts): `server/src/services/ruleExtractor.ts`

### Persistence

- [Regulatory Data Store](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/db/database.ts): `server/src/db/database.ts`
- [Supabase Report Service](https://github.com/mohammedhuzef/etp_sludgeops/blob/main/server/src/services/supabaseService.ts): `server/src/services/supabaseService.ts`

### Other components

- **Operator**
- **Supabase**

## Connections

- Operator → Application Router: uses (evidence: `src/App.tsx`)
- Application Router → Operations Dashboard: routes to (evidence: `src/App.tsx`)
- Application Router → Sludge Generation: routes to (evidence: `src/App.tsx`)
- Application Router → Batch Characterisation: routes to (evidence: `src/App.tsx`)
- Application Router → Dewatering: routes to (evidence: `src/App.tsx`)
- Application Router → Storage and Dispatch: routes to (evidence: `src/App.tsx`)
- Application Router → Compliance Center: routes to (evidence: `src/App.tsx`)
- Application Router → Plant Design: routes to (evidence: `src/App.tsx`)
- Application Router → ETP State Context: provides state (evidence: `src/App.tsx`)
- ETP State Context → Initial Sample Data: loads defaults (evidence: `src/context/ETPContext.tsx`)
- ETP State Context → Operational Calculations: evaluates metrics (evidence: `src/context/ETPContext.tsx`)
- ETP State Context → Operational Types: uses types (evidence: `src/context/ETPContext.tsx`)
- Dewatering → Operational Calculations: calculates (evidence: `src/components/modules/DewateringView.tsx`)
- Dewatering → ETP State Context: reads state (evidence: `src/components/modules/DewateringView.tsx`)
- Storage and Dispatch → ETP State Context: reads state (evidence: `src/components/modules/StorageDisposalView.tsx`)
- Compliance Center → ETP State Context: reads state (evidence: `src/components/modules/ComplianceCenterView.tsx`)
- Compliance Center → AI Advice Panel: renders (evidence: `src/components/modules/ComplianceCenterView.tsx`)
- Compliance Center → Regulatory Assistant: renders (evidence: `src/components/modules/ComplianceCenterView.tsx`)
- Compliance Center → AI API Client: requests advice (evidence: `src/components/modules/ComplianceCenterView.tsx`)
- Regulatory Assistant → AI API Client: queries (evidence: `src/components/common/RagAssistantModal.tsx`)
- AI API Client → AI Route: posts AI requests (evidence: `src/services/groqService.ts`)
- HTTP Server and Routes → Compliance Route: registers route (evidence: `server/src/index.ts`)
- HTTP Server and Routes → Documents Route: registers route (evidence: `server/src/index.ts`)
- HTTP Server and Routes → AI Route: registers route (evidence: `server/src/index.ts`)
- Compliance Route → Compliance Evaluator: runs evaluation (evidence: `server/src/routes/compliance.ts`)
- Compliance Evaluator → Regulatory Data Store: reads rules and saves findings (evidence: `server/src/services/complianceEngine.ts`)
- Documents Route → Regulatory Data Store: manages documents (evidence: `server/src/routes/documents.ts`)
- Documents Route → PDF Extraction: extracts PDF (evidence: `server/src/routes/documents.ts`)
- Documents Route → Rule Extraction: extracts rules (evidence: `server/src/routes/documents.ts`)
- Documents Route → Supabase Report Service: stores reports (evidence: `server/src/routes/documents.ts`)
- AI Route → Server AI Service: requests generation (evidence: `server/src/routes/ai.ts`)
- AI Route → Regulatory RAG: queries corpus (evidence: `server/src/routes/ai.ts`)
- AI Route → Supabase Report Service: uses report service (evidence: `server/src/routes/ai.ts`)
- Regulatory RAG → Regulatory Data Store: reads regulatory records (evidence: `server/src/services/ragEngine.ts`)
- Supabase Report Service → Supabase: accesses (evidence: `server/src/services/supabaseService.ts`)
