Project Info
Inspiration
We learn something new every day, but like our memories, the best ideas can fade into forgotten tabs, buried bookmarks, book notes, research papers, and messy documents. It can be hard to connect insights across scattered materials. That’s why we built Second Brain: to help people save what they learn, support deeper research, and connect the dots between books, papers, and online knowledge.
What it does
Second Brain saves knowledge from the web and lets you recall it when you need it. Users can store useful content, organize it, and retrieve relevant information quickly instead of searching from scratch again.
How we built it
We built Second Brain as a web app that captures knowledge from online sources, books, papers, and notes, then stores it in a personal knowledge base. We focused on making information easy to save, search, and connect so users can recall what they learned and discover relationships across different materials.
Challenges we ran into
The hardest part was turning messy online information into something useful and easy to retrieve. We also had to balance speed, simplicity, and accuracy so the product felt natural to use.
Accomplishments we're proud of
One of the biggest challenges was turning scattered information from websites, books, papers, and notes into something organized and useful. We also ran into challenges setting up the agent workflow so it could process knowledge, support recall, and connect related ideas in a helpful way without making the experience feel complicated.
What we learned
We learned that building a useful second brain is not just about storing information. The real value comes from helping people recall what they already know and connect ideas across different sources. On the technical side, we learned more about building agent workflows, structuring knowledge, handling retrieval, and designing a system that can turn scattered content into useful context.
What's next
Next, we want to improve Second Brain with smarter recall, stronger connections between ideas, and better support for books, papers, and long-form research. We also want to expand the agent workflow so it can reason across saved knowledge, suggest related materials, and help users build a clearer map of what they know.
Second Brain
Second Brain is a personal knowledge-base assistant. It helps users save knowledge from notes, PDFs, and links, then recall it later through search, generated summaries, a knowledge graph, and an agent chat experience.
Memory Detail View with summary, key ideas, and source file metadata.
Interactive Knowledge Graph connecting notes, concepts, and tags.
Librarian Agent Chat showing tool executions, retrieved graph concepts, and streaming grounded responses.
The app uses a FastAPI backend, a React/Vite frontend, Firebase Auth, optional Firestore persistence, Anthropic Claude for enrichment and chat, and OpenAI embeddings when configured.
Features
- Ingest notes, PDFs, and web links.
- Convert saved material into structured memories with summaries, key ideas, claims, questions, concepts, and tags.
- Build retrieval chunks and a knowledge graph that connects related ideas.
- Chat with an agent that uses saved knowledge, citations, graph context, tool traces, and streaming responses.
- Edit saved memory content and regenerate related artifacts.
- Delete saved memories and their generated artifacts.
- Archive chat sessions back into the knowledge base.
- Store original uploaded files with GitHub.
- Run locally with in-memory demo data or persist data in Firebase Firestore.
Tech Stack
- Python, FastAPI, Uvicorn
- TypeScript, React, Vite
- Firebase Auth, Firebase Admin SDK, Firestore
- Anthropic Claude API
- OpenAI Embeddings API
- GitHub Contents API
- Tailwind CSS, Radix UI, Vaul, Lucide React
- D3 Force, React Markdown, Remark GFM
- PyPDF, Pillow, HTTPX
- Pytest
Install
From the project root:
uv sync
cd frontend
npm install
Environment
Copy the example backend environment file:
cp .env.example .env
The backend can run without AI keys for local development. Without ANTHROPIC_API_KEY, ingestion uses local fallback enrichment. Without OPENAI_API_KEY, embeddings use deterministic local vectors.
Common backend variables:
ANTHROPIC_API_KEY="your_claude_key"
OPENAI_API_KEY="your_openai_key"
SECONDBRAIN_STORAGE_BACKEND=memory
SECONDBRAIN_SEED_MOCK_DATA=1
Create frontend/.env for the Vite app:
VITE_API_BASE_URL="http://localhost:8000"
VITE_FIREBASE_API_KEY="your-firebase-web-api-key"
VITE_FIREBASE_AUTH_DOMAIN="your-project.firebaseapp.com"
VITE_FIREBASE_PROJECT_ID="your-firebase-project-id"
VITE_FIREBASE_APP_ID="your-firebase-web-app-id"
Firebase Auth is used by the frontend for Google sign-in. The backend accepts Firebase ID tokens when present and falls back to the mock account for local demo mode.
Run
Start the backend from the project root:
uv run python -m backend.api
Equivalent Uvicorn command:
uv run uvicorn backend.api:app --reload
Do not run uv run api.py from inside backend/; the backend imports expect the project root to be on Python's module path.
In another terminal, start the frontend:
cd frontend
npm run dev
The frontend runs on the Vite URL printed in the terminal and talks to VITE_API_BASE_URL, defaulting to http://127.0.0.1:8000.
Storage
The backend defaults to seeded in-memory storage:
SECONDBRAIN_STORAGE_BACKEND=memory
SECONDBRAIN_SEED_MOCK_DATA=1
Use Firestore for persistent accounts, sources, chunks, posts, and graph data:
SECONDBRAIN_STORAGE_BACKEND=firestore
FIREBASE_PROJECT_ID="your-firebase-project-id"
FIREBASE_SERVICE_ACCOUNT_FILE="/absolute/path/to/service-account.json"
# or:
FIREBASE_SERVICE_ACCOUNT_JSON='{"type":"service_account",...}'
For local Firestore emulator development:
SECONDBRAIN_STORAGE_BACKEND=firestore
FIREBASE_PROJECT_ID="secondbrain-local"
FIRESTORE_EMULATOR_HOST="127.0.0.1:8080"
Firestore collections used by the backend are accounts, sources, chunks, posts, and graphs. Records are scoped by account_id.
Original File Storage
PDF uploads and scraped-link Markdown snapshots are stored outside the database, then linked from source metadata.
Original files are stored in GitHub:
ORIGINAL_FILE_STORAGE=github
GITHUB_TOKEN="your-github-token"
GITHUB_STORAGE_REPO="owner/repo"
GITHUB_STORAGE_BRANCH="main"
GITHUB_STORAGE_PATH_PREFIX="uploads"
GitHub storage requires a token with write access to GITHUB_STORAGE_REPO.
API
GET /accountGET /sourcesGET /sources/{source_id}POST /sources- accepts JSON or multipart form data
- fields:
type=note|pdf|link,title,text,source_url,file
PATCH /sources/{source_id}- JSON body:
{ "content": "updated memory content" }
- JSON body:
DELETE /sources/{source_id}- deletes the memory and generated source artifacts
GET /postsGET /graphPOST /chat- JSON body:
{ "message": "...", "history": [] }
- JSON body:
POST /chat/stream- streams server-sent events for text, tool calls, trace steps, and final citations
CLI Ingestion
uv run python -m backend.ingest note --account-id "cli-user" --title "Transformers" --text "Self-attention connects tokens."
uv run python -m backend.ingest pdf --account-id "cli-user" --title "Paper" --file ./paper.pdf
uv run python -m backend.ingest link --account-id "cli-user" --title "Article" --source-url "https://example.com"
Test
Backend tests:
uv run pytest
Frontend typecheck and build:
cd frontend
npm run build
Documentation
More technical notes are in documents/:
Analysis
View
Metric
- 27
- 9
- 6
Figures cover GitHub contributors during the hackathon window. A co-authored commit counts in full for each author, so per-member totals add up to more than the whole-team figures.
Technology
- AnthropicIn code
- CSSIn code
- FastAPIIn code
- FirebaseIn code
- HTMLIn code
- PythonIn code
- ReactIn code
- Tailwind CSSIn code
- TypeScriptIn code
- OpenAIClaimed
9 of 10 appear in the indexed code. 1 claimed on Devpost could not be matched to code, which may simply mean the tool leaves no trace in the repository.
AI coding agents
- Claude CodeConfig · Commits
- CursorConfig
Detected from committed agent config files and commit authorship. Absence of a signal is not proof an agent was unused.
Codebase size
Source size
560 KB
Source files
113
Counts recognized source files only; vendored directories, binaries and lockfiles are excluded, so this is smaller than the repository on disk.
Repository
lenminh002/second-brain
231 files · 2.7 MB · @ 216437b
Structure
Interface
38 files · 16%Screens, components and styles rendered to the user.
Application logic
61 files · 26%Domain rules, services and shared utilities.
+4 moreData & schema
102 files · 44%Schema definitions, migrations and data access.
Supporting
Layers are inferred from where files sit in the tree, not from reading the code. A project that names its directories unconventionally will read oddly here — open the file browser to check anything the diagram implies.
Languages
- Python36%
- Markdown35%
- TypeScript28%
- CSS1%
- HTML0%
Share of indexed source by file size. Binary and vendored files are excluded.
Dependencies
frontend/package.json
npm · 26- @radix-ui/react-avatar
- @radix-ui/react-dialog
- @radix-ui/react-scroll-area
- @radix-ui/react-separator
- @radix-ui/react-tabs
- @radix-ui/react-tooltip
- @tailwindcss/typography
- @tailwindcss/vite
- @types/d3-force
- @vitejs/plugin-react
- class-variance-authority
- clsx
- d3-force
- firebase
- lucide-react
- react
- react-dom
- react-markdown
- +8 more
pyproject.toml
pypi · 12- anthropic
- fastapi
- firebase-admin
- google-api-python-client
- google-auth
- google-auth-httplib2
- httpx
- pillow
- pypdf
- python-dotenv
- python-multipart
- uvicorn[standard]
Declared in the repository’s manifests at the indexed commit. A declared package is not proof it is used, and runtime dependencies are listed first.
Export this project's context (description, README, evidence, key source files) to chat with an AI agent elsewhere.