Spaces:
Paused

miracle / README.md
dushyantsingh0
backend
2fd20f1
|
Raw History Blame Contribute Delete
4.94 kB
---
title: Nexus
emoji: πŸš€
colorFrom: blue
colorTo: indigo
sdk: docker
app_port: 7860
pinned: false
---
# Nexus β€” AI-Powered Customer Support Platform
Nexus is a production-grade, multi-tenant customer support platform with an embedded AI agent layer. It combines a FastAPI backend, a React frontend, PostgreSQL with pgvector semantic search, and LangGraph-powered agents into a single deployable unit.
**Live demo:** [https://3scerror404-nexus.hf.space/](https://3scerror404-nexus.hf.space/)
**API docs:** [https://3scerror404-nexus.hf.space/docs](https://3scerror404-nexus.hf.space/docs)
---
## What it does
- **Ticket management** β€” Multi-workspace support ticket lifecycle (OPEN β†’ ACKNOWLEDGED β†’ IN_PROGRESS β†’ RESOLVED β†’ CLOSED) with priorities P0–P3 and SLA enforcement.
- **AI master agent (Nexus)** β€” Natural language workspace queries via a LangGraph agent that routes to knowledge base search, ticket operations, analytics, and remediation nodes.
- **Semantic search** β€” Hybrid search over tickets and KB articles: pgvector HNSW similarity + PostgreSQL full-text (TSVECTOR/GIN).
- **Real-time updates** β€” WebSocket pub/sub (Redis-backed) broadcasts ticket changes, new messages, and SLA alerts to connected clients.
- **Background AI workers** β€” ARQ heavy lane runs auto-summarization, KB embedding/chunking, memory crystallization, and workspace insight generation.
- **Multi-workspace RBAC** β€” Six roles (SUPERADMIN, SC_ADMIN, SC_LEAD, SC_AGENT, CUSTOMER_ADMIN, CUSTOMER_USER) with per-workspace role overrides.
---
## Repository layout
```
Hackathon/
β”œβ”€β”€ main.py # FastAPI application entry point
β”œβ”€β”€ nexus_worker.py # ARQ worker definitions (regular + heavy lanes)
β”œβ”€β”€ Dockerfile # Multi-stage production image
β”œβ”€β”€ alembic/ # Database migrations
β”œβ”€β”€ api/v1/ # HTTP route handlers (20 modules)
β”œβ”€β”€ agents/ # LangGraph agent graphs, nodes, and tools
β”œβ”€β”€ core/ # Config, auth, DB engine, cache, websockets, RBAC
β”œβ”€β”€ models/ # SQLAlchemy ORM models (30 entities)
β”œβ”€β”€ schemas/ # Pydantic request/response schemas
β”œβ”€β”€ services/ # Business logic layer
β”œβ”€β”€ tasks/ # ARQ background job definitions
β”œβ”€β”€ scripts/ # Dev and production helper scripts
β”œβ”€β”€ docs/ # Full documentation
└── frontend/
β”œβ”€β”€ apps/customer/ # Customer-facing portal (React + Vite)
β”œβ”€β”€ apps/internal/ # Internal ops console (React + Vite)
└── packages/shared/ # Shared components and hooks
```
---
## Tech stack
| Layer | Technology |
|---|---|
| API framework | FastAPI 0.115 + Uvicorn / Gunicorn |
| Database | PostgreSQL (Supabase/Neon in cloud) |
| ORM | SQLAlchemy 2.0 async + asyncpg |
| Vector search | pgvector (HNSW index, 768-dim embeddings) |
| Cache / pub-sub | Redis (Upstash in cloud, local Redis in dev) |
| Job queue | ARQ (dual worker lanes) |
| AI orchestration | LangGraph 0.2 + LangChain 0.3 |
| LLM providers | Anthropic Claude (primary), Ollama (local/embeddings), Google Gemini |
| Frontend | React 19 + TypeScript 5 + Vite 8 |
| Email | Resend |
| Observability | OpenTelemetry (OTLP exporter) |
| Container | Docker (multi-stage build) |
---
## Quick start
```bash
# 1. Copy and configure environment
cp .env.example .env # fill in DATABASE_URL, REDIS_URL, ANTHROPIC_API_KEY, etc.
# 2a. Docker (recommended β€” matches production)
./scripts/start_local.bat # Windows one-click
# or: docker compose -f compose.example.yml up
# 2b. Manual (no Docker)
uvicorn main:app --reload # API on :8000
arq nexus_worker.RegularWorkerSettings &
arq nexus_worker.HeavyWorkerSettings &
npm run dev -w frontend/apps/customer # customer portal
npm run dev -w frontend/apps/internal # internal portal
# 3. Run migrations (first time or after schema changes)
alembic upgrade head
```
---
## Documentation
| Doc | Contents |
|---|---|
| [Architecture](docs/architecture.md) | System design, data flow, caching layers, WebSocket pub/sub |
| [API Reference](docs/api.md) | All HTTP and WebSocket endpoints with parameters and response shapes |
| [AI Agents](docs/agents.md) | LangGraph agent graphs, tools, RBAC output masking |
| [Development](docs/development.md) | Environment variables, local setup, migrations, testing |
| [Deployment](docs/deployment.md) | Docker build, Hugging Face Spaces, Railway failover |
| [Backend Insights](docs/backend_insights/) | 15 deep-dive technical design docs |
---
## Deployment tiers
| Tier | Target | When |
|---|---|---|
| Primary | Hugging Face Spaces (Docker) | All production traffic |
| Failover | Railway (auto-detects `railway.json`) | HF Spaces outage |
| Local | Docker or bare processes | Development |