How mdayanabbas/repopilot works
Purpose and Runtime
RepoPilot is a local-first Python 3.11+ backend that analyzes local or Git-backed FastAPI/Flask repositories and produces LLM-assisted, schema-validated debugging fix plans. Its ASGI entry point is backend/app/main.py; versioned HTTP endpoints are assembled through backend/app/api/router.py and backend/app/api/v1/.
API and Orchestration Boundary
HTTP route modules expose repository loading, analysis history/runs, architecture, fix-plan, LLM, health, and trace operations. Workflows coordinate the long-running business sequence rather than embedding it in API handlers:
• backend/app/api/v1/routes_analysis.py
• backend/app/workflows/analyze_repository_workflow.py
• backend/app/workflows/generate_fix_plan_workflow.py
Analysis produces separate persisted analysis_run_id and observability trace_run_id, which clients use for result/history versus trace lookup.
Repository Ingestion and Workspace Isolation
Repository services load either a local directory or Git source into managed workspace storage, record metadata, and clean up workspace state. This is the boundary between untrusted target repositories and RepoPilot’s analysis pipeline:
• backend/app/repository/service.py
• backend/app/repository/workspace.py
• backend/app/repository/git_client.py
Target source is then scanned for eligible files, ignored paths, language, file roles, and supported framework signals:
• backend/app/scanner/service.py
• backend/app/scanner/framework_detector.py
• backend/app/scanner/file_tree.py
Static Code Intelligence and Graphs
Python AST parsing extracts imports, functions, classes, symbols, and framework routes. FastAPI/Flask-specific extractors convert target code into route-level intelligence; import and symbol indexes support downstream retrieval.
• backend/app/intelligence/service.py
• backend/app/intelligence/python_ast_parser.py
• backend/app/intelligence/fastapi_extractor.py
• backend/app/intelligence/flask_extractor.py
Architecture construction derives dependency/layer relationships and exports JSON or Mermaid. A separate knowledge graph models debugging relationships through explicit nodes and edges:
• backend/app/architecture/service.py
• backend/app/architecture/architecture_graph.py
• backend/app/knowledge_graph/service.py
Issue-Focused Retrieval and Context
Given an issue, retrieval combines keyword, import, route, and Git-history signals; scoring and token budgeting select a bounded context for the model. Git intelligence analyzes log, blame, and change frequency and can boost relevant code.
• backend/app/retrieval/service.py
• backend/app/retrieval/context_builder.py
• backend/app/retrieval/git_retriever.py
• backend/app/git_intelligence/service.py
This establishes a key boundary: deterministic repository analysis and retrieval happen before external model invocation.
LLM Fix-Plan Generation
The agent layer builds prompts from retrieved context, selects a configured provider, calls it, parses the response, and validates it against structured schemas before returning/persisting a fix plan. Providers support remote Groq and local LM Studio:
• backend/app/agent/service.py
• backend/app/agent/provider_factory.py
• backend/app/agent/providers/groq_provider.py
• backend/app/agent/providers/lmstudio_provider.py
• backend/app/agent/schema_validator.py
Prompt and output-contract assets live outside executable code:
• prompts/system/repopilot_system_prompt.md
• prompts/fix_plan/fastapi_fix_plan_prompt.md
• prompts/schemas/fix_plan_schema.json
Persistence, Observability, and Deployment
SQLAlchemy-style database/session/repository layers persist repositories, analyses, retrieval outputs, plans, traces, and graphs; Alembic owns migrations. SQLite is the stated default, while Docker Compose infrastructure includes PostgreSQL and Redis assets.
• backend/app/database/models.py
• backend/app/database/repositories.py
• backend/alembic/env.py
• docker-compose.yml
Trace context and event/model/tool loggers capture workflow execution independently of API responses:
• backend/app/tracing/service.py
• backend/app/tracing/event_logger.py
• backend/app/tracing/model_call_logger.py
Container deployment is defined by infra/Dockerfile.backend and infra/nginx.conf.
Main entry points: generate_fix_plan_workflow.py Fix-plan workflow · analyze_repository_workflow.py Repository analysis workflow · service.py Fix-plan agent · routes_analysis.py Analysis routes
Components 20
API & workflows
- ASGI application
backend/app/main.py - Versioned API router
backend/app/api/router.py - Analysis routes
backend/app/api/v1/routes_analysis.py - Repository analysis workflow · Coordinates loading, scanning, intelligence, and persisted analysis runs.
backend/app/workflows/analyze_repository_workflow.py - Fix-plan workflow · Separates deterministic retrieval from model invocation.
backend/app/workflows/generate_fix_plan_workflow.py
Repository analysis
- Repository workspace service · Loads local or Git sources into isolated managed workspaces.
backend/app/repository/service.py - Source scanner · Filters files and detects languages, roles, and supported frameworks.
backend/app/scanner/service.py - Static code intelligence · Extracts symbols, imports, and framework routes.
backend/app/intelligence/service.py - Architecture graph builder · Derives dependency and layer relationships for JSON or Mermaid export.
backend/app/architecture/service.py - Debugging knowledge graph
backend/app/knowledge_graph/service.py
Retrieval & planning
- Issue retrieval · Combines keyword, import, route, and history signals.
backend/app/retrieval/service.py - Bounded model context · Scores evidence and applies token budgeting.
backend/app/retrieval/context_builder.py - Git intelligence · Uses log, blame, and change frequency to boost relevance.
backend/app/git_intelligence/service.py - Fix-plan agent · Builds prompts, calls a provider, parses, and validates plans.
backend/app/agent/service.py - LLM provider factory · Selects remote Groq or local LM Studio.
backend/app/agent/provider_factory.py - Fix-plan contract
prompts/schemas/fix_plan_schema.json
Persistence & operations
- Database repositories · Persists repositories, runs, retrieval outputs, plans, traces, and graphs.
backend/app/database/repositories.py - Trace service · Records trace runs independently of analysis results.
backend/app/tracing/service.py - Alembic migrations
backend/alembic/env.py - Container deployment
infra/Dockerfile.backend
Connections 22
- ASGI application → Versioned API router: mounts
- Versioned API router → Analysis routes: dispatches
- Analysis routes → Repository analysis workflow: starts analysis
- Analysis routes → Fix-plan workflow: requests plan
- Repository analysis workflow → Repository workspace service: loads source
- Repository workspace service → Source scanner: provides workspace
- Source scanner → Static code intelligence: eligible source files
- Static code intelligence → Architecture graph builder: symbols and imports
- Static code intelligence → Debugging knowledge graph: code relationships
- Repository analysis workflow → Database repositories: persists analysis run
- Repository analysis workflow → Trace service: creates trace run
- Fix-plan workflow → Issue retrieval: retrieves issue evidence
- Issue retrieval → Bounded model context: ranked candidates
- Git intelligence → Issue retrieval: history signals
- Bounded model context → Fix-plan agent: bounded context
- Fix-plan workflow → Fix-plan agent: generates plan
- Fix-plan agent → LLM provider factory: selects provider
- Fix-plan agent → Fix-plan contract: uses output contract
- Fix-plan workflow → Database repositories: persists fix plan
- Fix-plan workflow → Trace service: logs model execution
- Alembic migrations → Database repositories: evolves schema
- Container deployment → ASGI application: containers runtime