cd /news/developer-tools/bike-0-graph-backed-bicycle-part-com… Β· home β€Ί topics β€Ί developer-tools β€Ί article
[ARTICLE Β· art-178110] src=github.com β†— pub= topic=developer-tools verified=true sentiment=↑ positive

Bike-0: Graph-backed bicycle part compatibility and inventory engine

A developer released Bike-0, an open-source bicycle-parts compatibility and inventory engine built on Node 22, TypeScript, Fastify 5, PostgreSQL 16, Zod 4 and React 19 with Vite, which uses a graph-backed rule engine of 55 connection checks and 5 whole-bike rules to return one of four compatibility verdicts: fits, fits with kit, data missing, or does not fit. The system enforces a zero-fault inventory policy in which no part is listed until its catalog data is human-verified, graded, photographed and measured against spec, and it ships with Docker Compose deployment, 24-hour automated database and photo backups retained for 14 days, and 48 unit plus 27 integration tests. The project requires no ORM, graph database or paid services, and optionally routes part-matching suggestions to Anthropic, OpenAI or a local Ollama model for human review.

key takeaway

Bike-0's rule engine runs 55 connection checks and 5 whole-bike rules to return fits, fits with kit, data missing or does not fit, and blocks listing any part whose measured dimensions contradict its spec, such as a 30.9 seatpost measuring 31.6.

read14 min views4 publishedNov 29, 2026
Bike-0: Graph-backed bicycle part compatibility and inventory engine
Image: Michielbdejong (auto-discovered)

The data layer and workshop UI for a budget bicycle-parts hub. It sells used parts from stripped donor bikes, Chinese generics and OEM parts under a no-return, zero-fault policy, so every compatibility answer has to be right, or it has to say it doesn't know.

  • Compatibility graph: parts link to the physical standards they use (BB shells, steerers, axles, freehubs, cable-pull families, brake and motor mounts…). A rule engine with 55 connection checks and 5 whole-bike rules returnsfits / fits with kit / data missing / does not fit .
  • Zero-fault inventory: nothing is listed until its catalog data is human-verified, it's graded and photographed, and its measurements match the spec (a "30.9" seatpost that measures 31.6 is blocked).
  • Donor-bike intake: strip a known bike into pre-identified parts, or describe parts and let the offline parser, an AI model, or both suggest a match for human review.
  • Frankenstein builds: assemble a bike from stock slot by slot; each slot shows what in stock fits.

Stack: Node 22 Β· TypeScript Β· Fastify 5 Β· PostgreSQL 16 Β· Zod 4 Β· React 19 + Vite. No ORM, no graph database, no paid services required.

Build check on a bike schematic Verification gate Overview
docker compose up -d --build     # β†’ http://localhost:3000  (UI at /app, API docs at /docs)

That builds one image with the API and the workshop UI, starts Postgres, waits for it to be healthy, runs migrations, seeds the catalog only if the database is empty, and starts the API with a healthcheck. Data lives in the pgdata and uploads volumes, so rebuilds and restarts keep everything, including verifications you made. Optional settings go in .env (copy .env.example; every value has a default):

Setting Default
POSTGRES_PASSWORD bike0 Change for anything beyond your own machine
API_KEYS empty (auth off) Comma-separated keys; enter one in the UI under Settings
APP_PORT 3000 Host port
PUBLIC_URL empty Base URL of the deployment; makes photo links in marketplace listings absolute
DEFAULT_CURRENCY USD ISO 4217 code for new donors and items; existing records keep theirs
SEED_ON_START if-empty always re-applies seed specs (overwrites edits to seed parts),false disables
DEMO_DATA false true loads demo donors, stock and builds into an empty inventory
AI_PROVIDER none anthropic (+ANTHROPIC_API_KEY ) oropenai ; Ollama on the host works viahttp://host.docker.internal:11434/v1
STORAGE local s3 withdocker compose --profile s3 up -d --build for bundled MinIO (bucket created automatically)

