PHANTOM - Development Guide for Claude
Living Machine Learning Framework - Production-grade document intelligence, RAG pipeline, and AI classification system.
Version: 0.0.1 (Pre-Alpha) Python: 3.11+ License: Apache-2.0 Last Updated: 2026-03-26
π Table of Contentsβ
- Project Overview
- Current State Assessment
- Architecture Quick Reference
- Development Priorities
- Quality Assessment
- Frontend-Backend Integration
- Key Files Reference
- Testing Strategy
- Common Tasks
- Known Issues & TODOs
π― Project Overviewβ
What is Phantom?β
Phantom is a local-first AI document intelligence framework that processes unstructured documents into actionable intelligence using:
- CORTEX Engine: Semantic chunking, parallel LLM classification, insight extraction
- RAG Pipeline: FAISS vector indexing with sentence-transformers embeddings
- Multi-Interface: CLI (Typer), REST API (FastAPI), Desktop UI (Tauri + SvelteKit)
- Production-Ready: VRAM monitoring, auto-throttling, thread pool concurrency, Prometheus metrics
- Fully Reproducible: Nix flake with locked dependencies
Core Capabilitiesβ
- Document Processing: Extract insights from markdown, text, PDFs
- Vector Search: Semantic search over document embeddings (FAISS)
- Classification: Multi-threaded LLM-based document classification
- Sentiment Analysis: NLTK VADER + optional spaCy NER
- RAG Pipeline: Question-answering over knowledge base
- Resource Management: Real-time VRAM/RAM monitoring with auto-throttling
Tech Stackβ
- Backend: Python 3.11+, FastAPI, Pydantic 2.0
- Frontend: Tauri 2.0, SvelteKit, Svelte 5, Tailwind CSS
- ML/NLP: sentence-transformers, FAISS, NLTK, scikit-learn, tiktoken
- Inference: llama.cpp (local, OpenAI-compatible API)
- Agent: Rust (Crane build system, multi-crate workspace)
- DevOps: Nix flake, GitHub Actions (8 workflows), pre-commit hooks
- Observability: structlog, Prometheus metrics
π Current State Assessmentβ
β Production-Ready Componentsβ
| Component | Status | Files | Test Coverage |
|---|---|---|---|
| CORTEX Processor | β Complete | core/cortex.py | High |
| Semantic Chunker | β Complete | core/cortex.py | High |
| FAISS Vector Store | β Complete | rag/vectors.py | High |
| Sentiment Engine | β Complete | analysis/sentiment.py | High |
| Embedding Generator | β Complete | core/embeddings.py | Medium |
| LlamaCpp Provider | β Complete | providers/llamacpp.py | Medium |
| FastAPI Server | β Complete | api/app.py | High |
| Prometheus Metrics | β Complete | api/app.py | High |
| Pydantic Schemas | β Complete | All modules | High |
| CI/CD Pipelines | β Complete | .github/workflows/ | N/A |
| Nix Environment | β Complete | flake.nix | N/A |
| CLI Commands | β Complete | cli/main.py | Medium |
| RAG Query API | β Complete | api/app.py | High |
| Document Upload | β Complete | api/app.py | High |
| Vector Indexing API | β Complete | api/app.py | High |
| SSE Streaming Chat | β Complete | api/app.py | Medium |
π‘ Partially Implemented Componentsβ
| Component | Status | Missing | Priority |
|---|---|---|---|
| Desktop UI | π‘ Framework | Component polish, e2e tests | Medium |
| tools vram | π‘ Partial | Model-specific VRAM estimates | Low |
| Cloud LLM Providers | π‘ Stub | OpenAI, Anthropic, DeepSeek impl | Medium |
β Not Implementedβ
- Cloud LLM Providers (OpenAI, Anthropic, DeepSeek)
- Kubernetes/Helm packaging
- Full desktop app UI (marked for GTK4 migration)
- Redis semantic cache integration
- Advanced prompt workbench features
Code Quality Metricsβ
- Total Python LOC: 11,290 (33 source files)
- Test Files: 18 (unit, integration, e2e)
- Test Coverage: 70% minimum (enforced via pytest)
- Linting: Ruff (enforced in CI)
- Type Checking: mypy (enabled, non-strict mode)
- Security Scanning: bandit, pip-audit, cargo-audit
- Documentation: 20+ markdown files
ποΈ Architecture Quick Referenceβ
Directory Structureβ
phantom/
βββ src/phantom/ # Main Python source (11,290 LOC)
β βββ core/ # CORTEX engine, embeddings, chunking
β βββ rag/ # Vector stores (FAISS), search
β βββ analysis/ # Sentiment, SPECTRE, viability
β βββ pipeline/ # DAG orchestration, classification
β βββ providers/ # LLM providers (llama.cpp base)
β βββ cerebro/ # RAG engine + knowledge integration
β βββ neutron/ # Compliance guardrails (SENTINEL)
β βββ api/ # FastAPI REST server + Judge API
β βββ cli/ # Typer CLI interface
βββ tests/ # 18 test files
β βββ unit/ # Unit tests (isolated components)
β βββ integration/ # API + CLI tests
β βββ e2e/ # End-to-end pipeline tests
βββ cortex-desktop/ # Tauri + SvelteKit + Svelte 5
βββ intelagent/ # Rust agent (multi-crate workspace)
β βββ crates/security/ # Privacy & audit modules
β βββ crates/governance/ # DAO & rewards systems
β βββ crates/memory/ # Context & knowledge graphs
β βββ crates/quality/ # Automated peer review gates
β βββ crates/mcp/ # MCP protocol handlers
βββ docs/ # 20+ markdown documentation files
βββ nix/ # NixOS module definitions
βββ .github/workflows/ # CI/CD pipelines (8 workflows)