# billashiva15/nexus architecture

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

## Overview

Nexus AI is an enterprise ERP/CRM automation backend. Users reach chat, agents, analytics, workflows, and approvals through FastAPI; agent orchestration and approval-governed workflow execution support the principal operational flow. Separate branches provide RAG, ETL/analytics, and external market intelligence. Relationships reflect the sampled route, service, and engine calls plus explicit README capabilities; several feature implementations are unsampled, so those links are documented rather than inferred from imports.

Main entry points: [`backend/main.py`](https://github.com/billashiva15/nexus/blob/main/backend/main.py) (FastAPI app), [`backend/models`](https://github.com/billashiva15/nexus/tree/main/backend/models) (Workflow and approval records), [`backend/chat/chatbot_service.py`](https://github.com/billashiva15/nexus/blob/main/backend/chat/chatbot_service.py) (Chat service), [`backend/api/workflow_routes.py`](https://github.com/billashiva15/nexus/blob/main/backend/api/workflow_routes.py) (Workflow API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and interaction"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_chat_api["Chat API<br/>[chat_routes.py]"]
  node_chat["Chat service<br/>[chatbot_service.py]"]
  node_agent_api["Agent API<br/>[agent_routes.py]"]
end

subgraph group_ai["Agents and intelligence"]
  node_agent_suite["Business agents"]
  node_orchestration["Agent orchestration"]
  node_llm["LLM generation<br/>[groq_client.py]"]
  node_rag["RAG retrieval"]
  node_rag_ingest["RAG ingestion"]
  node_market_intel["Market intelligence"]
end

subgraph group_governance["Workflow governance"]
  node_workflow_api["Workflow API<br/>[workflow_routes.py]"]
  node_approval_api["Approval API<br/>[approval_routes.py]"]
  node_workflow_engine["Workflow engine<br/>[workflow_engine.py]"]
  node_approval_service["Approval service"]
end

subgraph group_data["Business data"]
  node_analytics_api["Analytics API"]
  node_analytics["ERP analytics"]
  node_etl["ETL pipeline"]
end

subgraph group_platform["Runtime services"]
  node_qdrant[("Qdrant vectors")]
  node_db[("SQL database<br/>[database.py]")]
  node_models["Workflow and approval records"]
  node_guardrails["Safety and policy<br/>[policy_engine.py]"]
  node_memory["Conversation memory"]
end

node_user(("Business user"))
node_external_news["Market sources"]

node_user -->|"uses API"| node_fastapi
node_fastapi -->|"registers route"| node_chat_api
node_fastapi -->|"registers route"| node_agent_api
node_fastapi -->|"registers route"| node_workflow_api
node_fastapi -->|"registers route"| node_approval_api
node_fastapi -->|"registers route"| node_analytics_api
node_chat_api -->|"calls chat"| node_chat
node_chat -->|"generates response"| node_llm
node_chat -->|"stores conversation"| node_memory
node_chat -.->|"checks safety"| node_guardrails
node_agent_api -->|"dispatches agent"| node_agent_suite
node_orchestration -->|"executes agent"| node_agent_suite
node_orchestration -.->|"requests review"| node_approval_service
node_rag_ingest -->|"writes vectors"| node_qdrant
node_rag -.->|"retrieves vectors"| node_qdrant
node_user -->|"queries documents"| node_rag
node_external_news -.->|"supplies signals"| node_market_intel
node_user -->|"requests insights"| node_market_intel
node_workflow_api -->|"persists workflow"| node_models
node_workflow_api -->|"checks approval"| node_models
node_approval_api -->|"updates decisions"| node_models
node_workflow_engine -->|"uses approvals"| node_approval_service
node_workflow_engine -.->|"records operations"| node_models
node_analytics_api -->|"serves metrics"| node_analytics
node_etl -->|"loads processed data"| node_db
node_analytics -.->|"reads business data"| node_db
node_db -->|"backs records"| node_models

click node_fastapi "https://github.com/billashiva15/nexus/blob/main/backend/main.py"
click node_chat_api "https://github.com/billashiva15/nexus/blob/main/backend/api/chat_routes.py"
click node_chat "https://github.com/billashiva15/nexus/blob/main/backend/chat/chatbot_service.py"
click node_agent_api "https://github.com/billashiva15/nexus/blob/main/backend/api/agent_routes.py"
click node_agent_suite "https://github.com/billashiva15/nexus/tree/main/backend/agents"
click node_orchestration "https://github.com/billashiva15/nexus/blob/main/backend/orchestration/execution_engine.py"
click node_llm "https://github.com/billashiva15/nexus/blob/main/backend/llm/groq_client.py"
click node_rag "https://github.com/billashiva15/nexus/tree/main/backend/rag"
click node_rag_ingest "https://github.com/billashiva15/nexus/blob/main/backend/rag/ingestion_pipeline.py"
click node_qdrant "https://github.com/billashiva15/nexus/blob/main/backend/rag/vector_store_qdrant.py"
click node_market_intel "https://github.com/billashiva15/nexus/tree/main/backend/external_intelligence"
click node_workflow_api "https://github.com/billashiva15/nexus/blob/main/backend/api/workflow_routes.py"
click node_approval_api "https://github.com/billashiva15/nexus/blob/main/backend/api/approval_routes.py"
click node_workflow_engine "https://github.com/billashiva15/nexus/blob/main/backend/workflows/workflow_engine.py"
click node_approval_service "https://github.com/billashiva15/nexus/blob/main/backend/workflows/approval_service.py"
click node_analytics_api "https://github.com/billashiva15/nexus/blob/main/backend/api/analytics_routes.py"
click node_analytics "https://github.com/billashiva15/nexus/tree/main/backend/analytics"
click node_etl "https://github.com/billashiva15/nexus/tree/main/backend/etl"
click node_db "https://github.com/billashiva15/nexus/blob/main/backend/database.py"
click node_models "https://github.com/billashiva15/nexus/tree/main/backend/models"
click node_guardrails "https://github.com/billashiva15/nexus/blob/main/backend/guardrails/policy_engine.py"
click node_memory "https://github.com/billashiva15/nexus/blob/main/backend/chat/conversation_manager.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_fastapi,node_chat_api,node_chat,node_agent_api,node_user toneBlue
class node_agent_suite,node_orchestration,node_llm,node_rag,node_rag_ingest,node_market_intel toneAmber
class node_workflow_api,node_approval_api,node_workflow_engine,node_approval_service toneMint
class node_analytics_api,node_analytics,node_etl toneRose
class node_qdrant,node_db,node_models,node_guardrails,node_memory,node_external_news toneIndigo
```

## Components

### API and interaction

- [FastAPI app](https://github.com/billashiva15/nexus/blob/main/backend/main.py): `backend/main.py`
- [Chat API](https://github.com/billashiva15/nexus/blob/main/backend/api/chat_routes.py): `backend/api/chat_routes.py`
- [Chat service](https://github.com/billashiva15/nexus/blob/main/backend/chat/chatbot_service.py): `backend/chat/chatbot_service.py`
- [Agent API](https://github.com/billashiva15/nexus/blob/main/backend/api/agent_routes.py): `backend/api/agent_routes.py`

### Agents and intelligence

- [Business agents](https://github.com/billashiva15/nexus/tree/main/backend/agents): `backend/agents`
- [Agent orchestration](https://github.com/billashiva15/nexus/blob/main/backend/orchestration/execution_engine.py): `backend/orchestration/execution_engine.py`
- [LLM generation](https://github.com/billashiva15/nexus/blob/main/backend/llm/groq_client.py): `backend/llm/groq_client.py`
- [RAG retrieval](https://github.com/billashiva15/nexus/tree/main/backend/rag): `backend/rag`
- [RAG ingestion](https://github.com/billashiva15/nexus/blob/main/backend/rag/ingestion_pipeline.py): `backend/rag/ingestion_pipeline.py`
- [Market intelligence](https://github.com/billashiva15/nexus/tree/main/backend/external_intelligence): `backend/external_intelligence`

### Workflow governance

- [Workflow API](https://github.com/billashiva15/nexus/blob/main/backend/api/workflow_routes.py): `backend/api/workflow_routes.py`
- [Approval API](https://github.com/billashiva15/nexus/blob/main/backend/api/approval_routes.py): `backend/api/approval_routes.py`
- [Workflow engine](https://github.com/billashiva15/nexus/blob/main/backend/workflows/workflow_engine.py): `backend/workflows/workflow_engine.py`
- [Approval service](https://github.com/billashiva15/nexus/blob/main/backend/workflows/approval_service.py): `backend/workflows/approval_service.py`

### Business data

- [Analytics API](https://github.com/billashiva15/nexus/blob/main/backend/api/analytics_routes.py): `backend/api/analytics_routes.py`
- [ERP analytics](https://github.com/billashiva15/nexus/tree/main/backend/analytics): `backend/analytics`
- [ETL pipeline](https://github.com/billashiva15/nexus/tree/main/backend/etl): `backend/etl`

### Runtime services

- [Qdrant vectors](https://github.com/billashiva15/nexus/blob/main/backend/rag/vector_store_qdrant.py): `backend/rag/vector_store_qdrant.py`
- [SQL database](https://github.com/billashiva15/nexus/blob/main/backend/database.py): `backend/database.py`
- [Workflow and approval records](https://github.com/billashiva15/nexus/tree/main/backend/models): `backend/models`
- [Safety and policy](https://github.com/billashiva15/nexus/blob/main/backend/guardrails/policy_engine.py): `backend/guardrails/policy_engine.py`
- [Conversation memory](https://github.com/billashiva15/nexus/blob/main/backend/chat/conversation_manager.py): `backend/chat/conversation_manager.py`

### Other components

- **Business user**
- **Market sources**

## Connections

- Business user → FastAPI app: uses API (evidence: `README.md`)
- FastAPI app → Chat API: registers route (evidence: `backend/main.py`)
- FastAPI app → Agent API: registers route (evidence: `backend/main.py`)
- FastAPI app → Workflow API: registers route (evidence: `backend/main.py`)
- FastAPI app → Approval API: registers route (evidence: `backend/main.py`)
- FastAPI app → Analytics API: registers route (evidence: `backend/main.py`)
- Chat API → Chat service: calls chat (evidence: `backend/api/chat_routes.py`)
- Chat service → LLM generation: generates response (evidence: `backend/chat/chatbot_service.py`)
- Chat service → Conversation memory: stores conversation (evidence: `backend/chat/chatbot_service.py`)
- Chat service → Safety and policy: checks safety
- Agent API → Business agents: dispatches agent (evidence: `backend/api/agent_routes.py`)
- Agent orchestration → Business agents: executes agent (evidence: `backend/orchestration/execution_engine.py`)
- Agent orchestration → Approval service: requests review
- RAG ingestion → Qdrant vectors: writes vectors (evidence: `backend/rag/ingestion_pipeline.py`)
- RAG retrieval → Qdrant vectors: retrieves vectors (evidence: `README.md`)
- Business user → RAG retrieval: queries documents (evidence: `README.md`)
- Market sources → Market intelligence: supplies signals (evidence: `README.md`)
- Business user → Market intelligence: requests insights (evidence: `README.md`)
- Workflow API → Workflow and approval records: persists workflow (evidence: `backend/api/workflow_routes.py`)
- Workflow API → Workflow and approval records: checks approval (evidence: `backend/api/workflow_routes.py`)
- Approval API → Workflow and approval records: updates decisions (evidence: `backend/api/approval_routes.py`)
- Workflow engine → Approval service: uses approvals (evidence: `backend/workflows/workflow_engine.py`)
- Workflow engine → Workflow and approval records: records operations
- Analytics API → ERP analytics: serves metrics (evidence: `backend/api/analytics_routes.py`)
- ETL pipeline → SQL database: loads processed data (evidence: `README.md`)
- ERP analytics → SQL database: reads business data (evidence: `README.md`)
- SQL database → Workflow and approval records: backs records (evidence: `backend/database.py`)
