This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
WormBase REST API - A Clojure-based REST API that provides widget and field endpoints for retrieving data from a Datomic database. This powers the official WormBase website (wormbase.org) for biological data about C. elegans and other nematodes.
export WB_DB_URI="datomic:ddb://us-east-1/WS298/wormbase"
lein ring server-headless 8130lein test # Run all tests
lein test-refresh # Run tests with file watching
lein test rest-api.classes.gene-test # Run a specific test namespacelein code-qa # Run linting + tests (before PRs/releases)
lein eastwood # Linting onlylein with-profile +datomic-pro,+ddb uberjar # Create jar file
make clean && make docker/app.jar # Build for Docker
make build # Build Docker image
make run # Run Docker container locallysrc/rest_api/main.clj- Defines the Ring app, Swagger API, and aggregates all routes from entity class modules
src/rest_api/db/main.clj- Mount-managed Datomic connections (main DB + homology DB)- Connection URI comes from
WB_DB_URIenvironment variable - Uses pseudoace library for Datomic utilities
src/rest_api/routing.clj- Definesdefroutesmacro and route generation- Routes are auto-generated from entity class definitions using
RouteSpecprotocol - Two endpoint types: widgets (return multiple fields) and fields (return single data points)
- URL pattern:
/rest/{widget|field}/{entity_type}/:id/{endpoint_name}
Each biological entity type (gene, protein, variation, etc.) follows this pattern:
src/rest_api/classes/
├── {entity}.clj # Route definitions using defroutes macro
└── {entity}/
├── core.clj # Shared logic (optional)
└── widgets/
├── overview.clj # Widget implementations
├── references.clj
└── ...
Example route definition (src/rest_api/classes/gene.clj):
(routing/defroutes
{:entity-ns "gene"
:widget {:overview overview/widget
:expression expression/widget ...}
:field {:alleles_other variation/alleles-other ...}})src/rest_api/classes/generic_fields.clj- Reusable field implementations (remarks, xrefs, taxonomy, etc.)src/rest_api/classes/generic_functions.clj- Shared helper functionssrc/rest_api/formatters/object.clj-pack-objfunction for consistent entity serialization
- Widget functions take a Datomic entity and return
{:data ... :description ...} pack-objstandardizes entity references with:id,:label,:class,:taxonomy- Dynamic attribute lookup using
(keyword role "attribute")pattern for generic field implementations - Evidence is attached to data using
obj/get-evidence
- Tests in
test/rest_api/classes/mirror source structure test/rest_api/db_testing.cljprovidesdb-lifecyclefixture for mount state management- Tests require
WB_DB_URIto connect to Datomic
WB_DB_URI- Datomic database URI (required)SWAGGER_VALIDATOR_URL- Local swagger validator URL (dev only, defaults to localhost:8002)