OpenDeepWiki Documentation

repository·main·Indexed 25 days ago

https://github.com/aidotnet/opendeepwiki

An AI-driven knowledge base platform that transforms Git repositories, ZIP archives, and local directories into searchable, structured documentation. It features a Next.js site, chat interfaces, and Model Context Protocol (MCP) endpoints to expose repository knowledge. The platform includes an ASP.NET Core backend with Admin APIs for managing repositories, users, roles, and AI tool configurations.

Tokens
38.1K
Snippets
79
Records
202
Agent score
84%

What's inside OpenDeepWiki

  1. Overview of OpenDeepWiki

    main

    OpenDeepWiki is an open-source, AI-driven code knowledge base that converts code repositories from platforms like GitHub, GitLab, Gitee, and Gitea into structured documentation, architecture diagrams, and knowledge graphs within minutes.

    Built on .NET 9 and Semantic Kernel with a Next.js frontend, it bridges the gap between raw code and human-readable documentation.

    Core Capabilities:

    • Rapid Conversion: Uses AI-driven analysis to transform repositories into knowledge bases.
    • Multi-language Support: Supports code analysis for all programming languages and generates documentation in multiple languages (e.g., Chinese, English, Japanese, Korean).
    • Code Structure Visualization: Automatically generates Mermaid diagrams to visualize code structure and relationships.
    • Custom Model Support: Compatible with OpenAI, Azure OpenAI, Anthropic, and custom API endpoints.
    • AI-Powered Analysis: Understands code relationships, generates project overviews, and creates comprehensive documentation.
    • MCP Protocol Support: Supports the Model Context Protocol (MCP), allowing other AI tools to query your repository's knowledge base directly.
  2. Overview of Backend Services

    main

    The backend is an ASP.NET Core application (targeting .NET 10) located in src/OpenDeepWiki/. It utilizes Minimal APIs for routing and Entity Framework Core for data access. Key service responsibilities include:

    • IWikiGenerator: Orchestrates AI-driven catalog and content generation.
    • IRepositoryAnalyzer: Handles Git operations (clone/pull) via LibGit2Sharp.
    • IIncrementalUpdateService: Manages incremental update tasks.
    • IChatAssistantService: Handles SSE streaming chat and document context.
    • ITranslationService: Manages multi-language document translation.
    • IEmbedService: Handles authentication and chat for embeddable widgets.
  3. Understand the OpenDeepWiki System Architecture

    main

    OpenDeepWiki uses a decoupled architecture consisting of a Next.js frontend and an ASP.NET Core backend.

    • Frontend (web/): A Next.js application using the App Router, React components, custom hooks, and next-intl for internationalization. It uses an API proxy at /api/[...path] to communicate with the backend.
    • Backend (src/OpenDeepWiki/): An ASP.NET Core service utilizing Minimal APIs. It handles Git repository analysis, AI-driven documentation generation, and data persistence.
    • Data Layer: Powered by Entity Framework Core, supporting both SQLite and PostgreSQL.
    • External Integrations: Connects to Git providers (GitHub, GitLab, Gitee) and AI providers (OpenAI, Azure, Anthropic).
    • Background Processing: Long-running tasks like repository processing, translation, and mind map generation are handled by IHostedService background workers.
  4. Understand the OpenDeepWiki Frontend Architecture

    main

    The OpenDeepWiki frontend is a Next.js 16 application located in the web/ directory. It utilizes the App Router to provide a user interface for repository browsing, documentation reading, AI chat interaction, and system management. The architecture is organized into several key layers:

    • Routing: Uses Next.js App Router with nested layouts (Root, Main, Admin, and Dynamic Repository routes).
    • Components: Organized by domain (UI primitives, Repository, Chat, Apps, Admin, and Animations).
    • State & Logic: Managed via custom React hooks and React Context providers.
    • Internationalization: Powered by next-intl supporting zh (default), en, ko, and ja.
    • Styling: A utility-first approach using Tailwind CSS, Radix UI for accessible primitives, and Motion for animations.
  5. Understand the Wiki Catalog Generator Prompt

    main

    The catalog-generator.md file is a system prompt designed for a senior code repository analyst AI. Its purpose is to guide an AI agent through the process of analyzing a codebase and generating a structured, 'DeepWiki-style' documentation catalog in JSON format.

    Key objectives of this prompt include:

    • Building a navigable wiki organized by topic domains (e.g., Architecture, Product Workflows, AI/Integrations) rather than file structures.
    • Ensuring 'right-sized' coverage: avoiding both massive catch-all chapters and overly granular file-by-file pages.
    • Creating a hierarchy where parent nodes serve as navigation domains and leaf nodes contain the actual documentation content.
    • Verifying all catalog items against actual source code to prevent fabrication.
  6. Understand the Project Architecture Mind Map Generator Prompt

    main
    The mindmap-generator.md file defines a system prompt for a senior software architect AI agent. Its purpose is to analyze a code repository and generate a hierarchical mind map that captures the project's core architecture and structure. The agent uses tools like ListFiles, ReadFile, and Grep to explore the repository and must output the final result using the WriteMindMap tool.
  7. Access OpenDeepWiki Admin APIs

    main

    The Admin API provides system management capabilities including repository management, user management, role management, tool configuration, and statistics.

    Base Path: /api/admin

    Authentication Requirement: All Admin API endpoints require administrator privileges. Requests must include a valid JWT token containing an administrator role.

  8. How OpenDeepWiki Works

    main

    OpenDeepWiki follows a four-step process to transform code into a knowledge base:

    1. Clone: The target repository is cloned locally.
    2. Scan: The system recursively scans directories, respecting .gitignore files. It offers an option to use AI to filter large repositories.
    3. Analyze: AI generates the directory structure, project overviews, and detailed documentation for every module.
    4. Serve: Documentation is stored in a database and served via a Next.js frontend, supporting full-text search, MCP, and conversational AI.
  9. Run the OpenDeepWiki web development server

    main

    To start the local development server for the web application, use one of the following package manager commands. Once running, the application will be accessible at http://localhost:3000. You can modify app/page.tsx to begin editing the application's main page, and changes will auto-update in the browser.

    npm run dev
    # or
    yarn dev
    # or
    pnpm dev
    # or
    bun dev
  10. Workflow for Generating an Architecture Mind Map

    main

    To generate a valid mind map, the agent follows these steps:

    1. Analyze Project Structure: Read entry point files to understand bootstrap processes, module organization, and dependencies.
    2. Identify Core Components: Use discovery tools:
      • ListFiles("src/**/*", maxResults=50) to find modules.
      • ListFiles("**/config*", maxResults=20) to find configuration.
      • Grep("main|bootstrap|app", "**/*.{ts,js,cs,py,go}") to find entry points.
    3. Build Architecture Map: Organize findings into: Entry Points, Core Business Logic, Data Layer, Infrastructure, and External Integrations.
    4. Generate Mind Map: Create the hierarchical representation and call the WriteMindMap tool.
  11. Follow Documentation Principles for DeepWiki

    main

    When generating documentation, adhere to these core principles:

    • Accuracy: Base all information on actual source code.
    • Exhaustive Completeness: Document responsibilities, internal mechanisms, data flow, configuration, APIs, failure modes, concurrency, extension points, and operational behavior.
    • Maximum Depth: Explain the implementation details (how it works) and real control flow, rather than high-level paraphrasing.
    • Clarity: Use precise, professional language.
    • Practicality: Include multiple working code examples with source attribution.
    • Visual Richness: Include at least 3 Mermaid diagrams (architecture, sequence, data, or state) for substantial pages.
    • Design Intent: Explain the rationale, trade-offs, and constraints behind the design (the 'why').
    • Substantial Length: Avoid thin summaries; use sections, subsections, tables, and annotated code excerpts to provide expert-level detail.