How daveebbelaar/company-knowledge-base works
This is a password-gated company handbook: employees browse department policies and profiles, search for relevant pages, or ask a chat assistant for cited answers. Content is read from local Markdown/JSON or published Sanity documents; search combines keyword, semantic, or hybrid retrieval in Sanity and keyword matching locally. The graph includes the documented Sanity editing and embedding capability. Some page-rendering and content-source internals are unsampled, so their wiring is shown only where the README or sampled code supports it.
Main entry points: route.ts Chat endpoint · content.ts Content access · people.ts Employee access · retrieval.ts Knowledge retrieval
Components 23
Handbook experience
- Company homepage
app/page.tsx - Handbook pages
app/docs/[[...slug]]/page.tsx - Team directory
app/docs/team/page.tsx
Knowledge content
- Content access
lib/content.ts - Employee access
lib/people.ts - Local handbook files
content/docs - Local employee profiles
content/employees - Sanity content service
lib/sanity.mjs - Sanity schemas
sanity/schema.ts
Search and chat
- Search interface
components/search.tsx - Search endpoint
app/api/search/route.ts - Knowledge retrieval
lib/retrieval.ts - Chat panel
components/chat.tsx - Chat endpoint
app/api/chat/route.ts - Chat protocol
lib/chat.mjs
Site access
- Password login
app/login/page.tsx - Unlock endpoint
app/api/unlock/route.ts - Session gate
proxy.ts - Logout endpoint
app/api/logout/route.ts - Session utilities
lib/access.mjs
Other components
- Employee
- Sanity Content Lake
- OpenAI Responses API
Connections 33
- Employee → Company homepage: browses
- Employee → Handbook pages: reads
- Employee → Team directory: finds colleagues
- Employee → Search interface: searches
- Employee → Chat panel: asks
- Company homepage → Content access: loads pages
- Company homepage → Employee access: loads profiles
- Handbook pages → Content access: loads content
- Team directory → Employee access: loads profiles
- Search interface → Search endpoint: requests results
- Search endpoint → Knowledge retrieval: searches
- Knowledge retrieval → Content access: reads pages
- Knowledge retrieval → Employee access: reads profiles
- Knowledge retrieval → Sanity content service: queries
- Content access → Local handbook files: reads
- Employee access → Local employee profiles: reads
- Content access → Sanity content service: loads published content
- Employee access → Sanity content service: loads published profiles
- Sanity content service → Sanity Content Lake: queries
- Sanity schemas → Sanity Content Lake: edits and publishes
- Chat panel → Chat protocol: reads saved chats
- Chat panel → Chat endpoint: sends turns
- Chat endpoint → Chat protocol: validates and parses
- Chat endpoint → Employee access: loads profiles
- Chat endpoint → Content access: loads current page
- Chat endpoint → OpenAI Responses API: plans and streams answer
- Chat endpoint → Knowledge retrieval: retrieves cited pages
- Employee → Password login: opens site
- Password login → Unlock endpoint: submits password
- Unlock endpoint → Session utilities: creates session
- Session gate → Session utilities: validates session
- Employee → Logout endpoint: locks site
- Logout endpoint → Session utilities: uses cookie name