AI-powered second brain for capturing, enriching, and querying personal knowledge.
- Captures knowledge items (note/link/insight) with optional source + manual tags
- Enriches notes with AI summary + AI tags on create/update
- Shows a searchable, filterable dashboard with detail view
- Supports grounded conversational query over saved notes
- Exposes a public query endpoint for infrastructure-style access
- In-app docs:
/docs - API routes:
src/app/api/** - AI service:
src/lib/gemini.ts - Notes/data service:
src/lib/notes.ts - Database migrations:
supabase/migrations/**
- Frontend: Next.js App Router, React, TypeScript, Tailwind CSS, shadcn/ui
- Backend: Next.js API Routes
- Database: Supabase Postgres
- AI: Google Gemini (server-side)
- Motion/UI: Framer Motion
- Deploy: Vercel
- In-app architecture visuals:
/docs→ Architecture Diagrams section - Mermaid source diagrams are included below for portability/documentation
flowchart TD
U[User] --> UI[Next.js UI\nLanding • Dashboard • New Note • Docs]
UI --> API[Next.js API Routes]
subgraph API_Layer[Application + Service Layer]
N1[/POST /api/notes/]
N2[/GET /api/notes/]
N3[/POST /api/brain/query/]
N4[/POST /api/public/brain/query/]
end
API --> N1
API --> N2
API --> N3
API --> N4
N1 --> S1[lib/notes.ts\ncreateNote • updateNote]
N3 --> S2[lib/notes.ts\nfindCandidateNotes • logQuery]
N3 --> G1[lib/gemini.ts\nextractQueryTags • answerQuestionWithNotes]
N4 --> S2
N4 --> G1
S1 --> DB[(Supabase Postgres)]
S2 --> DB
G1 --> AI[Gemini API]
sequenceDiagram
participant User
participant NewNotePage
participant APINotes as /api/notes
participant NotesLib as lib/notes.ts
participant Gemini as lib/gemini.ts
participant Supabase
User->>NewNotePage: Submit title/content/type + optional tags/source
NewNotePage->>APINotes: POST /api/notes
APINotes->>NotesLib: createNote(payload)
NotesLib->>Gemini: enrichNote(content, existingTags)
Gemini-->>NotesLib: summary + aiTags + mergedTags
NotesLib->>Supabase: insert into notes
NotesLib->>Supabase: upsert tags + note_tags
NotesLib-->>APINotes: created note
APINotes-->>NewNotePage: 201 Created
sequenceDiagram
participant User
participant AskBrain
participant APIQuery as /api/brain/query
participant NotesLib as lib/notes.ts
participant Gemini as lib/gemini.ts
participant Supabase
User->>AskBrain: Ask natural language question
AskBrain->>APIQuery: POST /api/brain/query
APIQuery->>NotesLib: listExistingTags()
APIQuery->>Gemini: extractQueryTags(question, existingTags)
Gemini-->>APIQuery: queryTags
APIQuery->>NotesLib: findCandidateNotes(queryTags, question)
NotesLib->>Supabase: tag overlap + full-text retrieval
Supabase-->>NotesLib: candidate notes
APIQuery->>Gemini: answerQuestionWithNotes(question, candidates)
Gemini-->>APIQuery: answer + sources
APIQuery->>NotesLib: logQuery(question, resultCount)
APIQuery-->>AskBrain: JSON response
notes: primary knowledge entries with content, summary, and tagstags: canonical taxonomy and usage counternote_tags: many-to-many note-tag mappingquery_logs: query observability (question + result count)note_updates: update history for prior summary/tags
Create .env.local:
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
SUPABASE_SERVICE_ROLE_KEY=
GEMINI_API_KEY=Security notes:
- Keep
SUPABASE_SERVICE_ROLE_KEYandGEMINI_API_KEYserver-only. - Never commit
.env.local.
npm install
npm run devOpen http://localhost:3000.
Apply in order:
supabase/migrations/20260316_create_notes.sqlsupabase/migrations/20260316_add_user_scoping_and_rls.sqlsupabase/migrations/20260316_add_supporting_tables.sql
- Ingestion flow: form input → validation → Gemini enrichment → note persistence → canonical tag sync
- Query flow: question → query-tag extraction → candidate retrieval (tag/full-text) → grounded answer + sources
- Public access: external callers can use
POST /api/public/brain/query
npm run dev— Start local dev servernpm run build— Production buildnpm run start— Run production servernpm run lint— Lint checksnpm run test— Unit tests (Vitest)
GET /api/notesPOST /api/notesGET /api/notes/:idPATCH /api/notes/:idDELETE /api/notes/:idPOST /api/brain/queryPOST /api/public/brain/query
Public query payload example:
{
"question": "What did I note about distributed systems?",
"userId": "optional-uuid"
}Due to the 6–10 hour time constraint of the assignment, I prioritized core product functionality, UI polish, and AI integration over advanced features.
-
Tree-based Knowledge Visualization
Instead of a flat list of notes, I would introduce a “tree of thoughts” or whiteboard-style visualization to represent relationships between ideas and improve navigation. -
Semantic Search (RAG)
Implement vector embeddings and retrieval-augmented generation for more accurate and context-aware querying. -
Enhanced Conversational Querying
Improve multi-turn conversations and contextual memory instead of single-shot queries. -
Authentication & User Isolation
Add proper auth (e.g., Supabase Auth / Google Auth) with user-scoped data. -
Improved Motion & Splash Integration
Blend the splash screen animation more seamlessly with the application background and transitions.
Given the time constraint, I chose to:
- prioritize a working end-to-end system
- focus on UI/UX polish and responsiveness
- implement meaningful AI features instead of partially built advanced systems