Backups run automatically: the backup service dumps the database and the photo uploads every 24 hours into ./backups and keeps 14 days (BACKUP_DIR, BACKUP_INTERVAL_HOURS, BACKUP_KEEP_DAYS). Each dump is verified readable before it's kept, and the service turns unhealthy if backups stop succeeding. Copy ./backups off the machine (rsync, rclone, Syncthing): a backup on the same disk doesn't survive the disk. Take one now with docker compose run --rm backup once; restore with scripts/restore.sh backups/bike0-db-….dump [backups/bike0-uploads-….tar.gz]. CI exercises the full backup-and-restore round trip.

Useful: docker compose logs -f api, docker compose exec api node_modules/.bin/tsx src/seed/demo.ts --if-empty, docker compose down (keeps data) / down -v (wipes it). Postgres is bound to 127.0.0.1 only.

docker compose up -d db          # just the database
cp .env.example .env
npm install
npm run seed                     # migrate + seed parts/bikes + build the graph
npm run dev                      # http://localhost:3000  β†’ interactive docs at /docs
npm test                         # 48 unit + 27 integration tests (needs bike0_test DB)
npm run demo                     # optional: donors, listed stock, a blocked part, AI queue, two builds
npm run web:build                # once: builds web/ β†’ served by the API at http://localhost:3000/app/
npm run web:dev                  # Vite on http://localhost:5173/app/ with hot reload, proxied to the API on :3000

A React + TypeScript admin app in web/ for testing every part of the core:

Section What you can do
Overview Inventory pipeline with the verification gate, catalog health, spend vs listed value, recent activity
Donor bikes Register a donor; strip it from a bike model (tick recovered parts) or describe each part for AI identification
Inventory Filter stock; per item: lifecycle, measurements checked live against the catalog spec, photo upload (drag and drop), grade/price, gated transitions with the exact blockers, which bikes it fits, and a ready-to-paste marketplace listing
AI review Accept a catalog match (variants matching the extracted specs are highlighted), correct and create, or reject
Builds Frankenstein builds on a bike schematic: every slot is a node coloured by its verdict; pick a slot to see what in stock (or in the catalog) fits and use it
Bike models Stock builds with self-check; "what fits my bike" per slot; start a build from a bike
Parts catalog Search, create/edit/duplicate with JSON specs + required-field list + allowed-values lookup, verify, graph neighbours
Interfaces Browse standard nodes and every part attached; export the graph
Tools Check two parts (load from catalog or type what-if specs), identify a part from text, rider fit
Settings API key and your name for the audit log, tyre/rim table editor, graph rebuild
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ interface nodes (physical standards) ────────────┐
            β”‚  bb_shell=BSA:68   seatpost=27.2   freehub=HG_8_10   ...     β”‚
            β””β”€β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚ uses         β”‚ uses          β”‚ uses            (part_interfaces)
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ frame (catalog)  │══▢│ seatpost     β”‚  β”‚ cassette     β”‚       (compat_edges:
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜fitsβ””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        compatible | conditional
            β–²                                                       + required adapters)
            β”‚ is-a
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ inventory item   β”‚  physical unit: measurements, grade, photos, price, status
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • Catalog parts: 24 part types with typed, validated specs. This includesdrive_unit ,battery ,ebike_display anddropper_remote .
  • Interface nodes: 87 physical standards in the seed. They include BB shells, S.H.I.S. cups, crown races, axle spacing, freehub/cog interfaces, cable-pull families, IGH shifter families, brake mounts, rotor mounts, motor mounts, battery mounts, chainlines and single-speed widths.
  • Compat edges: materialized part-to-part verdicts across55 connection types . They are rebuilt automatically whenRULES_VERSION changes or when the tyre/rim table is replaced.
  • Inventory items are physical units. Theireffective specs are the catalog specs plus measured overrides: cut steerer length, thread length, worn rotor thickness, axle-to-crown and insertion depth.
