# How Wiki Generation Uses LLM Summaries for Community Pages in Code Review Graph

> Discover how the code review graph wiki generator embeds pre-computed LLM summaries for community pages. Learn about this efficient wiki generation approach.

- Repository: [Tirth Kanani/code-review-graph](https://github.com/tirth8205/code-review-graph)
- Tags: how-to-guide
- Published: 2026-08-16

---

**The wiki generator in `code_review_graph` does not call an LLM directly; instead, it embeds pre-computed LLM summaries stored in the `description` field of each community object.**

The code-review-graph repository separates concerns between **community analysis** and **documentation generation**. The wiki system consumes LLM-produced descriptions that were generated earlier in the pipeline, making the documentation workflow efficient and reproducible.

## How Community Descriptions Flow Into Wiki Pages

### Step 1: LLM Summaries Are Produced During Community Discovery

The `get_communities(store)` function in [`code_review_graph/communities.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/communities.py) returns community objects as dictionaries. When communities are created, an external tool (such as a community-description generator) can invoke an LLM to analyze the code patterns within that community and store the resulting narrative in the `"description"` key.

This design allows flexibility—you can use any LLM provider or prompt engineering approach without modifying the wiki generator itself.

### Step 2: The Wiki Generator Renders Pre-Computed Descriptions

In [`code_review_graph/wiki.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/wiki.py), the `_generate_community_page(store, community)` function handles page construction:

```python

# From code_review_graph/wiki.py (lines 58-60)

description = community.get("description", "")
if description:
    md.write(f"## Overview\n\n{description}\n\n")

```

The generator performs these actions:
- Retrieves the description via `community.get("description", "")`
- If present, inserts it into the **Overview** section of the Markdown page
- Continues with additional sections: dependency tables, control flow diagrams, and cross-references

### Step 3: The Final Markdown Page Contains the LLM Narrative

The complete workflow is: **LLM → community description → wiki generator → Markdown page**.

## Complete Usage Example

Generate a wiki from an existing graph store:

```python
from code_review_graph.wiki import generate_wiki

# store is already populated with communities and LLM descriptions

wiki_stats = generate_wiki(store, "/tmp/my_wiki")

print(wiki_stats)

# Output: {'pages_generated': 12, 'pages_updated': 3, 'pages_unchanged': 0}

```

Inspect a generated page to verify the LLM summary appears:

```python
from pathlib import Path

page = Path("/tmp/my_wiki/data-processing.md").read_text()
print(page.splitlines()[:15])

# ['# Data Processing',

#  '',

#  '## Overview',

#  '',

#  'This module provides utilities for handling CSV and JSON parsing...',

#  ...]

```

Manually inject a description for testing or customization:

```python
from code_review_graph.communities import get_communities

communities = get_communities(store)
communities[0]["description"] = (
    "Handles all I/O operations with retry logic and async support."
)

# Subsequent wiki generation will embed this text

```

## Key Files in the Wiki Generation Pipeline

| File | Responsibility |
|------|---------------|
| [`code_review_graph/wiki.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/wiki.py) | Core wiki generation; embeds `community["description"]` into the Overview section of each page |
| [`code_review_graph/communities.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/communities.py) | Constructs community dictionaries; `description` field is populated by external tools |
| [`code_review_graph/tools/docs.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/tools/docs.py) (example) | Illustrative location where an LLM tool might generate descriptions before wiki creation |

## Why This Architecture Matters

**Decoupled design** allows you to:
- Swap LLM providers without touching wiki code
- Cache expensive LLM calls (descriptions are stored, not regenerated)
- Generate wikis offline or in air-gapped environments
- Version-control community descriptions independently of the generator

## Summary

- The wiki generator **reads** LLM summaries from `community["description"]` rather than calling an LLM
- Descriptions are inserted into the **Overview** section of each community page in [`code_review_graph/wiki.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/wiki.py)
- Community objects originate in [`code_review_graph/communities.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/communities.py) with pre-populated metadata
- This pipeline pattern keeps documentation generation fast, deterministic, and independent of LLM availability

## Frequently Asked Questions

### Where does the LLM actually get called in the codebase?

The repository does not mandate a specific LLM call location. Typically, a separate tool in `code_review_graph/tools/` (such as [`docs.py`](https://github.com/tirth8205/code-review-graph/blob/main/docs.py)) or an external pipeline invokes the LLM to produce community descriptions before `generate_wiki()` runs. The wiki system itself is LLM-agnostic.

### Can I generate wiki pages without any LLM summaries?

Yes. The `community.get("description", "")` call returns an empty string when no description exists, and the Overview section is omitted. The page still contains dependency tables, flow diagrams, and structural information derived from static code analysis.

### How do I customize which LLM generates the descriptions?

Implement a custom tool that calls your preferred LLM and attaches the result to each community dictionary before passing it to `generate_wiki()`. The wiki generator requires only that the `"description"` key exists; it does not inspect how the value was produced.

### Is the description regenerated every time I run `generate_wiki()`?

No. Descriptions are persisted in the community objects within the graph store. They are written once during community discovery and read repeatedly during wiki generation. To refresh descriptions, you must re-run the community discovery pipeline with your LLM tool.