Skip to main content

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​

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​

  1. Document Processing: Extract insights from markdown, text, PDFs
  2. Vector Search: Semantic search over document embeddings (FAISS)
  3. Classification: Multi-threaded LLM-based document classification
  4. Sentiment Analysis: NLTK VADER + optional spaCy NER
  5. RAG Pipeline: Question-answering over knowledge base
  6. 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​

ComponentStatusFilesTest Coverage
CORTEX Processorβœ… Completecore/cortex.pyHigh
Semantic Chunkerβœ… Completecore/cortex.pyHigh
FAISS Vector Storeβœ… Completerag/vectors.pyHigh
Sentiment Engineβœ… Completeanalysis/sentiment.pyHigh
Embedding Generatorβœ… Completecore/embeddings.pyMedium
LlamaCpp Providerβœ… Completeproviders/llamacpp.pyMedium
FastAPI Serverβœ… Completeapi/app.pyHigh
Prometheus Metricsβœ… Completeapi/app.pyHigh
Pydantic Schemasβœ… CompleteAll modulesHigh
CI/CD Pipelinesβœ… Complete.github/workflows/N/A
Nix Environmentβœ… Completeflake.nixN/A
CLI Commandsβœ… Completecli/main.pyMedium
RAG Query APIβœ… Completeapi/app.pyHigh
Document Uploadβœ… Completeapi/app.pyHigh
Vector Indexing APIβœ… Completeapi/app.pyHigh
SSE Streaming Chatβœ… Completeapi/app.pyMedium

🟑 Partially Implemented Components​

ComponentStatusMissingPriority
Desktop UI🟑 FrameworkComponent polish, e2e testsMedium
tools vram🟑 PartialModel-specific VRAM estimatesLow
Cloud LLM Providers🟑 StubOpenAI, Anthropic, DeepSeek implMedium

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