# adarshreddy13/etp_sludgeops architecture

> Architecture diagram of the GitHub repository adarshreddy13/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/adarshreddy13/etp_sludgeops
- Repository: https://github.com/adarshreddy13/etp_sludgeops

## Overview

This repository appears to implement an ETP sludge-operations application: users record sludge generation, manage batches through characterisation and dewatering, track storage and dispatch, and review compliance. A React frontend also exposes regulatory AI assistance, while a TypeScript API provides document, rule, authorisation, obligation, compliance, and AI endpoints. The Python backend is a separate additional service in the tree. The README is only a Vite template; unsampled modules are included where the source index identifies them, but their internal behavior and wiring are not assumed.

Main entry points: [`src/App.tsx`](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/App.tsx) (Application shell), [`server/src/index.ts`](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/index.ts) (TypeScript API entry), [`server/src/db/database.ts`](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/db/database.ts) (Regulatory data store), [`server/src/routes/documents.ts`](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/routes/documents.ts) (Document endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Operations frontend"]
  node_app["Application shell<br/>[App.tsx]"]
  node_data_table["Data table<br/>[DataTable.tsx]"]
  node_kpi["KPI cards<br/>[KPICard.tsx]"]
  node_groq_panel["AI analysis panel<br/>[GroqAIPanel.tsx]"]
  node_rag_modal["Regulatory assistant"]
  node_groq_client["AI API client<br/>[groqService.ts]"]
end

subgraph group_domain["Sludge operations"]
  node_context["Operations state<br/>[ETPContext.tsx]"]
  node_generation["Sludge generation"]
  node_characterisation["Batch characterisation"]
  node_dewatering["Dewatering<br/>[DewateringView.tsx]"]
  node_storageview["Storage and dispatch"]
  node_complianceview["Compliance centre"]
  node_plant["Plant design"]
  node_dashboard["Operations dashboard<br/>[DashboardView.tsx]"]
  node_calculations["Operational calculations<br/>[calculations.ts]"]
end

subgraph group_regulatory["Regulatory services"]
  node_api_entry["TypeScript API entry<br/>[index.ts]"]
  node_documents_route["Document endpoints<br/>[documents.ts]"]
  node_rules_route["Rule endpoints<br/>[rules.ts]"]
  node_authorisations_route["Authorisation endpoints<br/>[authorisations.ts]"]
  node_obligations_route["Obligation endpoints<br/>[obligations.ts]"]
  node_compliance_route["Compliance endpoints<br/>[compliance.ts]"]
  node_ai_route["AI endpoints<br/>[ai.ts]"]
  node_compliance_engine["Compliance evaluation"]
  node_rag_engine["Regulatory retrieval<br/>[ragEngine.ts]"]
  node_groq_service["Groq generation<br/>[groqAiService.ts]"]
  node_pdf_extractor["PDF extraction<br/>[pdfExtractor.ts]"]
  node_rule_extractor["Rule extraction<br/>[ruleExtractor.ts]"]
  node_python_entry["Python API service<br/>[main.py]"]
end

subgraph group_storage["Persistence and models"]
  node_database[("Regulatory data store<br/>[database.ts]")]
  node_supabase[("Supabase reports<br/>[supabaseService.ts]")]
  node_models["Regulatory data types<br/>[types.ts]"]
  node_python_db[("Python data access<br/>[db.py]")]
end

node_operator(("Facility operator"))
node_api_actor(("Frontend API"))

node_operator -->|"uses"| node_app
node_app -->|"provides state"| node_context
node_app -->|"selects view"| node_dashboard
node_app -->|"selects view"| node_generation
node_app -->|"selects view"| node_characterisation
node_app -->|"selects view"| node_dewatering
node_app -->|"selects view"| node_storageview
node_app -->|"selects view"| node_complianceview
node_app -->|"selects view"| node_plant
node_generation -->|"records operations"| node_context
node_dewatering -->|"uses calculations"| node_calculations
node_dewatering -->|"renders table"| node_data_table
node_dewatering -->|"renders metrics"| node_kpi
node_dewatering -->|"renders analysis"| node_groq_panel
node_storageview -->|"uses operations state"| node_context
node_storageview -.->|"renders table"| node_data_table
node_storageview -.->|"renders metrics"| node_kpi
node_rag_modal -->|"queries"| node_groq_client
node_groq_client -->|"posts AI requests"| node_api_actor
node_api_actor -.->|"calls API"| node_api_entry
node_api_entry -->|"registers route"| node_documents_route
node_api_entry -->|"registers route"| node_rules_route
node_api_entry -->|"registers route"| node_authorisations_route
node_api_entry -->|"registers route"| node_obligations_route
node_api_entry -->|"registers route"| node_compliance_route
node_api_entry -->|"registers route"| node_ai_route
node_documents_route -->|"reads and writes"| node_database
node_documents_route -->|"extracts PDF"| node_pdf_extractor
node_documents_route -->|"extracts rules"| node_rule_extractor
node_documents_route -->|"uses report service"| node_supabase
node_rules_route -->|"reads and writes"| node_database
node_authorisations_route -->|"reads and writes"| node_database
node_obligations_route -->|"reads and writes"| node_database
node_compliance_route -->|"evaluates compliance"| node_compliance_engine
node_compliance_engine -->|"loads rules and saves findings"| node_database
node_ai_route -->|"requests generation"| node_groq_service
node_ai_route -->|"queries corpus"| node_rag_engine
node_ai_route -->|"uses report service"| node_supabase
node_rag_engine -->|"loads regulatory records"| node_database
node_python_entry -->|"uses data access"| node_python_db
node_documents_route -->|"uses document types"| node_models
node_rules_route -->|"uses rule types"| node_models
node_obligations_route -->|"uses obligation types"| node_models
node_database -->|"stores typed records"| node_models

click node_app "https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/App.tsx"
click node_context "https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/context/ETPContext.tsx"
click node_generation "https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/modules/SludgeGenerationView.tsx"
click node_characterisation "https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/modules/CharacterisationView.tsx"
click node_dewatering "https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/modules/DewateringView.tsx"
click node_storageview "https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/modules/StorageDisposalView.tsx"
click node_complianceview "https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/modules/ComplianceCenterView.tsx"
click node_plant "https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/modules/Plant3DDesignView.tsx"
click node_dashboard "https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/modules/DashboardView.tsx"
click node_calculations "https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/utils/calculations.ts"
click node_data_table "https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/common/DataTable.tsx"
click node_kpi "https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/common/KPICard.tsx"
click node_groq_panel "https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/common/GroqAIPanel.tsx"
click node_rag_modal "https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/common/RagAssistantModal.tsx"
click node_groq_client "https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/services/groqService.ts"
click node_api_entry "https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/index.ts"
click node_documents_route "https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/routes/documents.ts"
click node_rules_route "https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/routes/rules.ts"
click node_authorisations_route "https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/routes/authorisations.ts"
click node_obligations_route "https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/routes/obligations.ts"
click node_compliance_route "https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/routes/compliance.ts"
click node_ai_route "https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/routes/ai.ts"
click node_compliance_engine "https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/services/complianceEngine.ts"
click node_rag_engine "https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/services/ragEngine.ts"
click node_groq_service "https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/services/groqAiService.ts"
click node_pdf_extractor "https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/services/pdfExtractor.ts"
click node_rule_extractor "https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/services/ruleExtractor.ts"
click node_database "https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/db/database.ts"
click node_supabase "https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/services/supabaseService.ts"
click node_models "https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/models/types.ts"
click node_python_entry "https://github.com/adarshreddy13/etp_sludgeops/blob/main/backend/main.py"
click node_python_db "https://github.com/adarshreddy13/etp_sludgeops/blob/main/backend/db.py"

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_data_table,node_kpi,node_groq_panel,node_rag_modal,node_groq_client,node_api_actor toneBlue
class node_context,node_generation,node_characterisation,node_dewatering,node_storageview,node_complianceview,node_plant,node_dashboard,node_calculations toneAmber
class node_api_entry,node_documents_route,node_rules_route,node_authorisations_route,node_obligations_route,node_compliance_route,node_ai_route,node_compliance_engine,node_rag_engine,node_groq_service,node_pdf_extractor,node_rule_extractor,node_python_entry toneMint
class node_database,node_supabase,node_models,node_python_db toneRose
class node_operator toneIndigo
```

## Components

### Operations frontend

- [Application shell](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/App.tsx): `src/App.tsx`
- [Data table](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/common/DataTable.tsx): `src/components/common/DataTable.tsx`
- [KPI cards](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/common/KPICard.tsx): `src/components/common/KPICard.tsx`
- [AI analysis panel](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/common/GroqAIPanel.tsx): `src/components/common/GroqAIPanel.tsx`
- [Regulatory assistant](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/common/RagAssistantModal.tsx): `src/components/common/RagAssistantModal.tsx`
- [AI API client](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/services/groqService.ts): `src/services/groqService.ts`

### Sludge operations

- [Operations state](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/context/ETPContext.tsx): `src/context/ETPContext.tsx`
- [Sludge generation](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/modules/SludgeGenerationView.tsx): `src/components/modules/SludgeGenerationView.tsx`
- [Batch characterisation](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/modules/CharacterisationView.tsx): `src/components/modules/CharacterisationView.tsx`
- [Dewatering](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/modules/DewateringView.tsx): `src/components/modules/DewateringView.tsx`
- [Storage and dispatch](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/modules/StorageDisposalView.tsx): `src/components/modules/StorageDisposalView.tsx`
- [Compliance centre](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/modules/ComplianceCenterView.tsx): `src/components/modules/ComplianceCenterView.tsx`
- [Plant design](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/modules/Plant3DDesignView.tsx): `src/components/modules/Plant3DDesignView.tsx`
- [Operations dashboard](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/components/modules/DashboardView.tsx): `src/components/modules/DashboardView.tsx`
- [Operational calculations](https://github.com/adarshreddy13/etp_sludgeops/blob/main/src/utils/calculations.ts): `src/utils/calculations.ts`

### Regulatory services

- [TypeScript API entry](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/index.ts): `server/src/index.ts`
- [Document endpoints](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/routes/documents.ts): `server/src/routes/documents.ts`
- [Rule endpoints](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/routes/rules.ts): `server/src/routes/rules.ts`
- [Authorisation endpoints](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/routes/authorisations.ts): `server/src/routes/authorisations.ts`
- [Obligation endpoints](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/routes/obligations.ts): `server/src/routes/obligations.ts`
- [Compliance endpoints](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/routes/compliance.ts): `server/src/routes/compliance.ts`
- [AI endpoints](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/routes/ai.ts): `server/src/routes/ai.ts`
- [Compliance evaluation](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/services/complianceEngine.ts): `server/src/services/complianceEngine.ts`
- [Regulatory retrieval](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/services/ragEngine.ts): `server/src/services/ragEngine.ts`
- [Groq generation](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/services/groqAiService.ts): `server/src/services/groqAiService.ts`
- [PDF extraction](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/services/pdfExtractor.ts): `server/src/services/pdfExtractor.ts`
- [Rule extraction](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/services/ruleExtractor.ts): `server/src/services/ruleExtractor.ts`
- [Python API service](https://github.com/adarshreddy13/etp_sludgeops/blob/main/backend/main.py): `backend/main.py`

### Persistence and models

- [Regulatory data store](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/db/database.ts): `server/src/db/database.ts`
- [Supabase reports](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/services/supabaseService.ts): `server/src/services/supabaseService.ts`
- [Regulatory data types](https://github.com/adarshreddy13/etp_sludgeops/blob/main/server/src/models/types.ts): `server/src/models/types.ts`
- [Python data access](https://github.com/adarshreddy13/etp_sludgeops/blob/main/backend/db.py): `backend/db.py`

### Other components

- **Facility operator**
- **Frontend API**

## Connections

- Facility operator → Application shell: uses (evidence: `src/App.tsx`)
- Application shell → Operations state: provides state (evidence: `src/App.tsx`)
- Application shell → Operations dashboard: selects view (evidence: `src/App.tsx`)
- Application shell → Sludge generation: selects view (evidence: `src/App.tsx`)
- Application shell → Batch characterisation: selects view (evidence: `src/App.tsx`)
- Application shell → Dewatering: selects view (evidence: `src/App.tsx`)
- Application shell → Storage and dispatch: selects view (evidence: `src/App.tsx`)
- Application shell → Compliance centre: selects view (evidence: `src/App.tsx`)
- Application shell → Plant design: selects view (evidence: `src/App.tsx`)
- Sludge generation → Operations state: records operations
- Dewatering → Operational calculations: uses calculations (evidence: `src/components/modules/DewateringView.tsx`)
- Dewatering → Data table: renders table (evidence: `src/components/modules/DewateringView.tsx`)
- Dewatering → KPI cards: renders metrics (evidence: `src/components/modules/DewateringView.tsx`)
- Dewatering → AI analysis panel: renders analysis (evidence: `src/components/modules/DewateringView.tsx`)
- Storage and dispatch → Operations state: uses operations state (evidence: `src/components/modules/StorageDisposalView.tsx`)
- Storage and dispatch → Data table: renders table (evidence: `src/components/modules/StorageDisposalView.tsx`)
- Storage and dispatch → KPI cards: renders metrics (evidence: `src/components/modules/StorageDisposalView.tsx`)
- Regulatory assistant → AI API client: queries (evidence: `src/components/common/RagAssistantModal.tsx`)
- AI API client → Frontend API: posts AI requests (evidence: `src/services/groqService.ts`)
- Frontend API → TypeScript API entry: calls API
- TypeScript API entry → Document endpoints: registers route (evidence: `server/src/index.ts`)
- TypeScript API entry → Rule endpoints: registers route (evidence: `server/src/index.ts`)
- TypeScript API entry → Authorisation endpoints: registers route (evidence: `server/src/index.ts`)
- TypeScript API entry → Obligation endpoints: registers route (evidence: `server/src/index.ts`)
- TypeScript API entry → Compliance endpoints: registers route (evidence: `server/src/index.ts`)
- TypeScript API entry → AI endpoints: registers route (evidence: `server/src/index.ts`)
- Document endpoints → Regulatory data store: reads and writes (evidence: `server/src/routes/documents.ts`)
- Document endpoints → PDF extraction: extracts PDF (evidence: `server/src/routes/documents.ts`)
- Document endpoints → Rule extraction: extracts rules (evidence: `server/src/routes/documents.ts`)
- Document endpoints → Supabase reports: uses report service (evidence: `server/src/routes/documents.ts`)
- Rule endpoints → Regulatory data store: reads and writes (evidence: `server/src/routes/rules.ts`)
- Authorisation endpoints → Regulatory data store: reads and writes (evidence: `server/src/routes/authorisations.ts`)
- Obligation endpoints → Regulatory data store: reads and writes (evidence: `server/src/routes/obligations.ts`)
- Compliance endpoints → Compliance evaluation: evaluates compliance (evidence: `server/src/routes/compliance.ts`)
- Compliance evaluation → Regulatory data store: loads rules and saves findings (evidence: `server/src/services/complianceEngine.ts`)
- AI endpoints → Groq generation: requests generation (evidence: `server/src/routes/ai.ts`)
- AI endpoints → Regulatory retrieval: queries corpus (evidence: `server/src/routes/ai.ts`)
- AI endpoints → Supabase reports: uses report service (evidence: `server/src/routes/ai.ts`)
- Regulatory retrieval → Regulatory data store: loads regulatory records (evidence: `server/src/services/ragEngine.ts`)
- Python API service → Python data access: uses data access (evidence: `backend/main.py`)
- Document endpoints → Regulatory data types: uses document types (evidence: `server/src/routes/documents.ts`)
- Rule endpoints → Regulatory data types: uses rule types (evidence: `server/src/routes/rules.ts`)
- Obligation endpoints → Regulatory data types: uses obligation types (evidence: `server/src/routes/obligations.ts`)
- Regulatory data store → Regulatory data types: stores typed records (evidence: `server/src/db/database.ts`)
