Skip to content

Repository files navigation

Second Brain Banner


PythonLicense: MITOllamaLocal AIPRs Welcome


Turn your documents, web pages, and notes into a conversational AI knowledge base — that runs entirely on your machine.

🚀 Quick Start · ✨ Features · 📖 CLI Reference · ⚙️ Configuration · 🗺️ Roadmap


🔒 Your data never leaves your machine. No API keys. No subscriptions. No cloud.


📸 Preview

┌─────────────────────────────────────────────────────────────────┐
│ 🧠 SECOND BRAIN │
│ Your Local AI Knowledge Base │
│─────────────────────────────────────────────────────────────────│
│ ✅ Vector DB │ 1,247 chunks across 14 documents │
│ ✅ Knowledge Graph │ 89 concepts · 214 connections │
│ ✅ LLM Ready │ mistral:7b via Ollama │
└─────────────────────────────────────────────────────────────────┘

ask What connects the transformer architecture to attention theory?

🤔 Thinking...

💡 Based on your knowledge base: The transformer architecture fundamentally reimagines attention as a first-class computational primitive rather than an auxiliary mechanism. Across your 3 related documents, the key insight is...

_


🤔 Why Second Brain?

Most AI tools require sending your data to the cloud. Second Brain is different.

☁️ Cloud AI Tools🧠 Second Brain
PrivacyData sent to remote servers100% local — never leaves your machine
CostMonthly subscriptions / API feesFree forever
Knowledge SourceGeneric world knowledgeYour documents and notes
ConnectivityRequires internetWorks fully offline
CustomizationLimitedFully open and configurable
Data ControlVendor-dependentYou own everything

✨ Features

📥 Multi-Format Ingestion

Ingest PDFs, web pages, raw text notes, or any auto-detected file. The pipeline chunks, cleans, and embeds everything automatically.

🔍 Semantic Search

Find information by meaning, not keywords. Ask vague questions and still get the right answer.

💬 Conversational Q&A

Ask natural language questions grounded entirely in your own ingested knowledge base.

📝 Smart Summaries

Generate structured, bullet-pointed summaries for any topic or specific document in your library.

🔗 Knowledge Graph

Automatically map how concepts connect across your entire library. Visualize your mental model.

💡 Daily Insights

Surface surprising, non-obvious connections between random pieces of your knowledge.

🖥️ Rich Interactive CLI

A full REPL with command history, inline help, and over 20 built-in commands.

🔒 100% Local & Private

Powered by Ollama. No API keys, no cloud, no telemetry — ever.


🏗️ Architecture

second_brain/
├── ingestion/
│ ├── __init__.py
│ ├── pdf_processor.py
│ ├── web_processor.py
│ └── text_processor.py
├── storage/
│ ├── __init__.py
│ ├── vector_store.py
│ ├── graph_store.py
│ └── summary_store.py
├── agents/
│ ├── __init__.py
│ ├── query_agent.py
│ ├── link_agent.py
│ └── insight_agent.py
├── utils/
│ ├── __init__.py
│ └── helpers.py
├── brain.py
└── main.py

🚀 Quick Start

1 · Prerequisites

- Python 3.10+
- Ollama installed and running

2 · Pull Models

ollama pull mistral:7b
ollama pull nomic-embed-text

3 · Install

git clone https://github.com/2am-dev/Second-Brain.git
cd Second-Brain
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

4 · Run

python main.py
python main.py --demo #For running demo no extra files# Ingest a single file then exit
python main.py --ingest /path/to/paper.pdf
python main.py --ingest /path/to/notes.md
python main.py --ingest /path/to/book.txt

5 · Troubleshooting and Pinpointing

Use the check.ipynb that makes it easier to see where the actual error lies during execution of the code


📖 CLI Reference

📥 Ingestion

CommandDescription
ingest pdf <path>Ingest a PDF file
ingest url <url>Ingest a web page
ingest textType or paste a note (end with END)
ingest file <path>Auto‑detect format and ingest

🔍 Queries & Insights

CommandDescription
ask <question>Ask anything about your knowledge base
search <query>Raw semantic search
summarize <topic>Summarise a concept or topic
summarize doc <source>Summarise a specific ingested document
compare <a> | <b>Compare two topics or documents
questionsGenerate study questions from your data
insightsGenerate daily cross‑topic insights

🧠 Knowledge Graph

CommandDescription
graph buildBuild the concept graph from ingested content
graph related <concept>Show concepts most related to the given one
graph centralShow the most central / important concepts
graph connect <a> <b>Trace the connection between two concepts

🛠️ Utilities

CommandDescription
docsList all ingested documents
statsDisplay knowledge base statistics
historyShow recent insights
clearClear current conversation context
helpShow the full command help
quit / exitExit the REPL

⚙️ Configuration

frombrainimportSecondBrainbrain=SecondBrain(
db_path="./my_vector_db",
graph_path="./my_graph.pkl",
summary_db="./my_summaries.db",
llm_model="llama3.2:3b",
embed_model="nomic-embed-text",
)

🗺️ Roadmap

  • Web UI
  • Folder watcher
  • Graph visualization
  • Notion/Obsidian sync
  • Plugin system

🤝 Contributing

PRs welcome! Open an issue or discussion first.

📜 License

MIT License — see LICENSE file.

Built with ❤️ by 2am-dev

⭐ Star the repo if you find it useful!

About

Second Brain serves as a local system to store and compile all your sensitive and private files which might be too large for your reading and too sensitive for cloud.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages