An intelligent knowledge management system that automatically processes, understands, and connects your documents using AI. Built with a production-grade agentic architecture, vector search, and knowledge graphs.
- Automated Document Ingestion: Drop PDFs into the inbox folder and watch them get processed automatically
- Multi-Step Agent Architecture: Coordinated agents handle extraction, summarization, tagging, and embedding
- Smart Chunking: Documents are intelligently split while preserving context
- AI-Powered Summarization: Get concise summaries using local LLMs via Ollama
- Semantic Search: Find documents by meaning, not just keywords
- Hybrid Retrieval: Combines vector similarity and knowledge graph traversal
- Context-Aware Answers: Get relevant answers with supporting evidence
- Multi-Step Reasoning: AI agent performs step-by-step reasoning over your knowledge base
- Automatic Relationship Discovery: Connects documents through shared topics and concepts
- Graph-Based Exploration: Navigate your knowledge through conceptual links
- Topic Clustering: Automatically categorizes content by topics, concepts, and applications
- Knowledge Analytics: Discover patterns across your entire knowledge base
- Recommendation Engine: Get personalized document recommendations
- Insight Generation: AI-powered insights about your learning journey
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β File Watcher (Inbox) β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Agent Orchestrator (Planner) β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β Extract βββ Summarizeβββ Tag βββ Embed β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββββ β
β β Graph Builder β β
β ββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Storage Layer β
β βββββββββββββββ βββββββββββββββ ββββββββββββββββ β
β β ChromaDB β β Neo4j β β File System β β
β β (Vectors) β β (Graph) β β (Processed) β β
β βββββββββββββββ βββββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Query Agent β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β Retrieve βββ Tag βββ Graph βββ Reason β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Python 3.8+
- Neo4j 5.0+ - Graph database for knowledge relationships
- Ollama - Local LLM inference engine
- 8GB RAM minimum (16GB recommended)
- 10GB free disk space for models and data
- macOS, Linux, or Windows (WSL recommended)
git clone https://github.com/yourusername/second-brain.git
cd second-brain# Create virtual environment
python -m venv .venv
# Activate virtual environment
# On macOS/Linux:
source .venv/bin/activate
# On Windows:
.venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt# macOS (using Homebrew)
brew install neo4j
neo4j start
# Linux/Windows - Download from https://neo4j.com/download/# macOS/Linux
curl -fsSL https://ollama.com/install.sh | sh
# Pull the required model
ollama pull llama3.2:3b# Create .env file
cp .env.example .env
# Edit .env with your settings.env file:
# Ollama Model
MODEL_NAME=llama3.2:3b
# Neo4j Configuration
URI=bolt://localhost:7687
USERNAME=neo4j
PASSWORD=your_secure_password_here# First time setup - reset password
neo4j-admin set-initial-password your_secure_password_here# Activate virtual environment
source .venv/bin/activate
# Start the pipeline
python run_pipeline.pyThe pipeline will:
- Monitor
data/inbox/for new PDF files - Automatically process them through the AI pipeline
- Store embeddings, summaries, and graph relationships
- Move processed files to
data/processed/
# Interactive query interface
python -m src.scripts.queryExample queries:
Ask anything: What is machine learning?
Ask anything: Explain neural networks
Ask anything: What concepts relate to deep learning?
# Generate insights about your knowledge base
python -m src.scripts.insights# Clear all data and start fresh
python -m src.scripts.resetsecond-brain/
βββ data/
β βββ inbox/ # Drop PDF files here for processing
β βββ processed/ # Processed files and metadata
β βββ archive/ # Archived files
β βββ db/ # ChromaDB vector database
β
βββ src/
β βββ agent/ # Agentic orchestration
β β βββ executor.py # Step execution engine
β β βββ orchestrator.py # Main orchestration loop
β β βββ planner.py # Planning logic
β β βββ query/ # Query agent components
β β
β βββ processing/ # Document processing
β β βββ chunker.py # Text chunking logic
β β βββ embeddings.py # Vector embeddings
β β βββ summarizer.py # AI summarization
β β βββ tagger.py # Topic/concept extraction
β β
β βββ graph/ # Knowledge graph
β β βββ graph_builder.py
β β βββ graph_db.py # Neo4j interface
β β βββ graph_query.py # Graph queries
β β
β βββ memory/ # Vector storage
β β βββ vector_store.py # ChromaDB interface
β β
β βββ retrieval/ # Search & retrieval
β β βββ search.py # Semantic search
β β βββ ranker.py # Result ranking
β β βββ qa.py # Question answering
β β
β βββ intelligence/ # AI insights
β β βββ ai_insights.py
β β βββ reasoning.py
β β βββ recommender.py
β β
β βββ tools/ # Reusable tools
β β βββ base_tool.py # Tool interface
β β βββ extract.py # PDF extraction
β β βββ summarize.py # Summarization tool
β β βββ tag.py # Tagging tool
β β βββ embed.py # Embedding tool
β β βββ graph.py # Graph tool
β β βββ reason.py # Reasoning tool
β β
β βββ scripts/ # Utility scripts
β β βββ query.py # Interactive query
β β βββ insights.py # Insights dashboard
β β βββ reset.py # Database reset
β β
β βββ ingestion/ # File ingestion
β β βββ watcher.py # File system watcher
β β βββ worker.py # Processing worker
β β βββ queue_manager.py
β β
β βββ state/ # State management
β β βββ processing_state.py
β β
β βββ utils/ # Utilities
β β βββ hashing.py
β β
β βββ config.py # Configuration
β
βββ logs/ # Application logs
βββ requirements.txt # Python dependencies
βββ run_pipeline.py # Main entry point
βββ .env # Environment variables
βββ .gitignore
βββ README.md
This project follows production-level standards:
- Type hints: All functions use Python type hints
- Logging: Comprehensive logging with different levels
- Error handling: Graceful error handling with detailed messages
- Modularity: Clean separation of concerns
- Documentation: Inline comments and docstrings
Tools follow the BaseTool interface:
from src.tools.base_tool import BaseTool
class MyCustomTool(BaseTool):
name = "my_tool"
description = "What this tool does"
def run(self, *args, **kwargs):
# Your logic here
return {
"result": "data",
"metadata": {}
}The execute() method automatically wraps responses with:
- Status tracking
- Error handling
- Execution time
- Metadata
# Run all tests
pytest
# Run with coverage
pytest --cov=srcError: Neo.ClientError.Security.Unauthorized
Solution:
# Reset Neo4j password
neo4j-admin set-initial-password your_new_password
# Update .env file with new passwordError: model 'llama3.2:3b' not found
Solution:
ollama pull llama3.2:3bError: Permission denied: data/db/chroma.sqlite3
Solution:
# Fix permissions
chmod -R 755 data/db/Error: No text extracted from file
Solution:
- Ensure PDF is not scanned/image-based
- Try OCR preprocessing if needed
- Check PDF file is not corrupted
All logs are stored in logs/pipeline.log:
# View logs in real-time
tail -f logs/pipeline.log
# Search for errors
grep ERROR logs/pipeline.log- Batch Processing: Process multiple files by dropping them all at once
- GPU Acceleration: Use Ollama with GPU for faster inference
- Chunk Size: Adjust chunk size in
src/processing/chunker.pybased on your use case - Vector Index: ChromaDB automatically optimizes indexes
- Neo4j Tuning: Increase heap size for large knowledge bases
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PEP 8 style guide
- Add tests for new features
- Update documentation
- Keep commits atomic and well-described
This project is licensed under the MIT License - see the LICENSE file for details.
- Ollama - Local LLM inference
- Neo4j - Graph database
- ChromaDB - Vector database
- Sentence Transformers - Embedding models
- Rich - Beautiful terminal output
- Web interface (FastAPI + React)
- Multi-format support (DOCX, TXT, Markdown)
- Collaborative knowledge bases
- Cloud deployment guides
- Integrations (Notion, Obsidian)
- Mobile app
- Real-time collaboration
- Advanced visualization
For questions and support:
- Open an issue on GitHub
- Check existing issues for solutions
- Review the troubleshooting section
Built with β€οΈ using AI and Python