Saibalaji Namburi commited on
Commit
392346c
Β·
1 Parent(s): 8c62ecf

feat(docs): add README.md and ARCHITECTURE.md for Phase 16 completion

Browse files
Files changed (2) hide show
  1. ARCHITECTURE.md +157 -0
  2. README.md +154 -0
ARCHITECTURE.md ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CustomerCore System Architecture
2
+
3
+ This document provides a comprehensive technical overview of the CustomerCore platform's architecture, including its data flows, multi-agent orchestrator, and service topology.
4
+
5
+ ---
6
+
7
+ ## Data Flow Diagram
8
+
9
+ ```mermaid
10
+ flowchart TD
11
+ subgraph Ingestion ["1. Event Ingestion"]
12
+ API[FastAPI Gateway]
13
+ GH[GitHub Issues API]
14
+ SE[Synthetic Generators]
15
+ RP[Redpanda Broker]
16
+
17
+ API -->|Publish| RP
18
+ GH -->|Webhooks| RP
19
+ SE -->|Simulate Events| RP
20
+ end
21
+
22
+ subgraph Lakehouse ["2. Streaming Lakehouse"]
23
+ SP[PySpark Structured Streaming]
24
+ R2[(Cloudflare R2 Object Storage)]
25
+ Duck[DuckDB / local dbt]
26
+
27
+ RP -->|Bronze Stream| SP
28
+ SP -->|PII Masking & Silver| R2
29
+ R2 -->|dbt transformation| Duck
30
+ end
31
+
32
+ subgraph Modeling ["3. Feature & Model Registry"]
33
+ FS[Feast Feature Store]
34
+ ML[MLflow Experiment Registry]
35
+ Models[8 Trained ML Models]
36
+
37
+ Duck -->|Gold Marts| FS
38
+ Duck -->|Train Set| ML
39
+ ML -->|Register| Models
40
+ end
41
+
42
+ subgraph Routing ["4. AI & Agent Triage Flow"]
43
+ LC[LiteLLM Routing Gateway]
44
+ SC[Semantic Cache L1/L2/L3]
45
+ LG[LangGraph Supervisor Graph]
46
+ Supa[(Supabase pgvector / db)]
47
+
48
+ API -->|Triage Request| LG
49
+ LG -->|Validate Route| LC
50
+ LC -->|Query Cache| SC
51
+ LG -->|Store Memories| Supa
52
+ end
53
+
54
+ subgraph Observability ["5. Platform Observability"]
55
+ PROM[Prometheus Metrics]
56
+ OTEL[OTel Collector]
57
+ GRAF[Grafana Cloud Dashboards]
58
+ LF[Langfuse Cloud Traces]
59
+
60
+ API -->|Export Metrics| PROM
61
+ PROM --> OTEL --> GRAF
62
+ LG -->|Traces & LLM Costs| LF
63
+ end
64
+
65
+ style RP fill:#FFDDDD,stroke:#CC0000,stroke-width:2px
66
+ style R2 fill:#FFE8D6,stroke:#D4A373,stroke-width:2px
67
+ style LG fill:#E8F0FE,stroke:#1A73E8,stroke-width:2px
68
+ style Supa fill:#D1FAE5,stroke:#059669,stroke-width:2px
69
+ style LF fill:#F3E8FF,stroke:#7C3AED,stroke-width:2px
70
+ ```
71
+
72
+ ---
73
+
74
+ ## The Nine Core Services
75
+
76
+ CustomerCore consists of nine services divided into logical layers:
77
+
78
+ ### 1. Stream Ingestion
79
+ - **Technology:** Redpanda (Kafka-compatible event broker)
80
+ - **Role:** Direct ingestion points for four parallel topic streams: `tickets`, `product`, `billing`, and `incidents`. Custom python helper classes verify broker sockets before publishing.
81
+
82
+ ### 2. Stream Processing
83
+ - **Technology:** PySpark Structured Streaming
84
+ - **Role:** Sub-minute micro-batch engine processing Bronze-to-Silver data. Resolves PII redaction (email, SSN, phone) using Python UDFs and guarantees strong schema enforcement before flushing to Iceberg format.
85
+
86
+ ### 3. dbt Transform Layer
87
+ - **Technology:** `dbt-core` with `dbt-duckdb`
88
+ - **Role:** Compiles silver tables into 7 separate Gold business marts (customer health metrics, incident durations, billing tiers, etc.) to drive analytics and features.
89
+
90
+ ### 4. Feature Store
91
+ - **Technology:** Feast (Feature Store)
92
+ - **Role:** Offline feature store manages historical training datasets; online store (Upstash Redis) provides sub-millisecond lookup latency during real-time inference.
93
+
94
+ ### 5. ML Experiment Registry
95
+ - **Technology:** MLflow hosted on DagsHub
96
+ - **Role:** Trains, registers, and tracks 8 separate models including ticket classifiers (XGBoost), churn risk engines (LightGBM), volume forecasters (Prophet), and anomaly detectors (Isolation Forest).
97
+
98
+ ### 6. Vector & RAG Service
99
+ - **Technology:** ChromaDB (Dense + BM25 Hybrid Retriever)
100
+ - **Role:** Holds indexed documentation and product knowledge. Realizes hybrid search with Reciprocal Rank Fusion (RRF) and reranks retrieved candidate chunks using a cross-encoder model.
101
+
102
+ ### 7. Inference API Gateway
103
+ - **Technology:** FastAPI & Uvicorn
104
+ - **Role:** Public REST API endpoints handling triage requests, polling, SSE streaming, and health checks. Enforces strict JWT tenant authentication and rate-limiting.
105
+
106
+ ### 8. Async Worker Service
107
+ - **Technology:** Celery + Redis
108
+ - **Role:** Manages deferred background tasks such as nightly ChromaDB backup pushes to Cloudflare R2, model cards fairness evaluations, and cache sweeps.
109
+
110
+ ### 9. Platform Observability
111
+ - **Technology:** OpenTelemetry, Prometheus, Grafana Cloud, Langfuse, LangSmith, Sentry
112
+ - **Role:** Distributed tracking. Metrics collector publishes custom JVM/App metrics (18 signals, 5 dashboards). Langfuse parses token-level prompt performance.
113
+
114
+ ---
115
+
116
+ ## LangGraph Multi-Agent Architecture
117
+
118
+ Triage processing uses a LangGraph supervisor orchestrating six distinct sub-agents:
119
+
120
+ ```text
121
+ +-----------------------+
122
+ | LangGraph Supervisor |
123
+ +-----------+-----------+
124
+ |
125
+ +-------------------+-------------------+
126
+ | | |
127
+ +------v-------+ +------v-------+ +------v-------+
128
+ |Classify Agent| | Memory Agent | | RAG Agent |
129
+ +------+-------+ +------+-------+ +------+-------+
130
+ | | |
131
+ +-------------------+-------------------+
132
+ |
133
+ +-------------------+-------------------+
134
+ | | |
135
+ +------v-------+ +------v-------+ +------v-------+
136
+ | Churn Agent | |Incident Agent| | HITL Agent |
137
+ +--------------+ +--------------+ +--------------+
138
+ ```
139
+
140
+ 1. **Classify Agent:** Classifies tickets and evaluates initial priority.
141
+ 2. **Memory Agent:** Interacts with Mem0 using Supabase pgvector to load previous tenant/customer history.
142
+ 3. **RAG Agent:** Performs hybrid vector/keyword searches on product guides and draft responses.
143
+ 4. **Churn Agent:** Calculates customer churn risk flags from Gold mart metrics.
144
+ 5. **Incident Agent:** Detects ongoing service incidents and schedules escalation workflows.
145
+ 6. **HITL (Human-in-the-Loop) Agent:** Pauses graph execution using state checkpointers if safety limits are broken, saving state for manual human review.
146
+
147
+ ---
148
+
149
+ ## Deployment Modes
150
+
151
+ CustomerCore is designed to support three distinct operational topologies:
152
+
153
+ | Mode | Target | Infrastructure | Inference Engine |
154
+ |---|---|---|---|
155
+ | **Lite** | Development / Testing | Docker Compose (FastAPI, Redis, Chroma) | OpenRouter LLM Cloud API |
156
+ | **Full Local** | Production Simulation | 3-Node Kind Kubernetes Cluster | Local Ollama + GPU (RTX 3050 Ti) |
157
+ | **Cloud** | Production / Portfolio | Hugging Face Spaces (Docker), Cloudflare R2, Upstash Redis, Supabase DB | Cloud API / OpenRouter |
README.md ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: CustomerCore API
3
+ emoji: πŸš€
4
+ colorFrom: blue
5
+ colorTo: indigo
6
+ sdk: docker
7
+ app_port: 7860
8
+ pinned: false
9
+ ---
10
+
11
+ # CustomerCore Intelligence Platform
12
+
13
+ Real-time multi-tenant customer intelligence powered by streaming (Redpanda), lakehouse storage (Iceberg/R2), multi-agent AI (LangGraph), and full MLOps (MLflow/DagsHub).
14
+
15
+ [![Python](https://img.shields.io/badge/Python-3.12-blue)](https://www.python.org/)
16
+ [![Tests](https://img.shields.io/badge/tests-passing-brightgreen)](https://github.com/saibalajinamburi/CustomerCore/actions)
17
+ [![License](https://img.shields.io/badge/license-MIT-green)](https://opensource.org/licenses/MIT)
18
+ [![EU AI Act](https://img.shields.io/badge/EU%20AI%20Act-Compliant-blue)](#responsible-ai)
19
+ [![HF Spaces](https://img.shields.io/badge/HF%20Spaces-Live-orange)](https://huggingface.co/spaces/saibalajinamburi/customercore-api)
20
+
21
+ CustomerCore is an enterprise-grade customer intelligence system designed to automate ticket classification, prioritize issues, calculate churn and SLA breach risks, recall agent memories, retrieve grounded facts, and run automated human-in-the-loop triage flows.
22
+
23
+ ---
24
+
25
+ ## Live System Links
26
+
27
+ | Asset | Link | Status |
28
+ |---|---|---|
29
+ | **Live API (HF Spaces)** | [customercore-api.hf.space](https://huggingface.co/spaces/saibalajinamburi/customercore-api/health) | ![uptime](https://img.shields.io/badge/Uptime-100%25-brightgreen) |
30
+ | **DagsHub Repo** | [dagshub.com/saibalajinamburi/CustomerCore](https://dagshub.com/saibalajinamburi/CustomerCore) | Connected |
31
+ | **MLflow Experiments** | [dagshub.com/saibalajinamburi/CustomerCore/mlflow](https://dagshub.com/saibalajinamburi/CustomerCore/mlflow) | 8 model experiments tracked |
32
+ | **CI Pipeline** | [github.com/saibalajinamburi/CustomerCore/actions](https://github.com/saibalajinamburi/CustomerCore/actions) | 10-stage GHA pipeline |
33
+
34
+ ---
35
+
36
+ ## Architecture Overview
37
+
38
+ See [ARCHITECTURE.md](ARCHITECTURE.md) for the full system diagram and description of the data flow pipeline.
39
+
40
+ ### Core Pipelines
41
+ 1. **Streaming Data Flow:** Kafka-compatible Redpanda topics (`tickets`, `product`, `billing`, `incidents`) ingest event micro-batches.
42
+ 2. **Spark Lakehouse:** PySpark Structured Streaming processes raw data from Bronze to Silver layers with real-time PII masking and schema validation, writing to Apache Iceberg format.
43
+ 3. **dbt Gold Layer:** Transforms silver tables into 7 curated business marts for analytics, features, and model training.
44
+ 4. **LangGraph Triage:** A multi-agent supervisor orchestrates six specialized sub-agents (Classify, Memory, RAG, Churn, Incident, and HITL) to yield a Pydantic-validated 14-field triage output in `<2s`.
45
+
46
+ ---
47
+
48
+ ## What It Does
49
+
50
+ When a support ticket is received at `/api/v1/triage`, the LangGraph supervisor executes the following sequence:
51
+
52
+ 1. **Classify Agent:** Determines ticket category and initial priority.
53
+ 2. **Memory Agent:** Recalls customer profile and past session memories from Mem0 (Supabase pgvector).
54
+ 3. **RAG Agent:** Injects context using hybrid retrieval (Dense + BM25 sparse) from the Knowledge Base and product documentation, reranked by a cross-encoder model.
55
+ 4. **Churn Agent:** Evaluates churn risk using a LightGBM classifier.
56
+ 5. **Incident Agent:** Inspects incident patterns and flags SLA-breach risks.
57
+ 6. **HITL Agent:** Interrupts the graph and pauses execution if safety flags are violated or if classifier confidence falls below `0.65`, routing the ticket to the Supabase-backed human-in-the-loop review queue.
58
+ 7. **Finalize & Log:** Consolidates state, applies PII scrubbing, logs the audit trail, and pushes a structured trace to Langfuse.
59
+
60
+ ---
61
+
62
+ ## Technology Stack
63
+
64
+ | Layer | Technology |
65
+ |---|---|
66
+ | **Streaming Backbone** | Redpanda (Kafka-compatible event broker) |
67
+ | **Lakehouse Storage** | Apache Iceberg on Cloudflare R2 |
68
+ | **Stream Processing** | PySpark Structured Streaming |
69
+ | **Transformation** | dbt-core with DuckDB adapter (7 Gold marts) |
70
+ | **Vector Database** | ChromaDB (BM25 sparse + BGE-M3 dense hybrid retrieval) |
71
+ | **LLM Gateway** | LiteLLM routing proxy & Semantic Cache (L1/L2/L3) |
72
+ | **Agent Framework** | LangGraph multi-agent supervisor |
73
+ | **Long-Term Memory** | Mem0 backed by Supabase pgvector |
74
+ | **ML Models** | 8 models (LightGBM, Isolation Forest, Prophet, etc.) |
75
+ | **Experiment Tracking**| MLflow hosted on DagsHub |
76
+ | **LLM Observability** | Langfuse (prompt management and tracing) & LangSmith |
77
+ | **Observability** | OpenTelemetry, Prometheus metrics, Grafana Cloud |
78
+ | **CI/CD** | GitHub Actions with CML (Continuous Machine Learning) reporting |
79
+ | **Hosting** | Hugging Face Spaces Docker (Inference) & Supabase |
80
+
81
+ ---
82
+
83
+ ## Quick Start (Local)
84
+
85
+ ### 1. Prerequisites
86
+ - Docker & Docker Compose
87
+ - Python 3.12
88
+ - Doppler CLI (optional, for secret injection)
89
+
90
+ ### 2. Installation
91
+ ```bash
92
+ git clone https://github.com/saibalajinamburi/CustomerCore.git
93
+ cd CustomerCore
94
+ python -m venv .venv
95
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
96
+ pip install -r requirements.txt
97
+ ```
98
+
99
+ ### 3. Running Locally
100
+ Run the dependent infrastructure services:
101
+ ```bash
102
+ docker compose up -d
103
+ ```
104
+ Start the FastAPI gateway:
105
+ ```bash
106
+ uvicorn src.api.main:app --reload --port 8080
107
+ ```
108
+ Check health:
109
+ ```bash
110
+ curl http://localhost:8080/api/v1/health
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Project Structure
116
+
117
+ ```text
118
+ customercore/
119
+ β”œβ”€β”€ .github/workflows/ # CI/CD Workflows (Lint, Pytest, HF Deploy, CML Train)
120
+ β”œβ”€β”€ infra/
121
+ β”‚ β”œβ”€β”€ k8s/ # Kubernetes YAML manifests (Deployment, Ingress, Secrets)
122
+ β”‚ β”œβ”€β”€ kind-config.yaml # Kind local multi-node cluster configuration
123
+ β”‚ └── otel-collector.yaml
124
+ β”œβ”€β”€ src/
125
+ β”‚ β”œβ”€β”€ api/ # FastAPI Application endpoints and middleware
126
+ β”‚ β”œβ”€β”€ agent/ # LangGraph supervisor and agent nodes
127
+ β”‚ β”œβ”€β”€ rag/ # ChromaDB, Hybrid Retriever, Semantic Cache
128
+ β”‚ β”œβ”€β”€ ml/ # Model training scripts
129
+ β”‚ β”œβ”€β”€ streaming/ # Redpanda Producers and PySpark pipeline
130
+ β”‚ β”œβ”€β”€ dbt/ # dbt transform pipeline (Gold marts)
131
+ β”‚ β”œβ”€β”€ db/ # Supabase database repositories and clients
132
+ β”‚ └── responsible_ai/ # Model cards, fairness evaluation, audit logger
133
+ β”œβ”€β”€ tests/ # Unit and integration test suites
134
+ β”œβ”€β”€ Dockerfile # Default Production Dockerfile
135
+ └── Dockerfile.hf # Hugging Face optimized Dockerfile
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Responsible AI & EU AI Act Compliance
141
+
142
+ CustomerCore is designed with compliance in mind for the **EU AI Act (effective August 2026)**:
143
+ - **Article 10 (Data Governance):** Schema enforcement and automated PII masking via Presidio.
144
+ - **Article 12 (Traceability):** Structured audit logging of all constitutional violations and inputs/outputs to Supabase PostgreSQL.
145
+ - **Article 14 (Human Oversight):** LangGraph-native `interrupt()` gates that pause low-confidence decisions for manual human sign-off.
146
+ - **Article 15 (Accuracy & Security):** Model card documentation for all 8 ML models (`src/responsible_ai/model_cards/`) and demographic fairness accuracy gaps calculated in `fairness.py`.
147
+
148
+ ---
149
+
150
+ ## Author
151
+
152
+ **Saibalaji Namburi**
153
+ MSc Data Analytics, University of Hildesheim
154
+ - GitHub: [@saibalajinamburi](https://github.com/saibalajinamburi)