The Problem
Large monolithic codebases are hard to navigate, test, and evolve. Teams waste time locating definitions, understanding cross‑module effects, and keeping the knowledge graph of the system up‑to‑date. Without a disciplined architecture the blast radius of a change can be unpredictable, leading to fragile deployments.
What This Does
potpie bundles a spec‑driven development platform that builds a knowledge graph of every file, class, and function. The core FastAPI service lives in app/, while the Rust‑based parser (app/src/parsing/) extracts structural metadata. Helper scripts (scripts/) and a seed CLI (seed/) bootstrap and manage projects.
Key files:
app/main.py– FastAPI entry point, creates the app, registers routes, and starts the lifespan event.app/modules/utils/logger.py– the most‑imported hub (164 inbound imports).app/modules/intelligence/provider/provider_service.py– high‑impact service (41 inbound imports, part of an import cycle).app/src/parsing/src/lib.rs– Rust parser compiled viaCargo.toml.
The Dockerfile and docker-compose.yml (under deployment/) ship the whole stack, including Postgres, Neo4j, and Redis, so the system can be run locally with a single command.
How It Is Wired
Execution starts at app/main.py:274 in the run function. run traverses ~399 functions, ultimately invoking:
- Database –
get_project_repo_details_from_db→self.db.query(Project)(seeapp/core/database.py). - Network –
run_pytest(viasubprocess.run) and numerous outbound calls fromapp/api/router.py(e.g.,create_conversation). - File system / Crypto –
app/modules/repo_manager/repo_manager.pyvalidates repo names, sanitises errors, and generates secrets viasecrets.choice.
The most‑used internal symbols are query (called from 159 places) and getenv (99 places). The hub logger (app/modules/utils/logger.py) has zero outgoing imports, making it a stable anchor; any change here ripples to 164 modules.
Import cycles involve provider_service.py, code_provider_service.py, and tunnel_utils.py. These cycles increase cognitive load and risk of circular import errors; breaking them by extracting shared types or deferring imports would reduce instability (currently 0.56 for tool_service).
The call graph shows that UserLocalTunnelProvider is referenced from 59 locations, highlighting it as another high‑impact component.
External effects:
- 191 functions read/write the database.
- 141 functions perform outbound HTTP calls (e.g., to OpenAI, Neo4j).
- 22 functions generate cryptographic material.
How To Use It
# Clone with submodules
git clone --recurse-submodules https://github.com/moses-y/potpie
cd potpie
# Install UV (Python package manager) and sync deps
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync
# Copy environment template and set required vars
cp .env.template .env
# Edit .env to provide:
# LLM_PROVIDER, OPENAI_API_KEY, POSTGRES_SERVER, NEO4J_URI, REDISHOST, etc.
# Build and start all services (Docker, DB migrations, FastAPI, Celery)
chmod +x scripts/start.sh
./scripts/start.sh
The API is reachable at http://localhost:8001. Health can be verified with:
curl http://localhost:8001/health
To stop everything:
./scripts/stop.sh
Real‑World Use
A development team can point potpie at a new microservice repository. The parser (lib.rs) generates a graph that powers an AI assistant capable of answering “Which function updates the User table?” or “What code paths are affected by changing logger.py?”. The assistant queries Neo4j (via app/core/database.py) and returns precise, context‑aware suggestions, reducing onboarding time.
Code Health & Issues
- HIGH – Pin third‑party GitHub Actions to commit SHA (
.github/workflows/*). - HIGH – Replace wildcard CORS origin with an explicit allow list (
app/main.py). - HIGH – CI does not run the test suite (
.github/workflows/*). - MEDIUM – No least‑privilege
GITHUB_TOKENpermissions (.github/workflows/test.yml). - MEDIUM – Dependabot / Renovate not configured (4 manifests present).
- MEDIUM – No dependency‑vulnerability scan in CI (
.github/workflows/*). - LOW – Workflow jobs lack
timeout-minutes(.github/workflows/test.yml).
Static analysis also flagged:
- Hub module (
logger.py) – 164 dependents, keep stable. - Deep nesting (max depth 10) in several services – flatten for readability.
- Oversized files (>1 200 lines) – split into cohesive units.
- Broad exception handling – replace bare
exceptwith specific catches. - Import cycles – break by extracting shared types or inverting dependencies.
Dependencies: 103 packages, with 14 behind the latest major version (e.g., cryptography ≥ 46.0.7 vs 50.0.0).
The Bottom Line
potpie provides a concrete pipeline for turning a codebase into an actionable knowledge graph, backed by a FastAPI service and a Rust parser. The architecture is functional but suffers from several high‑impact health issues (unlocked CORS, missing test execution, import cycles) that should be addressed before production use. Teams comfortable fixing these concerns will gain a powerful, query‑able view of their code.