Task 2: GitHub Repository Intelligence Analyzer
Objective
Build a tool that analyzes multiple GitHub repositories and generates structured intelligence reports covering activity, complexity, and learning difficulty.
Overview
The analyzer accepts one or more GitHub repository URLs as input and produces per-repository scores, metric breakdowns, structured exports, and a portfolio-level summary. It is deployed as a live web application.
Input Handling
Accepts one or more GitHub repository URLs. Each URL is validated and sanitized through Zod before processing. Repositories are analyzed independently so a single failure does not block the rest of the batch.
GitHub API Integration
Uses Octokit with the throttling plugin to collect stars, forks, contributors, recent commits, languages, file trees, and dependency manifests. Authenticated requests via a GitHub token raise the rate limit to 5,000 requests/hour.
Activity Scoring
A weighted formula combining recent commits (40%), stars (25%), forks (15%), contributors (10%), and open issues (10%). Logarithmic normalization prevents mega-repositories from dominating the scale.
Complexity Estimation
Estimates maintenance cost using file count (30 pts), language diversity (30 pts), dependency file presence (20 pts), and dependency count (20 pts). All metrics are normalized and capped to produce a 0-100 score.
Difficulty Classification
The combined score (average of activity and complexity) maps to three levels: Beginner (under 35), Intermediate (35 to 65), and Advanced (above 65). Each level includes a plain-language description.
Edge Cases and Rate Limits
Repositories with missing data receive safe defaults instead of failing. The Octokit throttling plugin enforces rate-limit compliance automatically. Proactive limit checks abort the batch early when remaining quota is insufficient.
Scoring Formulas
Activity Score
| Metric | Weight | Normalization | Cap |
|---|---|---|---|
| Recent commits (30 days) | 40% | Linear | 500 |
| Stars | 25% | Logarithmic | 200,000 |
| Forks | 15% | Logarithmic | 50,000 |
| Contributors | 10% | Logarithmic | 1,000 |
| Open issues | 10% | Logarithmic | 10,000 |
Complexity Score
| Component | Max points | Method |
|---|---|---|
| File count | 30 | Log scale, cap 50,000 |
| Language diversity | 30 | Linear, cap 15 |
| Has dependency file | 20 | Binary |
| Dependency count | 20 | Linear, cap 200 |
Difficulty Classification
| Combined score | Level | Description |
|---|---|---|
| Below 35 | Beginner | Good for newcomers |
| 35 to 65 | Intermediate | Some experience needed |
| Above 65 | Advanced | Significant experience required |
Sample Results
| Repository | Activity | Complexity | Difficulty |
|---|---|---|---|
| facebook/react | 55.3 | 62.8 | Advanced |
| tensorflow/tensorflow | 48.0 | 72.0 | Advanced |
| torvalds/linux | 65.0 | 68.0 | Advanced |
| fastapi/fastapi | 42.0 | 52.0 | Intermediate |
| firstcontributions/first-contributions | 60.0 | 28.0 | Intermediate |
Architecture
Page (app/) -> View (views/) -> API Route (app/api/) -> Service (services/)| Layer | Location | Responsibility |
|---|---|---|
| Page | src/app/analyzer/page.js | Server component that only renders the view |
| View | src/views/AnalyzerView/ | Client-side state, form handling, event handlers, rendering |
| API Route | src/app/api/analyze/route.js | Validates input, sanitizes URLs, calls the service layer |
| Service | src/services/ | Server-only GitHub API fetches, scoring, caching, orchestration |
Quick Start
npm install
cp .env.example .env.local
# set GITHUB_TOKEN=ghp_your_token_here
npm run dev