# ramprakash-munugapati/ragram_enterprise architecture

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

- Interactive diagram: https://gitdiagram.com/ramprakash-munugapati/ragram_enterprise
- Repository: https://github.com/ramprakash-munugapati/ragram_enterprise

## Overview

RAGRAM Enterprise turns user questions into structured queries, retrieves matching documents, grades the context, and synthesizes an answer, retrying with a rewritten query when needed. Separately, a sync worker polls CDC events, derives text and embeddings, and upserts documents into the database. The CLI assembles and runs these components; the Python API also exposes the workflow directly. Several internal implementations are in omitted source excerpts, so those relationships are included only where the README documents them.

Main entry points: [`RagramEnterpriseEngine.py`](https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py) (EnterpriseAgentWorkflow), [`cli.py`](https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/cli.py) (CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["CLI<br/>[cli.py]"]
end

subgraph group_ingest["Ingestion and storage"]
  node_config["EnterpriseConfig"]
  node_engine["PostgresEngine"]
  node_database[("Relational and vector store")]
  node_cdc[("CDC events")]
  node_sync["RealTimeSyncWorker"]
  node_embed["Embedding generation"]
end

subgraph group_query["Query and retrieval"]
  node_router["QueryRouter"]
  node_structured["Structured query parsing"]
  node_search["Vector and metadata search"]
end

subgraph group_answer["Answer workflow"]
  node_workflow["EnterpriseAgentWorkflow"]
  node_grader["Context grader"]
  node_rewrite["Query rewrite"]
  node_synth["Factual synthesizer"]
  node_result["Answer and missing info"]
end

node_user(("User"))

node_user -->|"runs"| node_cli
node_user -->|"queries via API"| node_workflow
node_cli -->|"configures"| node_config
node_cli -->|"creates"| node_engine
node_cli -->|"starts"| node_sync
node_cli -->|"creates"| node_router
node_cli -->|"runs"| node_workflow
node_config -->|"configures"| node_engine
node_cdc -->|"provides events"| node_sync
node_sync -->|"computes"| node_embed
node_sync -->|"upserts documents"| node_engine
node_engine -->|"stores documents"| node_database
node_engine -->|"polls events"| node_cdc
node_workflow -->|"routes query"| node_router
node_router -->|"parses query"| node_structured
node_workflow -->|"retrieves context"| node_search
node_search -->|"searches documents"| node_engine
node_workflow -->|"grades context"| node_grader
node_workflow -->|"rewrites on failure"| node_rewrite
node_workflow -->|"synthesizes context"| node_synth
node_synth -->|"returns answer"| node_result

click node_cli "https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/cli.py"
click node_config "https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py"
click node_engine "https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py"
click node_sync "https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py"
click node_embed "https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py"
click node_workflow "https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py"
click node_router "https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py"
click node_structured "https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py"
click node_search "https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py"
click node_grader "https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py"
click node_rewrite "https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py"
click node_synth "https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.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_cli,node_user toneBlue
class node_config,node_engine,node_database,node_cdc,node_sync,node_embed toneAmber
class node_router,node_structured,node_search toneMint
class node_workflow,node_grader,node_rewrite,node_synth,node_result toneRose
```

## Components

### Entry points

- [CLI](https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/cli.py): `cli.py`

### Ingestion and storage

- [EnterpriseConfig](https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py): `RagramEnterpriseEngine.py`
- [PostgresEngine](https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py): `RagramEnterpriseEngine.py`
- **Relational and vector store**
- **CDC events**
- [RealTimeSyncWorker](https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py): `RagramEnterpriseEngine.py`
- [Embedding generation](https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py): `RagramEnterpriseEngine.py`

### Query and retrieval

- [QueryRouter](https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py): `RagramEnterpriseEngine.py`
- [Structured query parsing](https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py): `RagramEnterpriseEngine.py`
- [Vector and metadata search](https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py): `RagramEnterpriseEngine.py`

### Answer workflow

- [EnterpriseAgentWorkflow](https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py): `RagramEnterpriseEngine.py`
- [Context grader](https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py): `RagramEnterpriseEngine.py`
- [Query rewrite](https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py): `RagramEnterpriseEngine.py`
- [Factual synthesizer](https://github.com/ramprakash-munugapati/ragram_enterprise/blob/main/RagramEnterpriseEngine.py): `RagramEnterpriseEngine.py`
- **Answer and missing info**

### Other components

- **User**

## Connections

- User → CLI: runs (evidence: `README.md`)
- User → EnterpriseAgentWorkflow: queries via API (evidence: `README.md`)
- CLI → EnterpriseConfig: configures (evidence: `cli.py`)
- CLI → PostgresEngine: creates (evidence: `cli.py`)
- CLI → RealTimeSyncWorker: starts (evidence: `cli.py`)
- CLI → QueryRouter: creates (evidence: `cli.py`)
- CLI → EnterpriseAgentWorkflow: runs (evidence: `cli.py`)
- EnterpriseConfig → PostgresEngine: configures (evidence: `cli.py`)
- CDC events → RealTimeSyncWorker: provides events (evidence: `README.md`)
- RealTimeSyncWorker → Embedding generation: computes (evidence: `RagramEnterpriseEngine.py`)
- RealTimeSyncWorker → PostgresEngine: upserts documents (evidence: `RagramEnterpriseEngine.py`)
- PostgresEngine → Relational and vector store: stores documents (evidence: `README.md`)
- PostgresEngine → CDC events: polls events (evidence: `README.md`)
- EnterpriseAgentWorkflow → QueryRouter: routes query (evidence: `RagramEnterpriseEngine.py`)
- QueryRouter → Structured query parsing: parses query (evidence: `RagramEnterpriseEngine.py`)
- EnterpriseAgentWorkflow → Vector and metadata search: retrieves context (evidence: `RagramEnterpriseEngine.py`)
- Vector and metadata search → PostgresEngine: searches documents (evidence: `README.md`)
- EnterpriseAgentWorkflow → Context grader: grades context (evidence: `RagramEnterpriseEngine.py`)
- EnterpriseAgentWorkflow → Query rewrite: rewrites on failure (evidence: `README.md`)
- EnterpriseAgentWorkflow → Factual synthesizer: synthesizes context (evidence: `RagramEnterpriseEngine.py`)
- Factual synthesizer → Answer and missing info: returns answer (evidence: `README.md`)
