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|
| 8 |
+

|
| 9 |
+

|
| 10 |
+

|
| 11 |
+
|
| 12 |
+
An enterprise-grade, multi-agent AI automation platform built with **LangGraph**, **FastAPI**, **React 18**, **Qdrant Vector Database**, and **PostgreSQL**. Features hybrid RAG search, natural language SQL generation, automated analytics, real-time web search, multi-tenant RBAC security, and a full ChatGPT-style streaming UI.
|
| 13 |
+
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
## π Key Architecture & Capabilities
|
| 17 |
+
|
| 18 |
+
### π€ 1. LangGraph Multi-Agent Suite
|
| 19 |
+
Powered by a **Supervisor Planner Node** that dynamically routes incoming queries to specialized agents:
|
| 20 |
+
- π **Retrieval Specialist (Hybrid RAG)**: Performs dense vector search in Qdrant with CrossEncoder reranking (`ms-marco-MiniLM-L-6-v2`).
|
| 21 |
+
- ποΈ **SQL Intelligence Agent**: Generates safe SQL queries validated by an AST parser that blocks destructive DML/DDL commands.
|
| 22 |
+
- π **Analytics Specialist**: Generates structured metrics and dynamic chart visualizations (Recharts).
|
| 23 |
+
- π» **Code Specialist**: Writes, explains, and debugs code snippets with markdown formatting.
|
| 24 |
+
- π **Web Search Specialist**: Fetches real-time online data via DuckDuckGo integration.
|
| 25 |
+
- π¬ **Direct Response Synthesizer**: Handles conversational queries and synthesizes grounded answers with page-level citations.
|
| 26 |
+
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
### π¬ 2. ChatGPT-Style Frontend Interface
|
| 30 |
+
- **Persistent Conversation Memory**: Sessions and multi-turn chat history stored in PostgreSQL/SQLite.
|
| 31 |
+
- **Left Sidebar Navigation**: Grouped conversation threads (*Today*, *Yesterday*, *Previous*) with instant session switching and deletion.
|
| 32 |
+
- **Live Response Streaming**: Server-Sent Events (SSE) token streaming with word-by-word typing animation.
|
| 33 |
+
- **1-Click Document Chat**: Ask questions about any uploaded document directly from the Documents dashboard.
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
### π 3. Enterprise Security & Multi-Tenant RBAC
|
| 38 |
+
- **Tenant Isolation**: Every database record and vector payload is strictly tagged and filtered by `tenant_id`.
|
| 39 |
+
- **Role-Based Access Control**:
|
| 40 |
+
- π `admin`: Full platform control, user invitations, system audit logs, all document categories.
|
| 41 |
+
- π `hr`: Access restricted to HR handbooks and policy documents.
|
| 42 |
+
- π° `finance`: Access restricted to financial statements and sales metrics.
|
| 43 |
+
- π€ `employee`: General knowledge base search with upload restriction safeguards.
|
| 44 |
+
|
| 45 |
+
---
|
| 46 |
+
|
| 47 |
+
### π 4. Observability & Monitoring
|
| 48 |
+
- **Structured Audit Traces**: Every agent execution is logged in PostgreSQL with tokens used, routing decision, and latency in milliseconds.
|
| 49 |
+
- **Metrics Dashboard**: Integrated **Prometheus** metrics exporter and **Grafana** dashboard monitoring container health and request volume.
|
| 50 |
+
|
| 51 |
+
---
|
| 52 |
+
|
| 53 |
+
## π Multi-Agent Flow Diagram
|
| 54 |
+
|
| 55 |
+
```mermaid
|
| 56 |
+
graph TD
|
| 57 |
+
A[User Query] --> B[Supervisor Planner Node]
|
| 58 |
+
B -->|routing == retrieval| C[RAG Retrieval Agent + Qdrant + Reranker]
|
| 59 |
+
B -->|routing == sql| D[SQL Agent + AST Safety Validator]
|
| 60 |
+
B -->|routing == analytics| E[Analytics Agent + Chart Generator]
|
| 61 |
+
B -->|routing == code| F[Code Specialist Agent]
|
| 62 |
+
B -->|routing == web| G[Web Search Agent + DuckDuckGo]
|
| 63 |
+
B -->|routing == direct| H[Direct Conversational Handler]
|
| 64 |
+
C --> I[Response Synthesizer Node]
|
| 65 |
+
D --> I
|
| 66 |
+
E --> I
|
| 67 |
+
F --> I
|
| 68 |
+
G --> I
|
| 69 |
+
H --> I
|
| 70 |
+
I --> J[Streaming SSE Output + Citation Metadata]
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
---
|
| 74 |
+
|
| 75 |
+
## βοΈ Microservice Architecture
|
| 76 |
+
|
| 77 |
+
The platform runs 10 microservices orchestrated via Docker Compose:
|
| 78 |
+
|
| 79 |
+
| Container | Service | Tech Stack | Port |
|
| 80 |
+
| :--- | :--- | :--- | :--- |
|
| 81 |
+
| `copilot_frontend` | Frontend UI | React 18, TypeScript, TailwindCSS, Vite | `:3000` |
|
| 82 |
+
| `copilot_backend` | Core API & Agents | FastAPI, LangGraph, SQLAlchemy, Uvicorn | `:8000` |
|
| 83 |
+
| `copilot_postgres` | Primary Database | PostgreSQL 16 | `:5432` |
|
| 84 |
+
| `copilot_qdrant` | Vector Database | Qdrant v1.12 | `:6333` |
|
| 85 |
+
| `copilot_redis` | Cache & Broker | Redis 7 | `:6379` |
|
| 86 |
+
| `copilot_celery` | Task Worker | Celery | Background |
|
| 87 |
+
| `copilot_nginx` | Reverse Proxy | Nginx Alpine | `:8080` |
|
| 88 |
+
| `copilot_prometheus`| Metrics Collector| Prometheus | `:9090` |
|
| 89 |
+
| `copilot_grafana` | Monitoring Dashboard| Grafana | `:3001` |
|
| 90 |
+
|
| 91 |
+
---
|
| 92 |
+
|
| 93 |
+
## β‘ Quick Start (Local Docker Setup)
|
| 94 |
+
|
| 95 |
+
### 1. Clone & Setup Environment
|
| 96 |
+
```bash
|
| 97 |
+
git clone https://github.com/purityadav2/Enterprise-AI-Copilot.git
|
| 98 |
+
cd Enterprise-AI-Copilot
|
| 99 |
+
|
| 100 |
+
# Copy sample environment configuration
|
| 101 |
+
cp .env.example .env
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
### 2. Launch All Microservices
|
| 105 |
+
```bash
|
| 106 |
+
docker compose -f docker/docker-compose.yml up -d
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
### 3. Open the App in Your Browser
|
| 110 |
+
- **Frontend App**: [http://localhost:3000](http://localhost:3000)
|
| 111 |
+
- **FastAPI Swagger Docs**: [http://localhost:8000/docs](http://localhost:8000/docs)
|
| 112 |
+
- **Grafana Monitoring**: [http://localhost:3001](http://localhost:3001)
|
| 113 |
+
|
| 114 |
+
### 4. Default Seed Credentials
|
| 115 |
+
- **Email**: `admin@company.com`
|
| 116 |
+
- **Password**: `Admin@123!`
|
| 117 |
+
|
| 118 |
+
---
|
| 119 |
+
|
| 120 |
+
## π§ͺ Running Automated Tests
|
| 121 |
+
|
| 122 |
+
Run the full pytest suite inside the backend container (24/24 unit & end-to-end tests passing):
|
| 123 |
+
|
| 124 |
+
```bash
|
| 125 |
+
docker compose -f docker/docker-compose.yml exec backend sh -c "cd /tests && pytest -v"
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
---
|
| 129 |
+
|
| 130 |
+
## π Free Deployment on Hugging Face Spaces
|
| 131 |
+
|
| 132 |
+
This project includes a single-container [`Dockerfile`](Dockerfile) pre-configured for free deployment on **Hugging Face Spaces**:
|
| 133 |
+
|
| 134 |
+
1. Create a Space on [huggingface.co/new-space](https://huggingface.co/new-space) using **Docker SDK (Blank)**.
|
| 135 |
+
2. Add `GROQ_API_KEY` and `SECRET_KEY` in **Space Settings β Secrets**.
|
| 136 |
+
3. Push to Hugging Face:
|
| 137 |
+
```bash
|
| 138 |
+
git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/Enterprise-AI-Copilot
|
| 139 |
+
git push hf main --force
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
---
|
| 143 |
+
|
| 144 |
+
## π License
|
| 145 |
+
Distributed under the MIT License. See `LICENSE` for more information.
|