How milwil-2/climb-graphdb works
1. What this repo is
- climb-graphdb is a Python project centered on a graph-backed climbing network. The code is split into a reusable domain package, a small API layer, and offline sync/validation jobs.
2. Primary data stores and boundaries
- The architecture clearly separates a source relational database from a graph database:
- src/climber_network/source/pg.py reads from Postgres.
- src/climber_network/graph/client.py wraps graph access, almost certainly Neo4j given the cypher/ folder.
- cypher/schema_constraints.cypher defines graph constraints/schema rules, showing the graph model is an explicit part of the system.
3. Core domain library
- src/climber_network/ is the shared business logic layer. It contains:
- config.py for environment/runtime configuration
- vocab.py for canonical terms/labels used across the app
- geo/ for geocoding and location normalization
- travel/ for travel-distance formulas
- elo/ for expected-score / rating math
- graph/ for graph DB connectivity
- source/ for reading from the relational source
- This package is the main dependency of both the API and the sync jobs.
4. Ingestion and synchronization pipeline
- The sync/ directory contains offline jobs that move and enrich data:
- sync/pg_to_neo4j.py likely performs the main relational-to-graph migration.
- sync/geo.py adds geospatial enrichment.
- sync/travel.py computes or backfills travel relationships/metrics.
- sync/validate_elo.py checks rating-model consistency.
- These scripts form the batch/data engineering layer of the repo.
5. Geospatial enrichment path
- src/climber_network/geo/geocode.py plus sync/geo.py indicate a pipeline step that turns raw location data into geocoded coordinates or standardized place data.
- This enrichment likely feeds the graph model and any travel-distance calculations.
6. Travel and scoring logic
- src/climber_network/travel/formulas.py contains the core distance/relationship math used by the sync layer.
- src/climber_network/elo/expected.py provides the expected-value calculations for Elo-style ratings, with sync/validate_elo.py verifying the model against stored data.
- These are domain-calculation subsystems, not presentation code.
7. API layer
- api/ is the runtime-facing layer:
- api/index.py is the entrypoint
- api/db.py manages database access
- api/queries.py holds graph/data queries
- api/rag.py adds an LLM-assisted retrieval layer
- api/static/index.html is a bundled static frontend or landing page
- The API appears to be a thin orchestration layer over the shared domain package and graph/database clients.
8. Retrieval-augmented answering
- The presence of api/rag.py and the test fixture groq_ask_response.json suggests an LLM-backed question-answering path, likely using Groq as the model provider.
- This sits on top of graph/query results rather than replacing them, so the graph remains the source of truth and the LLM is an interpretation layer.
9. Deployment shape
- vercel.json and .vercelignore indicate the API/static surface is intended for Vercel-style deployment.
- The repo is Python-first (pyproject.toml, uv.lock) with a small static asset, so the runtime is likely serverless or lightweight web-service oriented rather than a large always-on backend.
10. Testing and contract coverage
- tests/ covers the major boundaries separately: config, geocoding, travel formulas, Elo validation, source DB access, graph/network behavior, API/query/RAG behavior, and sync flows.
- The fixtures show the project uses recorded external responses, which is important for diagramming the system as dependent on both graph/database state and external AI/geocoding services.
11. Operational / developer tooling
- .github/workflows/ci.yml, .pre-commit-config.yaml, and the .claude/ helpers show a fairly mature developer workflow with CI and review automation.
- These are not core runtime systems, but they reinforce that the repo is organized around repeatable sync, validation, and API behavior.
12. Likely end-to-end flow
- Data originates in Postgres or other source inputs → sync jobs normalize/geocode/compute travel and Elo-related data → graph client writes into Neo4j with schema constraints → API queries the graph → optional RAG layer turns query results into natural-language answers.
Main entry points: client.py Graph client · index.py API entry · rag.py RAG · queries.py Queries
Components 17
API layer
Runtime-facing query and answer layer.
- API entry · Starts the API runtime.
api/index.py - DB access · Database connection and access helper.
api/db.py - Queries · Graph and data queries served by the API.
api/queries.py - RAG · Retrieval-augmented response generation.
api/rag.py - Static UI · Bundled landing page or lightweight frontend.
api/static/index.html
Domain package
Shared climbing network logic used by API and sync jobs.
- Config · Environment and runtime settings.
src/climber_network/config.py - Vocab · Shared labels and naming conventions.
src/climber_network/vocab.py - Geocode · Location normalization and geocoding logic.
src/climber_network/geo/geocode.py - Travel math · Travel-distance and relationship calculations.
src/climber_network/travel/formulas.py - Elo math · Expected-score calculations for Elo-style ratings.
src/climber_network/elo/expected.py - Graph client · Wraps access to the graph database.
src/climber_network/graph/client.py
Sync jobs
Offline enrichment, migration, and validation workflows.
- Pg to graph · Main relational-to-graph sync pipeline.
sync/pg_to_neo4j.py - Geo sync · Adds geospatial enrichment to graph data.
sync/geo.py - Travel sync · Backfills travel relationships and metrics.
sync/travel.py - Elo check · Validates rating-model consistency.
sync/validate_elo.py
Data model
Graph schema and source relational boundary.
- Postgres source · Reads from the relational source database.
src/climber_network/source/pg.py - Schema rules · Graph constraints and schema declarations.
cypher/schema_constraints.cypher
Connections 21
- API entry → Queries: serves · API entry delegates to query layer.
- API entry → RAG: answers with · API can route requests through the RAG layer.
- API entry → Static UI: hosts · API serves bundled static content.
- Queries → Graph client: reads · Queries execute against the graph client.
- DB access → Postgres source: connects to · API database helper reaches the relational source when needed.
- RAG → Queries: retrieves · RAG depends on structured query results.
- RAG → Vocab: interprets · Uses canonical terms to shape responses.
- Pg to graph → Postgres source: extracts from · Main sync job reads source rows from Postgres.
- Pg to graph → Graph client: writes to · Main sync job populates the graph database.
- Geo sync → Geocode: uses · Geo sync relies on geocoding and normalization.
- Geo sync → Graph client: updates · Enriched location data is written back to the graph.
- Travel sync → Travel math: computes · Travel job uses shared distance formulas.
- Travel sync → Graph client: stores · Travel relationships and metrics are persisted in the graph.
- Elo check → Elo math: checks · Validation compares stored ratings to expected-score math.
- Elo check → Graph client: reads · Validation inspects graph-stored rating data.
- Graph client → Schema rules: follows · Graph access operates within explicit schema constraints.
- Postgres source → Config: configures · Source DB access is driven by shared runtime config.
- Graph client → Config: configures · Graph connection settings come from shared config.
- Geocode → Config: uses · Geocoding depends on runtime settings.
- Travel math → Vocab: normalizes · Travel calculations use canonical domain terms.
- Elo math → Vocab: normalizes · Elo math uses shared domain terminology.