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