# chirag-dhanda/jsl-contigency architecture

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

- Interactive diagram: https://gitdiagram.com/chirag-dhanda/jsl-contigency
- Repository: https://github.com/chirag-dhanda/jsl-contigency

## Overview

1. This repository is an enterprise platform monorepo, not a single app. It contains multiple user-facing UIs, a Python backend, AI/knowledge services, database assets, deployment tooling, and a large documentation/governance layer. The core product theme is knowledge + learning + manufacturing operations, with AI and workflow capabilities built around that.

2. The frontend is split into three distinct surfaces: a newer React/Vite app in `front1`, another React/JS Vite app in `frontend_app`, and a legacy static/JS app in `frontend`. They all present similar business areas such as dashboard, admin, learning, knowledge studio, workflow, media library, search, and approvals. The UIs consume backend APIs and use mock/service layers for local development.

3. The backend is a Python modular monolith centered in `backend/main.py`, with orchestration and lifecycle code in `backend/core`, shared config in `backend/config`, and cross-cutting concerns like logging, middleware, exceptions, and dependency injection. This is the main runtime boundary: request handling enters here, then routes into domain modules, services, and repositories.

4. Business capability is organized as many backend modules rather than a few large services. The important domains include authentication, authorization, users, roles/permissions, departments, learning, notifications, dashboard, search, reports, workflow, content, media, knowledge, roadmap, assessment, and audit. Most modules follow a consistent internal shape of models, services, APIs/controllers, and module registration.

5. The AI subsystem is a major architectural branch. It includes AI platform/orchestrator/router/runtime modules, provider abstractions, Ollama integration, prompt management, conversations, skills/tools, monitoring, moderation, memory, and a dedicated AI gateway/cache layer. The data flow is typically: user prompt or knowledge request → context/prompt assembly → retrieval or tool use → local model inference via Ollama → formatted response with citations/observability.

6. Knowledge ingestion and retrieval form a pipeline of their own. The repository contains document parsing, chunking, metadata extraction, embeddings generation, vector search, retrieval, and response formatting, plus knowledge platform/studio modules for upload, review, publishing, and explorer experiences. Storage is backed by local document assets and a vector store (`storage/chromadb`), with additional graph-style relationship handling in the relationship engine and Neo4j-oriented code paths.

7. Persistence is multi-store rather than single-database only. There is a relational model layer with migrations under `backend/migrations`, repository abstractions, and an entity catalog/database documentation structure. In addition, there is graph persistence (`neo4j_engine`, relationship repositories) and vector persistence (vector DB/chroma storage). The architecture therefore separates operational data, knowledge graph data, and embedding/vector data.

8. Workflow and automation are first-class. `backend/modules/workflow_engine` handles definitions, tasks, runtime, approvals, events, and notifications, while the events subsystem provides a bus, registry, subscriptions, automation engine, store, and dead-letter queue. This makes the platform event-driven inside the backend even though it is packaged as a modular monolith.

9. Security and governance are deeply embedded, not bolted on. Authentication, JWT/password handling, rate limiting, headers, sessions, and security controls are complemented by governance platform logic for classification, compliance, field security, row-level security, policy enforcement, and audit monitoring. Role/permission management and access requests are central to access control across the system.

10. Integration boundaries are explicit, especially for enterprise systems. `backend/modules/integration_platform` includes connectors, a gateway, sync engine, transformation, scheduling, and conflict handling, while the `sap` directory and `backend/services/future-sap`/related docs show planned and current ERP mapping work. This suggests bidirectional synchronization with SAP-style source systems as a key external dependency.

11. Content and media are managed as platform assets rather than just files. There are modules for document intelligence, document processing, media platform, thumbnails, OCR, uploads, storage, and demo data generation, plus a large checked-in corpus under `backend/storage/demo_docs`, `knowledge-base`, and `demo-data`. These assets feed both the learning/knowledge features and the AI/RAG pipeline.

12. Operations and quality are supported by strong platform scaffolding: CI workflows in `.github/workflows`, Docker and deployment assets, scripts and tasks, health endpoints, logs, tests, and benchmark/performance/security suites. The repo also includes extensive architecture, standards, governance, and review documents, indicating that documentation and process are part of the system’s operational design, not just supporting material.

