AI Context & Architecture Guide for Gemini
Documents the architecture, data pipeline, design patterns, and validation strategy for an AI-assisted transcript summarization project.
What this file does
Documents the architecture, data pipeline, design patterns, and validation strategy for an AI-assisted transcript summarization project.
When to use it
- Onboarding a new developer to the project's structure and conventions
- Providing context to an AI coding assistant before making changes
- Planning a new pipeline step or validation rule
- Understanding the core-wrapper separation and file responsibilities
Assumes this stack
AI Context & Architecture Guide for Gemini
This document provides context for AI coding assistants to understand the architecture, design patterns, and workflows of the trans-summary project.
1. Architecture Overview
The project follows a Core-Wrapper pattern to separate business logic from user interfaces.
- Core Logic (
pipeline.py): Contains the implementation of all major processing steps (formatting, summarizing, generating). It handles API interactions, file I/O, and logic. It is UI-agnostic. - Shared Utilities (
transcript_utils.py): Provides robust primitives for logging, API calls (with retry/validation), text normalization, and regex extraction. - Configuration (
config.py): Central source of truth for file paths, model selection, and constants. - Interfaces:
- GUI (
ts_gui.py): Tkinter-based interface that callspipeline.pyfunctions in threads. - CLI Wrappers (
transcript_*.py): Simple scripts that parse arguments and callpipeline.pyfunctions.
- GUI (
2. Data Pipeline Flow
Files move through specific states, denoted by suffixes and directories:
- Ingestion:
source/*.txt(Raw text)- Action:
format_transcript
- Action:
- Formatting:
formatted/* - formatted.md(Clean Markdown)- Action:
add_yaml
- Action:
- Metadata:
formatted/* - yaml.md(Formatted + Frontmatter)- Action:
summarize_transcript
- Action:
- Extraction:
projects/* - structural-themes.md,interpretive-themes.md,topics.md,key-terms.md,lenses-ranked.md,bowen-references.md,emphasis-items.md - Synthesis:
projects/* - summary-generated.md,abstract-generated.md - Publication:
projects/*.html,projects/*.pdf
3. Key Design Patterns
API Interaction
- Centralized Calls: All Claude API calls go through
transcript_utils.call_claude_with_retry. - 7-Level Validation: Responses are rigorously validated (message type, role, stop reason, content existence, text validity, token usage) to prevent silent failures.
- Truncation Safety: The system automatically detects and rejects responses truncated by token limits.
- Streaming: Long generations use streaming to prevent timeouts.
Text Processing
- Regex over JSON: The pipeline prefers robust Regex extraction (see
transcript_utils.extract_section) over strict JSON parsing for large text blocks, as it is more forgiving of LLM formatting minor errors. - Fuzzy Matching: Validation scripts (
transcript_validate_*.py) usedifflib.SequenceMatcherto verify that generated quotes exist in the source text, handling minor punctuation/whitespace differences.
Prompt Management
- External Files: Prompts are stored as Markdown files in
prompts/. - Template Injection:
pipeline._fill_prompt_templatehandles Jinja-like variable replacement (e.g.,{{transcript}}).
4. Critical Files Map
| File | Responsibility |
|---|---|
pipeline.py | The Brain. Orchestrates all logic. If adding a feature, start here. |
config.py | The Settings. Paths, models, constants. |
transcript_utils.py | The Toolbox. Logging, API wrappers, text helpers. |
html_generator.py | The Publisher. Logic for HTML/PDF creation. |
summary_validation.py | The Critic. Deep semantic validation for summaries. |
abstract_validation.py | The Critic. Deep semantic validation for abstracts. |
ts_gui.py | The Face. Tkinter GUI implementation. |
5. Validation Strategy
The project emphasizes correctness. Every generation step has a corresponding validation step:
- Format:
validate_formatchecks word preservation. - Headers:
validate_headerschecks header relevance via LLM. - Abstract/Summary:
validate_coveragechecks if required topics are present. - Quotes:
validate_emphasis_itemsensures quotes are not hallucinations.
6. Common Tasks for AI Agents
-
Adding a new pipeline step:
- Define prompt in
prompts/. - Add logic to
pipeline.py. - Add CLI wrapper
transcript_new_step.py. - Update
ts_gui.pyto include a button.
- Define prompt in
-
Updating Prompts:
- Modify files in
prompts/. - Ensure placeholders (e.g.,
{{transcript}}) match whatpipeline.pyprovides.
- Modify files in
-
Changing Models:
- Update
DEFAULT_MODELorAUX_MODELinconfig.py.
- Update
-
Testing & QA:
- Always run
pytest testsafter making logic changes. - Run
ruff check .to ensure code style compliance. - Add new tests in
tests/if introducing new logic.
- Always run
7. Workflows
- Request Logging:
- Automatically track user requests and task completion status in
REQUEST_LOG.md. - Update this log at the start and end of significant tasks.
- Automatically track user requests and task completion status in
What's inside
7 sections covering architecture, pipeline flow, design patterns, file map, validation, common tasks, and workflows
Change this for your project
- Replace
trans-summarywith your own project name - Replace
dbgnvan2/trans-summarywith your own repository path - Replace
DEFAULT_MODELandAUX_MODELinconfig.pywith your model IDs - Replace
prompts/directory contents with your own prompt templates
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Worth borrowing
- Core-wrapper separation keeps business logic UI-agnostic and testable
- 7-level API response validation prevents silent failures from truncated or malformed LLM output
- Regex extraction over JSON parsing for LLM output tolerates minor formatting errors
Related Documents
Totem — Development Rules
Defines team-wide conventions for a pnpm monorepo: branch strategy, commit rules, tooling, and a mandatory knowledge-search workflow before coding.
MechCAD-MLLM
Proposes a MLLM + dual-decoder architecture for mechanical CAD generation, combining Drawing2CAD and CAD-GPT ideas.
Prompt Generator
Generates Stable Diffusion and Flux prompts via Qwen3-8B on Ollama, with a Gradio UI and CLI.
Agent Instructions
Defines a three-layer architecture (directive, orchestration, execution) for AI agents that self-anneal errors and update living SOPs.