Powerful code analysis engine for repository insights
Deep Git history analysis β’ Hotspot detection β’ Ownership tracking
Complexity metrics β’ Code quality scanning β’ Automated insights
Features β’ Quick Start β’ API Reference β’ Deployment
|
Deep analysis of Git history with commit-level granularity. Identify high-risk files based on change frequency and complexity. Map code ownership and calculate bus factor risks. |
Track cyclomatic complexity trends over time. SonarQube-style analysis for JavaScript/TypeScript. Automated recommendations based on codebase patterns. |
- Bun v1.0+
- PostgreSQL database
- Redis instance
# Clone the repository
git clone https://github.com/sanketpatel32/code-archaeology-backend.git
cd code-archaeology-backend
# Install dependencies
bun install
# Set up environment
cp .env.example .env
# Edit .env with your credentials
# Start the API server
bun run dev
# Start the worker (separate terminal)
bun run worker| Variable | Required | Default | Description |
|---|---|---|---|
DATABASE_URL |
β | - | PostgreSQL connection string |
REDIS_URL |
β | - | Redis connection string |
PORT |
β | 3001 |
API server port |
CORS_ORIGIN |
β | * |
Allowed origins |
WORKDIR |
β | ./.data |
Clone directory |
ANALYSIS_MAX_COMMITS |
β | 5000 |
Max commits to analyze |
π All Environment Variables
# Server
PORT=3001
CORS_ORIGIN=https://your-frontend.com
WORKDIR=./.data
# Database
DATABASE_URL=postgresql://user:pass@host:5432/db
# Redis
REDIS_URL=redis://localhost:6379
# Analysis
ANALYSIS_MAX_COMMITS=5000
ANALYSIS_RECENT_DAYS=90
# Complexity
COMPLEXITY_SNAPSHOT_INTERVAL=50
COMPLEXITY_MAX_SNAPSHOTS=20
COMPLEXITY_MAX_FILES=200
COMPLEXITY_MAX_FILE_BYTES=200000
# Insights
HOTSPOT_THRESHOLD=0.6
FRAGILITY_THRESHOLD=0.6
INSIGHTS_MAX_PER_CATEGORY=5
BUS_FACTOR_TOUCH_THRESHOLD=10
BUS_FACTOR_SHARE_THRESHOLD=0.7GET /healthPOST /api/analysis
Content-Type: application/json
{
"repoUrl": "https://github.com/org/repo",
"branch": "main",
"maxCommits": 5000
}| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Health check |
POST |
/api/analysis |
Start repository analysis |
GET |
/api/repositories/:id/summary |
Repository summary |
GET |
/api/repositories/:id/hotspots |
File hotspots |
GET |
/api/repositories/:id/timeline |
Commit timeline |
GET |
/api/repositories/:id/ownership |
Ownership data |
GET |
/api/repositories/:id/complexity |
Complexity trends |
GET |
/api/repositories/:id/insights |
Automated insights |
GET |
/api/repositories/:id/quality |
Code quality report |
GET |
/api/repositories/:id/fragility |
File coupling |
src/
βββ config/ # Environment configuration
βββ lib/ # Database utilities
βββ queue/ # BullMQ job definitions
βββ routes/ # API endpoints
β βββ analysis.ts
β βββ health.ts
β βββ repositories.ts
βββ services/ # Business logic
βββ analysis.ts # Commit analysis
βββ complexity.ts # Complexity metrics
βββ insights.ts # Recommendations
βββ ownership.ts # Bus factor
βββ quality.ts # Code scanning
# Build API image
docker build -t code-archaeology-api .
# Build Worker image
docker build -f Dockerfile.worker -t code-archaeology-worker .- Create two services from this repository:
- API: Uses
Dockerfile, expose port 3001 - Worker: Uses
Dockerfile.worker, no port needed
- API: Uses
- Add environment variables to both
- Deploy!
| Feature | Status |
|---|---|
| Rate Limiting | β 100 req/min |
| Helmet Headers | β Enabled |
| CORS Protection | β Configurable |
| Non-root Docker | β Secure |
| Command | Description |
|---|---|
bun run dev |
Start API with hot reload |
bun run start |
Production API server |
bun run worker |
Background job worker |
bun run lint |
Run Biome linter |
bun run format |
Format code |
| Category | Technology |
|---|---|
| Runtime | Bun |
| Framework | Fastify 5 |
| Language | TypeScript 5 |
| Database | PostgreSQL |
| Queue | BullMQ + Redis |
| Analysis | TypeScript AST |
Built with β€οΈ by Sanket Patel
β Star this repo β’ π Report Bug β’ π‘ Request Feature