# Repository Briefing: yijiejiang/kaogong-school
> Source: https://repoforai.com/repo/yijiejiang/kaogong-school (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/yijiejiang/kaogong-school
- **Official Docs / Website**: https://yijiejiang.github.io/kaogong-school/
- **Category**: Chat UI & AI Apps (聊天界面与 AI 应用)
- **Primary Language**: Python
- **License**: MIT
- **Engineering Health**: B+ (68/100 · Maintenance 35/35 · Adoption 2/25 · Releases 11/20 · License 20/20)
- **Review Snapshot**: 2026-12-03
- **Deployment / Stack Signals**: Docker, Self-Hosted
- **Momentum**: 203 ★ total (+0 24h / +27 7d) · 1 forks
- **Topics**: `ai-agents`, `ai-tutor`, `civil-service-exam`, `deepseek`, `edtech`, `education`, `exam-prep`, `fastapi`, `gongkao`, `google-adk`, `kaogong`, `litellm`
- **When to Use**: Best for: Individual Chinese civil service exam candidates who already have PDFs, courses or past papers and want one private workspace for retrieval, targeted practice, grading and progress tracking. Skip if: You need a maintained question catalog out of the box, production-ready multi-user authentication, or high-quality offline OCR and grading without configuring local models.

## Overview
```text
### Architecture & Core Mechanics
Kaogong School is organized around one chat entry point, not a collection of independent bots. The Next.js 15 web app and native SwiftUI client use a Python 3.12 FastAPI backend over REST and SSE. A counselor built around Google ADK routes work to specialist roles for supervision, exam assembly, grading, tutoring and material collection or organization. Each role can use a different OpenAI-compatible model, and users can inspect handoffs and tool calls in the chat interface.

The data model distinguishes source documents, tagged questions, saved analyses and reusable skills. Ingestion creates retrievable chunks; question extraction runs as a background job with a progress endpoint. The tutor consults the skill map and material library, while grading feeds errors and mastery data back into study planning. Retrieval defaults to local `hash-384` embeddings and can use a configured embedding API. Extension points include model endpoints and Git skill packs that follow the `references/` layout.

### Key Capabilities & Differentiators
The material library accepts PDF, DOCX, TXT, Markdown, web pages, images, audio, and Bilibili or YouTube video. Chunks can link back to source pages; for image-heavy questions that text extraction misses, multimodal extraction can retain the question crop alongside the recognized text. Video ingestion prefers captions, then falls back to transcription and aligns narration with OCR and timestamped keyframes. Saved analyses can render formulas, tables and diagrams in a full-screen presentation on web and iOS.

The exam workflow supports filtering by subject, module, difficulty and tag, timed attempts with autosave, objective scoring and model-assisted rubric grading for written answers. Online question selection extracts complete questions from search results rather than inventing replacements. Paper grading accepts 1–30 photos and requires review before results enter the question bank and update learner analytics. The OpenAI-compatible presets include DeepSeek, OpenCode Go and Ollama; OCR, search and speech capabilities depend on the configured service or local fallback.

### Trade-offs & Limitations
Compared with a general self-hosted RAG workspace, the advantage is what happens after retrieval: a tagged question can be selected for an exam, scored and linked to a mastery update. Compared with a curated exam platform, there is more control over source material and model choice, but question coverage depends on what you import or can find online. Question-to-skill matching is heuristic, and mastery without real attempts is shown as an estimate rather than measured performance.

Self-hosting does not mean offline processing. Hosted inference, OCR and speech services can process inputs remotely and add usage costs; local Ollama and faster-whisper shift some of that load to the host. Video ingestion uses fixed-interval frames without scene detection or visual chart interpretation, and caption restrictions can reduce an import to its description. Most importantly, there is no login authentication. Keep the app private as shipped, and add authentication, access controls and an appropriate upload storage plan before a shared public deployment.

### Hardware & Deployment Guide
The local path uses Python 3.12, `uv`, Node 20+ and `ffmpeg`. Run `make install` and `make start`, then open `http://localhost:3000`. `make demo` exercises the workflow with canned model responses and local hash embeddings, without requiring an API key. macOS is relevant for Vision OCR and iOS builds, not the FastAPI backend itself. The iOS 17+ client can pair over the LAN or reach a private instance through Tailscale.

SQLite is the default. For external infrastructure, `make infra` brings up the supplied Compose services: pgvector on PostgreSQL 16 and Redis 7, with persistent volumes. This is not a full application Compose stack; PostgreSQL is selected separately via `DATABASE_URL`. There is no tagged release in the supplied metadata. Recent project changes include image-based PDF question extraction, stricter source-based online question selection and skill-source filtering.
```

## Key Capabilities
```text
- Agent routing: A counselor dispatches work to specialist roles, each with its own model configuration; chat streams over SSE.
- Document retrieval: Heading-aware chunking preserves section hierarchy and links chunks back to original pages or figures.
- Question selection: Fine-grained tags drive assembly; online selection requires a complete stem, options and answer, and reports shortages rather than silently substituting unrelated questions.
- Paper grading: A multimodal model processes 1–30 images per submission; reviewed results update the bank and learner analytics only after confirmation.
- Skill tracking: An offline-installable pack has more than 200 skills across eight areas; compatible Git packs can be imported, and estimated mastery is labeled.
- Evaluation: A small retrieval suite reports Top-1 knowledge-point accuracy, Top-3 tag recall, chunk-type accuracy and Recall@5.
```

## Quick Start / Clone
```bash
cd backend
uv add faster-whisper
# 想要更准可以设 ASR_LOCAL_MODEL=medium
```
