How phani-manda/the-cortex works
Cortex is an AI-assisted second-brain application. Users capture notes, links, or files; the notes API authenticates and rate-limits the request, invokes AI analysis, and persists enriched notes. Users can browse and search their notes, ask questions answered from retrieved notes, and expose selected public knowledge through APIs and an embeddable chat. The graph includes the documented capabilities whose implementation was not sampled; those links are dashed where source evidence is unavailable.
Main entry points: notes/route.ts Notes API · db.ts Note data service · note-grid.tsx Note grid · query/route.ts Public query route
Components 23
User experience
- Dashboard
src/components/dashboard.tsx - Capture form
src/components/capture-form.tsx - Note grid
src/components/note-grid.tsx - Note card
src/components/note-card.tsx - Note modal
src/components/note-modal.tsx - Note skeleton
src/components/note-skeleton.tsx - Ask brain
src/components/ask-brain.tsx - UI primitives
src/components/ui
Identity and access
- Login page
src/app/login/page.tsx - Auth routes
src/app/api/auth/[...nextauth]/route.ts - Registration route
src/app/api/auth/register/route.ts - Auth service
src/lib/auth.ts
Knowledge services
- Notes API
src/app/api/notes/route.ts - AI analysis
src/lib/ai.ts - Rate limiting
src/lib/rate-limit.ts - Note data service
src/lib/db.ts - PostgreSQL
Public access
- Public query route
src/app/api/public/brain/query/route.ts - Knowledge query
src/lib/query.ts - Public notes route
src/app/api/public/brain/route.ts - Embed chat
src/app/embed/page.tsx
Other components
- User
- Groq AI
Connections 29
- User → Dashboard: uses
- Dashboard → Capture form: renders
src/components/dashboard.tsx - Dashboard → Note grid: renders
src/components/dashboard.tsx - Note grid → Note card: renders
src/components/note-grid.tsx - Note grid → Note modal: opens
src/components/note-grid.tsx - Note grid → Note skeleton: renders
src/components/note-grid.tsx - Capture form → Notes API: submits
src/components/capture-form.tsx - Notes API → Auth service: authenticates
src/app/api/notes/route.ts - Notes API → Rate limiting: checks limit
src/app/api/notes/route.ts - Notes API → AI analysis: analyzes input
src/app/api/notes/route.ts - Notes API → Note data service: creates or reads
src/app/api/notes/route.ts - Note data service → PostgreSQL: queries
src/lib/db.ts - Notes API → User: returns notes
- User → Login page: signs in
- Login page → Auth routes: authenticates
- Auth routes → Auth service: uses handlers
src/app/api/auth/[...nextauth]/route.ts - Registration route → Auth service: registers user
src/app/api/auth/register/route.ts - Auth service → Note data service: checks users
src/lib/auth.ts - User → Ask brain: asks
- Ask brain → Public query route: submits query
- Public query route → Rate limiting: checks limit
src/app/api/public/brain/query/route.ts - Public query route → Knowledge query: dispatches query
src/app/api/public/brain/query/route.ts - Knowledge query → Note data service: retrieves notes
src/lib/query.ts - Knowledge query → Groq AI: generates answer
- User → Public notes route: requests public notes
- Public notes route → Note data service: reads public notes
src/app/api/public/brain/route.ts - User → Embed chat: opens widget
- Embed chat → Public query route: queries brain
- UI primitives → User: renders controls