REST API providing programmatic access to CodeCohesion repository analysis data.
cd api
npm install# Development mode (with hot reload)
npm run dev
# Production mode
npm run build
npm startThe API will start on port 3001 by default (or the PORT environment variable).
# Run tests once
npm test -- --run
# Run tests in watch mode
npm test
# Run tests with UI
npm run test:uiGET /- API metadataGET /health- Health check
GET /api/repos- List all repositoriesGET /api/repos?url=<github-url>- Find repository by GitHub URL
GET /api/repos/:repoId/stats- Repository statisticsGET /api/repos/:repoId/contributors?since=<date>&until=<date>- Contributors with date filteringGET /api/repos/:repoId/files?path=<prefix>&metric=<metric>- Files with filtering and sortingGET /api/repos/:repoId/hotspots?limit=<n>- Top N high-churn/high-contributor files
GET /api/contributors?url=<github-url>&days=<n>- Contributors by URL with relative date range
# List available repositories
curl http://localhost:3001/api/repos
# Get repository statistics
curl http://localhost:3001/api/repos/react-timeline-full/stats
# Get contributors in last 30 days
curl 'http://localhost:3001/api/contributors?url=https://github.com/facebook/react&days=30'
# Get top 10 hotspot files
curl 'http://localhost:3001/api/repos/react-timeline-full/hotspots?limit=10'
# Get files in src/ directory sorted by churn
curl 'http://localhost:3001/api/repos/react-timeline-full/files?path=src&metric=churn'The API reads JSON files from the api/data/ directory. To add a new repository:
# Analyze a repository using the processor
cd processor
npm run dev -- ../path/to/repo
# Copy the generated JSON to the API data directory
cp output/repo-timeline-full.json ../api/data/- Static snapshots - Single point-in-time analysis
- Timeline V2 - Full commit history with delta changes
The API automatically detects the format and extracts the necessary data.
The API is configured for Railway deployment:
- Build Command:
npm run build - Start Command:
npm start(ornode dist/server.js) - Procfile: Included for automatic detection
PORT- Server port (set automatically by Railway)
The API allows requests from:
https://thepaulrayner.com- Production viewerhttps://paulrayner.github.io- GitHub Pageshttp://localhost:3000-3003- Local development
For detailed API specifications, see:
- Vision - Goals and use cases
- Architecture - Technical design
- Specification - Endpoint documentation
- Plan - Implementation roadmap
- Runtime: Node.js 18+
- Language: TypeScript
- Framework: Express.js
- Testing: Vitest
- Deployment: Railway
MIT