Main entry points: [`backend/main.py`](https://github.com/chirag-dhanda/jsl-contigency/blob/main/backend/main.py) (main.py), [`backend/modules/knowledge_platform`](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/knowledge_platform) (Knowledge platform), [`backend/modules/ai_platform`](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/ai_platform) (AI platform), [`docs`](https://github.com/chirag-dhanda/jsl-contigency/tree/main/docs) (Docs & standards)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_frontend["Frontend surfaces"]
  node_front1["front1<br/>React/Vite UI"]
  node_frontend_app["frontend_app<br/>React/JS UI"]
  node_frontend_legacy["frontend<br/>Legacy JS UI"]
end

subgraph group_group_backend["Backend platform"]
  node_backend_main["main.py<br/>Python entrypoint<br/>[main.py]"]
  node_backend_core["Core runtime<br/>lifecycle/DI"]
  node_backend_config["Config<br/>settings modules"]
  node_security_auth["Security & auth<br/>identity/rbac"]
  node_user_org_domain["People domain<br/>users/org/roles"]
  node_learning_content["Learning & content<br/>learning/media"]
  node_knowledge_platform["Knowledge platform<br/>ingest/retrieve"]
  node_ai_platform["AI platform<br/>orchestrator/rag"]
  node_workflow_events["Workflow events<br/>workflow/bus"]
  node_integration_sap["Integration layer<br/>connectors/sync"]
  node_governance_platform["Governance<br/>policy/compliance"]
end

subgraph group_group_data["Data layers"]
  node_rel_graph[("Relationship graph<br/>neo4j/vector graph")]
  node_relational_db[("Relational DB<br/>migrations/models")]
  node_vector_store[("Vector store<br/>chromadb/chunks")]
  node_demo_corpus["Demo corpus<br/>documents/media"]
end

subgraph group_group_ops["Docs and operations"]
  node_docs_governance["Docs & standards<br/>architecture/process"]
  node_deploy_ci["CI/CD & deploy<br/>pipelines/containers<br/>[workflows]"]
end

node_front1 -->|"API calls"| node_backend_main
node_frontend_app -->|"API calls"| node_backend_main
node_frontend_legacy -->|"API calls"| node_backend_main
node_backend_main -->|"bootstraps"| node_backend_core
node_backend_main -->|"loads"| node_backend_config
node_backend_main -->|"routes"| node_security_auth
node_backend_main -->|"routes"| node_user_org_domain
node_backend_main -->|"routes"| node_learning_content
node_backend_main -->|"routes"| node_knowledge_platform
node_backend_main -->|"routes"| node_ai_platform
node_backend_main -->|"routes"| node_workflow_events
node_backend_main -->|"routes"| node_integration_sap
node_backend_main -->|"routes"| node_governance_platform
node_knowledge_platform -->|"writes/reads"| node_vector_store
node_knowledge_platform -->|"stores metadata"| node_relational_db
node_knowledge_platform -->|"projects"| node_rel_graph
node_ai_platform -->|"retrieves"| node_vector_store
node_ai_platform -->|"uses graph context"| node_rel_graph
node_ai_platform -->|"trains/reads"| node_demo_corpus
node_workflow_events -->|"persists"| node_relational_db
node_integration_sap -->|"syncs"| node_relational_db
node_deploy_ci -.->|"builds"| node_backend_main
node_docs_governance -.->|"defines"| node_deploy_ci
node_docs_governance -.->|"guides"| node_backend_main
node_docs_governance -.->|"guides"| node_front1

click node_front1 "https://github.com/chirag-dhanda/jsl-contigency/tree/main/front1"
click node_frontend_app "https://github.com/chirag-dhanda/jsl-contigency/tree/main/frontend_app"
click node_frontend_legacy "https://github.com/chirag-dhanda/jsl-contigency/tree/main/frontend"
click node_backend_main "https://github.com/chirag-dhanda/jsl-contigency/blob/main/backend/main.py"
click node_backend_core "https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/core"
click node_backend_config "https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/config"
click node_security_auth "https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/auth"
click node_user_org_domain "https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/users"
click node_learning_content "https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/learning"
click node_knowledge_platform "https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/knowledge_platform"
click node_ai_platform "https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/ai_platform"
click node_workflow_events "https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/workflow_engine"
click node_integration_sap "https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/integration_platform"
click node_governance_platform "https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/governance_platform"
click node_rel_graph "https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/relationship_engine"
click node_relational_db "https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/migrations"
click node_vector_store "https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/storage/chromadb"
click node_demo_corpus "https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/storage/demo_docs"
click node_docs_governance "https://github.com/chirag-dhanda/jsl-contigency/tree/main/docs"
click node_deploy_ci "https://github.com/chirag-dhanda/jsl-contigency/blob/main/.github/workflows"

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_front1,node_frontend_app,node_frontend_legacy toneBlue
class node_backend_main,node_backend_core,node_backend_config,node_security_auth,node_user_org_domain,node_learning_content,node_knowledge_platform,node_ai_platform,node_workflow_events,node_integration_sap,node_governance_platform toneAmber
class node_rel_graph,node_relational_db,node_vector_store,node_demo_corpus toneMint
class node_docs_governance,node_deploy_ci toneRose
```

## Components

### Frontend surfaces

User-facing clients and local development mocks

- [front1](https://github.com/chirag-dhanda/jsl-contigency/tree/main/front1): React/Vite UI · Newer enterprise surface for dashboard, knowledge, workflow, and admin experiences · `front1`
- [frontend_app](https://github.com/chirag-dhanda/jsl-contigency/tree/main/frontend_app): React/JS UI · Second modern UI with specialized studio and explorer modules · `frontend_app`
- [frontend](https://github.com/chirag-dhanda/jsl-contigency/tree/main/frontend): Legacy JS UI · Older static frontend with dashboard, auth, learning, and metadata pages · `frontend`

### Backend platform

Python modular monolith and cross-cutting runtime

- [main.py](https://github.com/chirag-dhanda/jsl-contigency/blob/main/backend/main.py): Python entrypoint · Application startup and request entry boundary · `backend/main.py`
- [Core runtime](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/core): lifecycle/DI · Lifecycle, dependency injection, events, cache, and module wiring · `backend/core`
- [Config](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/config): settings modules · Central configuration and validation across environments and services · `backend/config`
- [Security & auth](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/auth): identity/rbac · Authentication, authorization, sessions, JWT, headers, rate limiting, and access control · `backend/modules/auth`
- [People domain](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/users): users/org/roles · Users, departments, roles, permissions, profiles, and access requests · `backend/modules/users`
- [Learning & content](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/learning): learning/media · Learning, lessons, progress, certificates, content, media, documents, and publishing · `backend/modules/learning`
- [Knowledge platform](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/knowledge_platform): ingest/retrieve · Document intake, parsing, chunking, metadata, retrieval, review, and studio workflows · `backend/modules/knowledge_platform`
- [AI platform](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/ai_platform): orchestrator/rag · Prompting, conversation, skills, providers, citations, observability, and model routing · `backend/modules/ai_platform`
- [Workflow events](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/workflow_engine): workflow/bus · Workflow engine, approvals, runtime tasks, automation, event bus, and notifications · `backend/modules/workflow_engine`
- [Integration layer](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/integration_platform): connectors/sync · Enterprise connectors, gateway, sync, transformation, and SAP mapping paths · `backend/modules/integration_platform`
- [Governance](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/governance_platform): policy/compliance · Classification, compliance, field security, row-level security, and audit monitoring · `backend/modules/governance_platform`

### Data layers

Relational, graph, and vector persistence

- [Relationship graph](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/modules/relationship_engine): neo4j/vector graph · Knowledge and entity relationships across graph-oriented repositories and projectors · `backend/modules/relationship_engine`
- [Relational DB](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/migrations): migrations/models · Operational schema, ORM models, migrations, and repository-backed records · `backend/migrations`
- [Vector store](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/storage/chromadb): chromadb/chunks · Embedding storage and semantic retrieval corpus · `backend/storage/chromadb`
- [Demo corpus](https://github.com/chirag-dhanda/jsl-contigency/tree/main/backend/storage/demo_docs): documents/media · Checked-in docs, manuals, SOPs, training content, and media assets used for ingestion and demos · `backend/storage/demo_docs`

### Docs and operations

Governance, standards, deployment, testing, and repository process

- [Docs & standards](https://github.com/chirag-dhanda/jsl-contigency/tree/main/docs): architecture/process · Architecture, governance, security, testing, deployment, and decision records · `docs`
- [CI/CD & deploy](https://github.com/chirag-dhanda/jsl-contigency/blob/main/.github/workflows): pipelines/containers · GitHub workflows, Docker, deployment manifests, and release tooling · `.github/workflows`

## Connections

- front1 → main.py: API calls · Primary UI consumes backend services and APIs
- frontend_app → main.py: API calls · Modern secondary UI consumes the same backend boundary
- frontend → main.py: API calls · Legacy UI also depends on backend APIs
- main.py → Core runtime: bootstraps · Entrypoint wires lifecycle, DI, cache, and event plumbing
- main.py → Config: loads · Startup resolves environment and platform configuration
- main.py → Security & auth: routes · Requests enter identity and access control modules
- main.py → People domain: routes · Core business users and organization flows
- main.py → Learning & content: routes · Learning and content capabilities
- main.py → Knowledge platform: routes · Knowledge intake, retrieval, and studio flows
- main.py → AI platform: routes · AI requests and copilot-style interactions
- main.py → Workflow events: routes · Workflow, approval, and event-driven operations
- main.py → Integration layer: routes · External enterprise synchronization and connectors
- main.py → Governance: routes · Governance and compliance enforcement
- Knowledge platform → Vector store: writes/reads · Chunking and embeddings persist to vector search
- Knowledge platform → Relational DB: stores metadata · Document, review, and ingestion state is persisted
- Knowledge platform → Relationship graph: projects · Relationship extraction feeds graph persistence
- AI platform → Vector store: retrieves · RAG and semantic context access embeddings
- AI platform → Relationship graph: uses graph context · Knowledge and entity relationships enrich prompts and answers
- AI platform → Demo corpus: trains/reads · Demo and reference corpora seed AI and knowledge flows
- Workflow events → Relational DB: persists · Workflow definitions, tasks, and notifications are stored
- Integration layer → Relational DB: syncs · Operational records and mappings sync through the main database
- CI/CD & deploy → main.py: builds · Pipelines package and validate the backend runtime
- Docs & standards → CI/CD & deploy: defines · Documentation and governance prescribe delivery process
- Docs & standards → main.py: guides · Architecture and standards shape backend structure
- Docs & standards → front1: guides · UI standards and product docs shape the frontends