Verdict Meaning Sellable as "guaranteed fit"?
compatible Fits as-is βœ… (if all data is verified)
conditional Fits only with the listed adapter, shim, spacer or bench-tuning Only as a kit
unknown Required data is missing ❌ never treated as a fit
incompatible Does not fit ❌
  • Frame/fork core: BB shell + width; crank spindle (JIS vs ISO, spindle length β†’ chainline); crank spindle vs shell width; chainring clearance; S.H.I.S. cups; steerer and crown race (1" JIS 26.4 vs ISO 27.0); stems (quill bore, shims); bars and controls (22.2 vs 23.8); seatpost diameter/shim, minimum insertion, dropper routing and insertion depth; saddle rails.
  • Fork geometry: axle-to-crown vs the frame's design A2C. Within Β±10mm passes; Β±20mm is conditional with the approximate head-angle change; beyond that, or over max A2C or max travel, fails. A rigid fork in a suspension frame is caught.
  • Rear suspension: every frame statesrearSuspension (none orfull ); unknown is never read as hardtail. Full-suspension frames require a rear shock with matching mount and eye-to-eye; a shorter stroke is conditional (less travel), a longer one fails. Used shocks are measured (eye-to-eye, stroke Β±1mm) before verification.
  • Wheels/tyres: axle standard + spacing (with end-cap conversions); BSD; tyre clearance; tyre vs inner rim width (replaceable table);hookless rims only take tubeless-ready (TLE/TLR) tyres ; hub motors need torque arms in open dropouts and are refused in QR suspension forks.
  • Drivetrains: derailleur cassettes on HG, HG-11, XD/XDR, Micro Spline and Campagnolo bodies; threaded freewheels;single-speed freewheels (they fit flip-flop hubs too);track cogs , refused on freewheel hubs ("suicide hub");Nexus and3-spline IGH sprockets; single cogs on cassette bodies (needs a spacer kit).
  • Chain width: 5–8 speeds are one family; 9/10/11/12 are distinct;single-speed 1/8" vs 3/32" across chain, cog and chainring.
  • Shifting: rear pull families (Shimano legacy, Dyna-Sys, MTB-11/12, road-11, LinkGlide, SRAM 1:1, SRAM Exact, Campagnolo, microSHIFT Advent/Advent X/Acolyte);internal-hub shifters must match the hub; an IGH shifter can't drive a derailleur; a derailleur on a fixed gear is refused.
  • Cross-compatibility tables (RD_CROSS ,FD_CROSS ): documented cross-brand and cross-generation combinations come backconditional ("bench test & tune"); everything else is strict equality. Examples: Shimano road-11 shifter + 10s Dyna-Sys derailleur; SRAM MTB front shifter + Shimano MTB FD; Shimano road legacy ↔ road-11 FD is explicitly incompatible.
  • Brakes: multiple mounts per frame/fork (best mount wins); caliper reach and nut type; disc mount types and adapters; lever pull (long-pull lever on short-pull brake is unsafe); hydraulic fluid and system; rotor mount; rotor size;rotor thickness vs the caliper's accepted range, using the measured thickness for used rotors.
  • E-bike: a BB-shell conversion kit (Bafang BBS / Tongsheng) must match shell family and width, and comes with a clearance test-fit condition; frame motor mounts (Bosch Gen 2/3/4, STEPS, Yamaha, Brose, Bafang M) are matched exactly; motor crank interface; motor ↔ battery system and voltage (a generic battery is conditional); battery BMS current β‰₯ controller current; battery mount (bottle bosses / rack / integrated); display system; display clamp.
Rule What it checks
rd-capacity Derailleur wrap β‰₯ cassette spread + chainring spread
steerer-length Threadless: steerer β‰₯ head tube + headset stack + stem βˆ’ 3.Threaded: steerer β‰ˆ head tube + stack (too short = locknut won't engage; too long = spacers), andthread length reaches the top cup
chainline Derailleur: crank chainline (shifted by BB spindle length) vs frame design, which is derived from rear spacing if not stated (130→43.5, 135→48.5, 148 Boost→52, 157→55). Single/fixed/IGH: ring line vs sprocket line within 1.5mm
chain-tension Single/IGH on vertical dropouts needs a tensioner; fixed on vertical dropouts is refused ; horizontal/track/sliding dropouts or an eccentric BB pass
ebike-system One motor; no BB with a mid-drive; one voltage; one system

Required slots adapt to the bike: derailleur vs single/fixed/IGH, coaster brake (no rear brake or lever needed), disc (rotors), dropper (remote), e-bike (battery and display; no BB with a mid-drive).

intake ─▢ categorized ─▢ measured ─▢ verified ─▢ listed ─▢ reserved ─▢ sold

verified is refused (HTTP 422 ZERO_FAULT_GATE, with a list of blockers) unless:

  1. The catalog part is human-verified and complete (a per-type completeness gate with conditional fields).
  2. It has a condition grade and β‰₯ MIN_PHOTOS_FOR_LISTINGuploaded photos.
  3. For used andnew_china items, every required measurement matches the catalog spec within tolerance and every wear limit passes. Wear limits now cover battery resting voltage, battery capacity test (β‰₯70%) and a motor bench run, alongside chains, rotors, tyres, pads and true.

Re-verification audit: when the completeness gate grows, as it did in this release (chainline, rotor thickness, fork A2C and so on), previously verified parts that no longer pass drop to draft. Their listed items go back to measured. This runs automatically on boot after a rules-version change, and every downgrade is written to audit_log.

text/photos ─▢ rule parser (offline) ─▢ part-number match ─▢ LLM / vision (optional) ─▢ merge ─▢ review queue
  • Parser: Shimano part numbers and series, including Tourney β†’ XTR, Claris β†’ Dura-Ace, GRX, CUES and LinkGlide. It also knows SRAM MTB/Eagle/road groups, microSHIFT lines, internal hubs (Nexus, Alfine, Sturmey, Rohloff, i-Motion), coaster brakes, flip-flop/track hubs, 1/8" vs 3/32", Bafang/Tongsheng kits, voltage/watts/Wh, droppers (travel, routing, actuation), ETRTO sizes, axles, BB standards and brake types. Bare codes likeBBS02 are no longer mistaken for ShimanoBB- parts.
  • Vision: item photos (up toAI_MAX_IMAGES ) go to the model when it can see (AI_VISION=auto recognises Claude, GPT-4o/4.1/5, llava, qwen2.5vl, gemma3, llama3.2-vision and others;on /off override). It is told totranscribe printed part numbers, never estimate dimensions . The part number it reads is then matched against the catalog. If a model rejects images, the request is retried with text only and the run says so. Photo-only categorization needs a vision model.
  • Measuring it:npm run ai:eval scores the parser alone, the configured model alone, and the combined pipeline against the golden corpus insrc/ai/corpus.ts , reporting type accuracy, fields found, andwrong values (the number that matters under a no-return policy). Run it before switching models:AI_PROVIDER=openai AI_MODEL=qwen2.5:7b-instruct npm run ai:eval . In Docker:docker compose exec api npm run ai:eval .
  • Failure handling: each model call has a timeout (AI_TIMEOUT_MS ), truncated answers are refused, and an outage falls back to the rule parser with the error recorded on the run. Model calls run outside database transactions.
  • The parser wins conflicts; invalid fields are dropped. Auto-accept happens only on an exact part-number match to a human-verified catalog part. AI never creates verified data.

POST /v1/inventory/:id/photos (multipart field file). JPEG/PNG/WebP are detected from the file's bytes rather than trusting the client. Photos are size-limited and SHA-256 hashed, and stored in STORAGE=local (UPLOAD_DIR) or STORAGE=s3 (AWS, MinIO, R2, B2). They are served at GET /v1/photos/:id and locked once the item is verified.

POST /v1/fit/check and POST /v1/fit/frames check standover clearance per discipline, plus whether the seatpost can reach saddle height (inseam Γ— 0.883, or a supplied saddle height) without breaching minimum insertion or bottoming out. Every assumption is returned with the answer. Reach and stack preference is deliberately not judged.

npm run seed loads 135 catalog parts (72 verified definitional, 63 needs_review) and 9 bikes:

  • Donor archetypes: 80s steel road, 90s rigid MTB, 2000s V-brake hardtail, 2010s 29er,Dutch city bike (Nexus 3 + coaster) ,fixed/single-speed .
  • Retail bikes: Trek Marlin 5 Gen 2, Giant Escape 3, Decathlon Triban RC 120.
  • Kits: Bafang BBS02 conversion (motor, crank arms, Hailong-style battery, display) and a cable dropper + lever.

Generic/definitional parts are seeded as verified. Branded and bike-specific values were entered from general knowledge and are needs_review. That includes derailleur capacities, frame/fork geometry and A2C, chainlines, caliper rotor-thickness ranges, BBS02 specs and the Nexus hub's spacing. Verify them against manufacturer sheets before relying on the no-return promise.

Workshop UI: /app/ (see above). Interactive docs: open http://localhost:3000/docs (Swagger UI, "Try it out" enabled). The OpenAPI JSON is at /docs/json; import it into Postman/Insomnia or generate a typed client for the e-commerce app. Request schemas are generated from the same Zod schemas the handlers validate with, so they can't drift, and a test fails if a route is added without docs. GET / returns a JSON index, or redirects browsers to /docs.

| GET /v1/registry | Part types, slots, required fields, measurements, standards, connections | | POST /v1/compat/check | Stateless pair or whole-build check | | GET/POST /v1/catalog-parts ,GET/PATCH /:id ,POST /:id/verify ,GET /:id/neighbours | Catalog + graph neighbours | | GET /v1/graph/interfaces[/:port/:value] ,GET /v1/graph/export?compat=true ,POST /v1/graph/rebuild | Graph | | GET/POST /v1/bike-models ,GET /:id ,GET /:id/fits?slot= ,POST /:id/builds | Retail bikes and archetypes | | GET/POST /v1/donor-bikes ,GET /:id ,POST /:id/strip | Intake | | GET/POST /v1/inventory ,GET/PATCH /:id ,POST /:id/{categorize,link,measurements,transition} ,GET /:id/{sellability,compatible-bikes} | Stock lifecycle | | GET /v1/inventory/:id/listing?format=json\|text\|markdown | Marketplace listing: title, specs, measurements and which bikes it fits ;publishable: false with reasons until the item passes the gate | | POST /v1/inventory/:id/photos ,GET/DELETE /v1/photos/:id | Photos | | POST /v1/categorize ,GET /v1/categorizations ,POST /:id/{accept,reject} | AI queue | | POST /v1/builds ,GET /:id ,PUT/DELETE /:id/slots/:slot ,GET /:id/candidates?slot= | Frankenstein builds ( scanned /truncated reported) | | POST /v1/fit/check ,POST /v1/fit/frames | Rider fit | | GET/PUT /v1/settings/tire-rim-table | Load your verified ETRTO chart (persisted; graph rebuilt) |

Send x-api-key when API_KEYS is set and x-actor for the audit trail. Prices are integers in minor units (cents). New records use DEFAULT_CURRENCY (USD unless set); each donor and item stores its own currency.

  • Tables are only as good as their data. The cross-compatibility tables list only combinations I'm confident are commonly documented, and they stayconditional . The default tyre/rim table matches the ISO points I could confirm, but itis not the official ETRTO chart : load yours via the settings endpoint. The chainline-from-spacing table is approximate.
  • E-bike: motor-mount and system compatibility is exact-match on proprietary standards. Not checked: firmware/region speed limits, connector pinouts (flagged as a condition for generic batteries), or chainring offsets on conversion kits.
  • Untested against live services: the vision path is tested with a fake model, not a live one, and the S3 path is written but not tested against a real bucket (local storage is tested).
  • Not modelled yet: electronic shifting (Di2/AXS), pedals and cleats, rack/fender/kickstand mounts, tubeless valves, spoke/hub internals. Each is a schema field plus a connection rule; the engine and graph pick it up automatically.
  • Candidate search evaluates every graph-prefiltered row up toCANDIDATE_MAX_SCAN (default 50k) and reportstruncated if it stops.

Contributions are welcome, from new compatibility rules to catalog corrections with a source. Start with CONTRIBUTING.md and the step-by-step guide to adding a rule; open work is listed in docs/ROADMAP.md and on issues labelled good first issue. Please report security issues privately (see SECURITY.md).

Apache License 2.0. See NOTICE for attribution and bundled third-party components.

── more in #developer-tools 4 stories Β· sorted by recency
── more on @bike-0 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/bike-0-graph-backed-…] indexed:0 read:14min 2026-11-29 Β· β€”