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