# How to Build a Company Knowledge Base (Full Tutorial)

## Executive summary

This tutorial provides a comprehensive guide on building a scalable company knowledge base using Fumadocs as the foundation and integrating Sanity as the Content Operations Platform (COP). The process moves from local Markdown files to a cloud-hosted, editable CMS, enabling advanced features like semantic search and an AI-powered chat widget. Key steps involve setting up the development environment, connecting Sanity via API keys, and deploying the CMS to a live, editable URL.

## Key takeaways

- Initial Setup with Fumadocs: Start by setting up the open-source Fumadocs framework using Node.js to create a foundational, beautiful documentation website structure. This establishes the basic content rendering pipeline.
- Integrating Sanity for CMS Functionality: To enable non-technical content owners to edit content and provide robust search, the local content source must be switched to Sanity. This requires setting up the Sanity project, obtaining the API key and Project ID, and running `npm run Sanity setup` and `npm run import`.
- Advanced Search and AI Chat Widget: Sanity automatically generates embeddings, enabling semantic search (searching by meaning, not just keywords). This foundation allows for the integration of an AI chat widget (using an LLM API key, e.g., OpenAI) that answers questions and links back to source pages.
- Deployment and Scalability: The CMS can be deployed to a hosted URL using the Sanity CLI (`npx Sanity deploy`), providing a cloud-based interface for team members and AI agents to manage content.

## Technical details

- Development Environment Setup: Requires Node.js installation. The initial project setup uses the Fumadocs framework, starting with a basic 'cookie cutter' base install.
- Project Initialization: The process involves cloning a GitHub repository and running `npm run setup` to prepare the project structure and install necessary node modules.
- Sanity Integration: To connect to Sanity, the environment variables must be updated with the Sanity API key and Project ID. The connection is established by running `npm run Sanity setup` and `npm run import`.
- Content Source Switch: The system's content source must be switched from local Markdown files to Sanity by updating the environment variable. This switches the data source from the local filesystem to the Sanity data set.
- CMS Deployment: The Sanity Studio can be locally run using `npm run studio` and then deployed to a hosted URL using the Sanity CLI: `npx Sanity deploy`.
- AI Chat Widget Implementation: The chat widget requires an external LLM API key (e.g., OpenAI) and is responsible for querying the knowledge base, providing answers, and linking back to source pages.

## Practical implications

- The knowledge base can be scaled from simple Markdown files to a professional, cloud-hosted CMS.
- Non-technical team members can be granted access to edit and publish content via the Sanity Studio interface.
- The system supports advanced search capabilities (semantic and hybrid) that understand context, not just keywords.
- The final AI chat widget provides a powerful, immediate Q&A interface for the entire organization.
- The architecture can be adapted for various use cases, from internal company wikis to public-facing documentation.

## Topics

Knowledge Base, CMS, Content Management, Semantic Search, AI Integration, Build Engineering, Fumadocs, Sanity, GitHub Repository, Proposal Template

Source: https://www.youtube.com/watch?v=DNuD3Ia8qHM
