Transform your documents into navigable 3D constellations where chunks are stars, semantic relationships form nebulae, and knowledge becomes a cosmic memory palace.
# 1. Install lightweight dependencies (~50MB)
pip install -r requirements.txt
# 2. Copy and configure environment
cp env.example .env
# Edit .env and add your Gemini or OpenAI key
# 3. Run the application
python headspace/main.pyThen open: http://localhost:8000
docker-compose up --build# Install core + local model support (~2-3GB)
pip install -r requirements.txt -r requirements-local.txt
# Install Ollama from https://ollama.ai
# Pull models: ollama pull gemma3:4b
python headspace/main.py- Smart Chunking: LLM-based intelligent chunking with fallback to structural
- Attachment System: Attach documents to specific chunks
- Breadcrumb Navigation: Track your path through document hierarchies
- Subtle Interactions: Hover shows parentheses
( text )in margins - no text movement - Color-Coded: Chunks colored by type and semantic embedding
- 3D Visualization: Documents rendered as star systems in space
- Semantic Clustering: Similar chunks naturally cluster together
- Nebulae: Glowing particle clouds around related concepts
- Interactive: Hover to preview, click to zoom
- Dramatic Effects: Chunks glow and scale (1.5x hover, 1.8x selected)
- Constellation Lines: Sequential connections show document flow
- Physics Simulation: Optional gravity mode for organic movement
- Multiple Model Support: Ollama, Gemini, OpenAI, Sentence-Transformers
- Automatic Fallbacks: Seamless switching between models if one fails
- LLM Chunking: Context-aware document chunking using language models
- Semantic Embeddings: High-dimensional vectors for similarity matching
- Tag Generation: Automatic tagging based on content analysis
- Model Health Monitoring: Real-time status tracking of all AI services
- Modular Architecture: Clean separation of concerns (API, Services, Models)
- REST API: Full CRUD operations on documents and chunks
- SQLite Database: Persistent storage with relationships
- Real-time Updates: WebSocket support
- File Upload: Secure file upload with validation
- Comprehensive Testing: Unit tests with pytest
- Docker Support: One-command deployment
- Click "+ Add Document" in sidebar
- Enter title and content (or upload file)
- System automatically chunks and processes
- View in document or cosmos mode
- In document view, click the pulsing badge on any chunk
- Click "+ Attach Document"
- Enter document ID to attach
- Attached documents appear in expandable panel
- Switch to Cosmos View
- Hover stars to see chunk previews (dramatic glow!)
- Click to select and zoom camera
- Info panel shows chunk details + attach button
- Toggle nebulae, connections, gravity in controls
.
โโโ headspace/ # Main application package
โ โโโ main.py # Application entry point
โ โโโ api/ # API layer
โ โ โโโ routes.py # FastAPI endpoints
โ โ โโโ middleware.py # CORS, security headers
โ โโโ services/ # Business logic
โ โ โโโ database.py # Database operations
โ โ โโโ document_processor.py # Document processing
โ โโโ models/ # Data models
โ โโโ api_models.py # Pydantic models
โโโ config_manager.py # Configuration management
โโโ embeddings_engine.py # Embedding generation
โโโ llm_chunker.py # LLM-based chunking
โโโ tag_engine.py # Document tagging
โโโ model_monitor.py # Model health monitoring
โโโ requirements.txt # Python dependencies
โโโ requirements-dev.txt # Development dependencies
โโโ env.example # Environment variables template
โโโ docker-compose.yml # Container orchestration
โโโ Dockerfile # Container build
โโโ static/
โ โโโ index.html # Web frontend (Three.js visualization)
โโโ documents/ # Document storage
โโโ templates/ # HTML templates for standalone export
โโโ scripts/ # Launcher scripts
โ โโโ start_headspace.bat
โ โโโ run_docker.bat
โโโ docs/ # Detailed documentation
โ โโโ HEADSPACE.md
โ โโโ DOCKER.md
โ โโโ ...
โโโ legacy/ # Old loom-based system (archived)
โโโ archive/ # Experiments & prototypes
Backend:
- Python 3.11+
- FastAPI (web framework)
- SQLite (database)
- NumPy (embeddings & positioning)
Frontend:
- Three.js r128 (3D rendering)
- OrbitControls (camera navigation)
- Custom GLSL shaders (nebula effects)
- Vanilla JavaScript (no framework)
Deployment:
- Docker & Docker Compose
- Uvicorn ASGI server
- Volume mounts for persistence
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Serve web interface |
POST |
/api/documents |
Create document |
GET |
/api/documents |
List all documents |
GET |
/api/documents/{id} |
Get document with chunks |
DELETE |
/api/documents/{id} |
Delete document |
POST |
/api/chunks/{id}/attach |
Attach document to chunk |
GET |
/api/chunks/{id}/attachments |
Get chunk attachments |
DELETE |
/api/chunks/{id}/attach/{doc_id} |
Remove attachment |
GET |
/api/visualization |
Get all data for 3D viz |
POST |
/api/upload |
Upload file |
GET |
/api/health |
Basic health check |
GET |
/api/health/models |
Model status overview |
GET |
/api/health/detailed |
Comprehensive service check |
- Chunk borders: Color-coded by type (red=header, blue=paragraph, purple=code)
- Attachment badges: Circular, left edge, pulses when has attachments
- Hover: Subtle parentheses
( ... )fade in at margins - No text movement: Reading experience never interrupted
- Star size: Larger = more text
- Star color: From semantic embedding (similar colors = related concepts)
- Star position: UMAP reduction (close together = semantically similar)
- Nebulae: Particle clouds around semantic clusters
- Constellation lines: Show document structure
- Hover glow: Scale 1.5x, emissive intensity 1.2x
- Selected glow: Scale 1.8x, emissive intensity 1.5x
-
Copy
env.exampleto.env:cp env.example .env
-
Add your API keys:
GEMINI_API_KEY- Google Gemini (recommended, free tier available)OPENAI_API_KEY- OpenAI GPT modelsOLLAMA_URL- Local Ollama (optional, for offline use)
| File | Size | Use Case |
|---|---|---|
requirements.txt |
~50MB | Basic setup with API keys (Gemini/OpenAI) |
requirements-local.txt |
~2-3GB | Adds local embedding models (Sentence-Transformers) |
requirements-dev.txt |
~10MB | Adds testing tools (pytest, coverage) |
Edit loom_config.json to:
- Set preferred models and providers
- Configure fallback chains
- Enable/disable specific services
# Install dependencies
pip install -r requirements.txt
# Start server
python headspace/main.py
# Server runs on http://localhost:8000Edit static/index.html - changes are live (volume mounted in Docker)
Edit files in headspace/ directory - restart container to apply changes:
docker-compose restart# Install dev dependencies
pip install -r requirements-dev.txt
# Run all tests
pytest tests/
# Run with coverage
pytest tests/ --cov=headspace- Start server:
docker-compose up - Open: http://localhost:8000
- Add a document
- Switch between views
- Test attachments
- Explore cosmos
# Health check
curl http://localhost:8000/api/health
# Model status
curl http://localhost:8000/api/health/models
# List documents
curl http://localhost:8000/api/documents
# Get specific document
curl http://localhost:8000/api/documents/{doc_id}
# Attach document to chunk
curl -X POST http://localhost:8000/api/chunks/{chunk_id}/attach \
-H "Content-Type: application/json" \
-d '{"document_id": "doc_id"}'Memory Palace Principle: Humans remember spatial arrangements better than linear text. Headspace leverages spatial memory by placing ideas in 3D space.
Semantic Gravity: Related concepts naturally attract, different concepts repel. Clusters emerge organically from meaning.
Progressive Detail: Far view shows structure, near view shows content. Navigate smoothly between macro understanding and micro detail.
Context-Aware UX: Reading mode is subtle and respectful. Exploration mode is dramatic and engaging.
- Document chunking & storage
- 3D visualization with Three.js
- Attachment system
- Breadcrumb navigation
- 2000-particle nebula systems
- Custom GLSL shaders
- Nebula core glow
- Better cluster detection
- Click-to-expand node hierarchy
- Document โ Chunks โ Attachments drill-down
- Smooth camera zoom animations
- Visual hierarchy by level
- Search across all documents
- Real embeddings (OpenAI/Cohere)
- Multi-user support
- VR support for immersive exploration
- Export visualizations
MIT - Free to use and modify
Server won't start?
- Check Python 3.11+ installed
- Install dependencies:
pip install -r requirements_headspace.txt
Docker issues?
- Ensure Docker Desktop is running
- Check port 8000 is free:
netstat -ano | findstr :8000
Database errors?
- Delete
headspace.dbfor fresh start - Container will create new database automatically
More help: See docs/ for detailed guides
Built with ๐ซ - Explore your knowledge as a cosmic memory palace