From b878d2095b9094be7627a45240fb6608b31ef44d Mon Sep 17 00:00:00 2001 From: Aditya Datta Date: Fri, 24 Jul 2026 14:48:49 +0530 Subject: [PATCH 1/5] fix import and insight side effects --- package.json | 3 ++- src/app.js | 10 +++++++-- src/utils/insightsEngine.js | 6 ++++-- test/app.test.js | 27 ++++++++++++++++++++++++ test/insightsEngine.test.js | 41 +++++++++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 test/app.test.js create mode 100644 test/insightsEngine.test.js diff --git a/package.json b/package.json index 061f642..774c1d6 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "start": "node src/app.js", "dev": "nodemon src/app.js", - "lint": "echo 'Add ESLint config as needed'" + "lint": "echo 'Add ESLint config as needed'", + "test": "node --test" }, "keywords": ["github", "api", "node", "express", "mysql"], "author": "", diff --git a/src/app.js b/src/app.js index 059057a..ff5df09 100644 --- a/src/app.js +++ b/src/app.js @@ -74,12 +74,18 @@ const PORT = process.env.PORT || 3000; async function start() { await connectDB(); - app.listen(PORT, () => { + return app.listen(PORT, () => { console.log(`🚀 Server running on http://localhost:${PORT}`); console.log(`📖 Environment: ${process.env.NODE_ENV || 'development'}`); }); } -start(); +if (require.main === module) { + start().catch((err) => { + console.error('[StartupError]', err.stack || err.message); + process.exitCode = 1; + }); +} module.exports = app; +module.exports.start = start; diff --git a/src/utils/insightsEngine.js b/src/utils/insightsEngine.js index 39eba2a..090707a 100644 --- a/src/utils/insightsEngine.js +++ b/src/utils/insightsEngine.js @@ -74,7 +74,6 @@ function computeProfileScore(user) { * Main function: derive all insights from user + repos. */ function computeInsights(user, repos) { - const now = new Date(); const sixMonthsAgo = SIX_MONTHS_AGO(); // Stars / forks @@ -87,7 +86,10 @@ function computeInsights(user, repos) { const originalRepos = repos.filter(r => !r.fork); // Most starred - const mostStarred = repos.sort((a, b) => b.stargazers_count - a.stargazers_count)[0]; + const mostStarred = repos.reduce((best, repo) => { + if (!best) return repo; + return (repo.stargazers_count || 0) > (best.stargazers_count || 0) ? repo : best; + }, null); // Activity const activeRepos = repos.filter(r => { diff --git a/test/app.test.js b/test/app.test.js new file mode 100644 index 0000000..71f0267 --- /dev/null +++ b/test/app.test.js @@ -0,0 +1,27 @@ +const assert = require('node:assert/strict'); +const { spawnSync } = require('node:child_process'); +const path = require('node:path'); +const test = require('node:test'); + +const projectRoot = path.resolve(__dirname, '..'); + +test('importing the Express app does not connect to the database or start a server', () => { + const script = ` + const database = require('./src/config/database'); + database.connectDB = async () => { + throw new Error('connectDB must not run during import'); + }; + const app = require('./src/app'); + if (typeof app !== 'function' || typeof app.start !== 'function') { + throw new Error('app and start() must be exported'); + } + `; + + const result = spawnSync(process.execPath, ['-e', script], { + cwd: projectRoot, + encoding: 'utf8', + timeout: 5_000, + }); + + assert.equal(result.status, 0, result.stderr); +}); diff --git a/test/insightsEngine.test.js b/test/insightsEngine.test.js new file mode 100644 index 0000000..0b03255 --- /dev/null +++ b/test/insightsEngine.test.js @@ -0,0 +1,41 @@ +const assert = require('node:assert/strict'); +const test = require('node:test'); + +const { computeInsights } = require('../src/utils/insightsEngine'); + +const user = { + name: 'Example User', + bio: 'Developer', + avatar_url: 'https://avatars.githubusercontent.com/u/1', + location: null, + blog: '', + email: null, + company: null, + twitter_username: null, + hireable: false, + public_repos: 3, + followers: 10, + following: 2, +}; + +test('computing insights preserves repository order', () => { + const repos = [ + { name: 'recent', stargazers_count: 1, forks_count: 0, watchers_count: 1, fork: false, pushed_at: new Date().toISOString() }, + { name: 'popular', stargazers_count: 50, forks_count: 3, watchers_count: 50, fork: false, pushed_at: new Date().toISOString() }, + { name: 'older', stargazers_count: 5, forks_count: 1, watchers_count: 5, fork: true, pushed_at: '2020-01-01T00:00:00Z' }, + ]; + const originalOrder = repos.map((repo) => repo.name); + + const insights = computeInsights(user, repos); + + assert.deepEqual(repos.map((repo) => repo.name), originalOrder); + assert.equal(insights.most_starred_repo, 'popular'); + assert.equal(insights.most_starred_count, 50); +}); + +test('empty repository lists produce null most-starred details', () => { + const insights = computeInsights({ ...user, public_repos: 0 }, []); + + assert.equal(insights.most_starred_repo, null); + assert.equal(insights.most_starred_count, 0); +}); From 706a84283d654544cf3278561215e59525dfad03 Mon Sep 17 00:00:00 2001 From: ADITYA <59918965+adity982@users.noreply.github.com> Date: Mon, 27 Jul 2026 11:24:31 +0530 Subject: [PATCH 2/5] chore: sync package.json with main --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 774c1d6..066a341 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,11 @@ "scripts": { "start": "node src/app.js", "dev": "nodemon src/app.js", - "lint": "echo 'Add ESLint config as needed'", + "lint": "node --check src/app.js && node --check src/utils/githubClient.js && node --check src/utils/insightsEngine.js", "test": "node --test" }, "keywords": ["github", "api", "node", "express", "mysql"], - "author": "", + "author": "Aditya Datta", "license": "ISC", "dependencies": { "axios": "^1.9.0", From b182702c3ca59872a91ba336ecc767c1a3d686b8 Mon Sep 17 00:00:00 2001 From: ADITYA <59918965+adity982@users.noreply.github.com> Date: Mon, 27 Jul 2026 11:24:33 +0530 Subject: [PATCH 3/5] chore: sync src/utils/insightsEngine.js with main --- src/utils/insightsEngine.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/insightsEngine.js b/src/utils/insightsEngine.js index 090707a..7dea326 100644 --- a/src/utils/insightsEngine.js +++ b/src/utils/insightsEngine.js @@ -85,7 +85,7 @@ function computeInsights(user, repos) { const forkedRepos = repos.filter(r => r.fork); const originalRepos = repos.filter(r => !r.fork); - // Most starred + // Most starred (reduce instead of sorting so callers keep their repo order) const mostStarred = repos.reduce((best, repo) => { if (!best) return repo; return (repo.stargazers_count || 0) > (best.stargazers_count || 0) ? repo : best; @@ -98,8 +98,8 @@ function computeInsights(user, repos) { }); // Languages & topics - const topLanguages = computeLanguages(repos); - const topicsUsed = computeTopics(repos); + const topLanguages = computeLanguages(repos); + const topicsUsed = computeTopics(repos); const languageDiversity = topLanguages.length; // Profile completeness From f50267fabf2c1dced566fcda6d45518b214f1380 Mon Sep 17 00:00:00 2001 From: ADITYA <59918965+adity982@users.noreply.github.com> Date: Mon, 27 Jul 2026 11:24:36 +0530 Subject: [PATCH 4/5] chore: sync test/insightsEngine.test.js with main --- test/insightsEngine.test.js | 98 +++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 26 deletions(-) diff --git a/test/insightsEngine.test.js b/test/insightsEngine.test.js index 0b03255..9767e64 100644 --- a/test/insightsEngine.test.js +++ b/test/insightsEngine.test.js @@ -1,41 +1,87 @@ -const assert = require('node:assert/strict'); const test = require('node:test'); +const assert = require('node:assert/strict'); const { computeInsights } = require('../src/utils/insightsEngine'); -const user = { - name: 'Example User', - bio: 'Developer', - avatar_url: 'https://avatars.githubusercontent.com/u/1', - location: null, - blog: '', - email: null, - company: null, - twitter_username: null, - hireable: false, - public_repos: 3, - followers: 10, - following: 2, -}; - -test('computing insights preserves repository order', () => { +function completeEnoughUser(overrides = {}) { + return { + name: 'Ada Example', + bio: 'Builds useful developer tools', + avatar_url: 'https://avatars.githubusercontent.com/u/1?v=4', + location: null, + blog: null, + email: null, + company: null, + twitter_username: null, + hireable: false, + public_repos: 2, + followers: 12, + following: 3, + ...overrides, + }; +} + +test('computeInsights aggregates repository and profile metrics', () => { const repos = [ - { name: 'recent', stargazers_count: 1, forks_count: 0, watchers_count: 1, fork: false, pushed_at: new Date().toISOString() }, - { name: 'popular', stargazers_count: 50, forks_count: 3, watchers_count: 50, fork: false, pushed_at: new Date().toISOString() }, - { name: 'older', stargazers_count: 5, forks_count: 1, watchers_count: 5, fork: true, pushed_at: '2020-01-01T00:00:00Z' }, + { + name: 'starter', + stargazers_count: 2, + forks_count: 1, + watchers_count: 2, + fork: false, + language: 'JavaScript', + topics: ['github', 'api'], + pushed_at: new Date().toISOString(), + }, + { + name: 'popular', + stargazers_count: 5, + forks_count: 2, + watchers_count: 4, + fork: true, + language: 'Python', + topics: ['api'], + pushed_at: '2000-01-01T00:00:00.000Z', + }, ]; - const originalOrder = repos.map((repo) => repo.name); - const insights = computeInsights(user, repos); + const insights = computeInsights(completeEnoughUser(), repos); - assert.deepEqual(repos.map((repo) => repo.name), originalOrder); + assert.equal(insights.total_stars_received, 7); + assert.equal(insights.total_forks_received, 3); + assert.equal(insights.total_watchers, 6); + assert.equal(insights.avg_stars_per_repo, 3.5); + assert.equal(insights.forked_repos_count, 1); + assert.equal(insights.original_repos_count, 1); assert.equal(insights.most_starred_repo, 'popular'); - assert.equal(insights.most_starred_count, 50); + assert.equal(insights.most_starred_count, 5); + assert.equal(insights.active_repos_count, 1); + assert.deepEqual(insights.top_languages, ['JavaScript', 'Python']); + assert.deepEqual(insights.topics_used, ['api', 'github']); + assert.equal(insights.profile_score, 55); + assert.equal(insights.follower_ratio, 4); +}); + +test('computeInsights does not reorder the caller repository array', () => { + const repos = [ + { name: 'first', stargazers_count: 1, topics: [], pushed_at: '2000-01-01T00:00:00.000Z' }, + { name: 'second', stargazers_count: 20, topics: [], pushed_at: '2000-01-01T00:00:00.000Z' }, + ]; + const originalOrder = repos.map(repo => repo.name); + + const insights = computeInsights(completeEnoughUser(), repos); + + assert.equal(insights.most_starred_repo, 'second'); + assert.deepEqual(repos.map(repo => repo.name), originalOrder); }); -test('empty repository lists produce null most-starred details', () => { - const insights = computeInsights({ ...user, public_repos: 0 }, []); +test('computeInsights returns safe zero values for an empty repository list', () => { + const insights = computeInsights(completeEnoughUser({ public_repos: 0, followers: 0, following: 0 }), []); + assert.equal(insights.total_stars_received, 0); + assert.equal(insights.avg_stars_per_repo, 0); assert.equal(insights.most_starred_repo, null); assert.equal(insights.most_starred_count, 0); + assert.equal(insights.has_recent_activity, false); + assert.equal(insights.follower_ratio, 0); }); From a3b24b9aeec878a4722cdff4d2e23d58c2a45298 Mon Sep 17 00:00:00 2001 From: ADITYA <59918965+adity982@users.noreply.github.com> Date: Mon, 27 Jul 2026 11:25:08 +0530 Subject: [PATCH 5/5] docs: explain side-effect-free startup --- README.md | 344 +++++++++++++++--------------------------------------- 1 file changed, 95 insertions(+), 249 deletions(-) diff --git a/README.md b/README.md index 9f37379..ff0aa7e 100644 --- a/README.md +++ b/README.md @@ -1,328 +1,174 @@ -# 🔍 GitHub Profile Analyzer API +# GitHub Profile Analyzer API -A reference Node.js backend that fetches public GitHub profiles, computes portfolio insights, and stores analysis snapshots in MySQL. +A Node.js API that turns public GitHub profile data into useful portfolio insights and stores analysis history in MySQL. ---- +[![CI](https://github.com/adity982/github-profile-analyzer/actions/workflows/ci.yml/badge.svg)](https://github.com/adity982/github-profile-analyzer/actions/workflows/ci.yml) +[![Node.js 18+](https://img.shields.io/badge/Node.js-18%2B-339933?logo=node.js&logoColor=white)](https://nodejs.org/) +[![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](LICENSE) -## ✨ Features +## Why this project exists -| Feature | Details | -|---|---| -| **Profile Analysis** | Fetches full profile + up to 200 repos per user | -| **Rich Insights Engine** | Computes 15+ derived metrics per analysis | -| **MySQL Persistence** | Profiles + per-run snapshots stored; analysis history tracked | -| **In-Memory Cache** | Redis-free caching via `node-cache` (configurable TTL) | -| **Rate Limiting** | API-wide rate limiting via `express-rate-limit` | -| **Pagination + Search** | List endpoint supports page/limit/search/sort/order | -| **Security** | `helmet`, `cors`, input validation, parameterized queries | -| **Health Check** | `/health` endpoint for deployment monitoring | - ---- - -## 🛠️ Tech Stack - -- **Runtime**: Node.js 18+ -- **Framework**: Express.js -- **Database**: MySQL 8.x (via `mysql2/promise`) -- **External API**: GitHub REST API v3 -- **Libraries**: `axios`, `dotenv`, `helmet`, `cors`, `morgan`, `express-rate-limit`, `node-cache` +A repository count alone says little about a developer portfolio. This API combines profile and repository data into signals such as original-vs-forked work, stars and forks received, language diversity, topic usage, recent activity, and profile completeness. Each run is saved so applications can show how a profile changes over time. ---- +## Features -## 📁 Project Structure +| Feature | What it provides | +|---|---| +| Profile analysis | Public profile plus up to 200 recently updated repositories | +| Portfolio insights | Stars, forks, languages, topics, activity, and completeness metrics | +| Analysis history | MySQL snapshots for every run, not just the latest result | +| Local cache | Configurable in-memory caching without a Redis dependency | +| API protection | Helmet, CORS, request limits, validation, and parameterized queries | +| Operations | Database-aware health check and GitHub rate-limit endpoint | +| Testable startup | Import the Express app without opening a listener or connecting to MySQL | -``` -github-analyzer/ -├── src/ -│ ├── app.js # Express entry point -│ ├── config/ -│ │ └── database.js # MySQL connection pool -│ ├── controllers/ -│ │ └── profileController.js # Route handlers -│ ├── middleware/ -│ │ └── errorHandler.js # Global error + 404 handlers -│ ├── models/ -│ │ └── profileModel.js # DB queries (upsert, fetch, delete) -│ ├── routes/ -│ │ └── profileRoutes.js # Express router -│ └── utils/ -│ ├── githubClient.js # Axios-based GitHub API client -│ └── insightsEngine.js # Insight computation logic -├── sql/ -│ └── schema.sql # DB schema + view definitions -├── .env.example # Environment variable template -├── package.json -└── README.md -``` +## Quickstart ---- +### Prerequisites -## ⚙️ Setup Instructions +- Node.js 18 or newer +- MySQL 8.x +- Optional GitHub token for a higher public API rate limit -### 1. Clone the repository +### 1. Install ```bash git clone https://github.com/adity982/github-profile-analyzer.git cd github-profile-analyzer -``` - -### 2. Install dependencies - -```bash npm install ``` -### 3. Configure environment variables +### 2. Configure ```bash cp .env.example .env ``` -Edit `.env`: +Set the MySQL connection values in `.env`. `GITHUB_TOKEN` is optional; for public data, use a fine-grained token with no repository permissions. ```env PORT=3000 NODE_ENV=development - -# MySQL DB_HOST=localhost DB_PORT=3306 DB_USER=root DB_PASSWORD=yourpassword DB_NAME=github_analyzer - -# GitHub Personal Access Token (optional but recommended) -# Increases rate limit from 60 → 5000 requests/hour -# Create one at: https://github.com/settings/tokens (no scopes needed for public data) -GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx - -# Cache TTL in seconds (default: 300 = 5 min) +GITHUB_TOKEN= CACHE_TTL=300 +RATE_LIMIT_WINDOW_MS=900000 +RATE_LIMIT_MAX=100 ``` -### 4. Set up the MySQL database - -```bash -# Log into MySQL -mysql -u root -p - -# Run the schema -source /path/to/github-analyzer/sql/schema.sql; -``` - -Or directly: +### 3. Create the database ```bash mysql -u root -p < sql/schema.sql ``` -### 5. Start the server +### 4. Run ```bash -# Development (with auto-reload) -npm run dev - -# Production npm start ``` -Server starts at `http://localhost:3000` - ---- - -## 📡 API Reference - -### Base URL -``` -http://localhost:3000/api -``` - ---- +The API starts at `http://localhost:3000`. -### `POST /api/profiles/analyze/:username` -Fetch a GitHub user's profile and repos, compute insights, and store everything in the database. +### 5. Analyze a profile -**Example:** ```bash curl -X POST http://localhost:3000/api/profiles/analyze/torvalds +curl http://localhost:3000/api/profiles/torvalds ``` -**Response:** -```json -{ - "success": true, - "message": "Profile 'torvalds' analyzed and stored successfully.", - "data": { - "profile": { - "id": 1, - "username": "torvalds", - "name": "Linus Torvalds", - "public_repos": 7, - "followers": 236000, - ... - }, - "insights": { - "top_languages": ["C", "Perl"], - "total_stars_received": 210000, - "profile_score": 75, - "follower_ratio": 236000.0, - "has_recent_activity": true, - ... - } - } -} -``` - ---- - -### `GET /api/profiles` -List all analyzed profiles with their latest insights. +## API reference -**Query Parameters:** +| Method | Endpoint | Purpose | +|---|---|---| +| `POST` | `/api/profiles/analyze/:username` | Fetch, analyze, and save a public profile | +| `GET` | `/api/profiles` | List saved profiles with pagination, search, and sorting | +| `GET` | `/api/profiles/:username` | Return a profile and its latest analysis history | +| `DELETE` | `/api/profiles/:username` | Remove a profile and its snapshots | +| `GET` | `/api/github/rate-limit` | Show the current GitHub API allowance | +| `GET` | `/health` | Check server and database readiness | -| Param | Type | Default | Description | -|---|---|---|---| -| `page` | int | `1` | Page number | -| `limit` | int | `20` | Results per page (max 100) | -| `search` | string | `""` | Filter by username | -| `sortBy` | string | `last_analyzed_at` | Sort field | -| `order` | string | `DESC` | `ASC` or `DESC` | +The list endpoint accepts `page`, `limit`, `search`, `sortBy`, and `order`. Supported sort fields are `followers`, `public_repos`, `total_stars_received`, `profile_score`, `last_analyzed_at`, and `username`. -**Sort options:** `followers`, `public_repos`, `total_stars_received`, `profile_score`, `last_analyzed_at`, `username` +Example: -**Example:** ```bash -curl "http://localhost:3000/api/profiles?page=1&limit=10&sortBy=followers&order=DESC" +curl "http://localhost:3000/api/profiles?page=1&limit=10&sortBy=total_stars_received&order=DESC" ``` ---- +## Insights computed -### `GET /api/profiles/:username` -Get full stored data for a single profile, including the last 10 analysis snapshots. +- top languages and language diversity +- total and average stars and forks +- total watchers +- most-starred repository +- original and forked repository counts +- recently active repository count +- commonly used repository topics +- follower-to-following ratio +- profile completeness score with a field-by-field breakdown -```bash -curl http://localhost:3000/api/profiles/torvalds -``` +## Project structure -> Responses are cached in memory for `CACHE_TTL` seconds (default: 5 min). - ---- - -### `DELETE /api/profiles/:username` -Remove a profile and all its insight history from the database. - -```bash -curl -X DELETE http://localhost:3000/api/profiles/torvalds +```text +src/ +├── app.js # Express entry point and health route +├── config/database.js # MySQL connection pool +├── controllers/ # Request handlers +├── middleware/ # Error and 404 handling +├── models/ # Parameterized database queries +├── routes/ # API routes +└── utils/ + ├── githubClient.js # GitHub REST client and pagination + └── insightsEngine.js # Side-effect-free insight computation +sql/schema.sql # Tables, indexes, and summary view +test/ +├── app.test.js # Import/startup side-effect regression test +└── insightsEngine.test.js # Deterministic insight regression tests ``` ---- +## Validation -### `GET /api/github/rate-limit` -Check your current GitHub API rate limit status. +The regression suite is isolated from live GitHub requests and MySQL, so contributors can run it quickly and without credentials. Importing `src/app.js` is side-effect free; the database connection and HTTP listener start only when the file is executed directly or `start()` is called: ```bash -curl http://localhost:3000/api/github/rate-limit +npm run lint +npm test ``` ---- - -### `GET /health` -Health check — verifies server + database connectivity. - -```bash -curl http://localhost:3000/health -``` - ---- - -## 🧠 Insights Computed - -| Insight | Description | -|---|---| -| `top_languages` | Top 10 programming languages across all public repos | -| `language_diversity` | Count of unique languages used | -| `total_stars_received` | Sum of ⭐ across all repos | -| `total_forks_received` | Sum of forks across all repos | -| `avg_stars_per_repo` | Average stars per repo | -| `avg_forks_per_repo` | Average forks per repo | -| `most_starred_repo` | Name + count of the most starred repo | -| `forked_repos_count` | How many repos are forks (vs original) | -| `original_repos_count` | How many repos are original work | -| `has_recent_activity` | Any push in the last 6 months | -| `active_repos_count` | Number of repos updated in the last 6 months | -| `topics_used` | Top tags/topics used across repos | -| `follower_ratio` | followers / following (influence signal) | -| `profile_score` | 0–100 completeness score | -| `score_breakdown` | Per-field score breakdown (bio, avatar, blog, etc.) | - ---- - -## 🗄️ Database Schema - -Two tables + one view: - -- **`github_profiles`** — Core profile data, upserted on every analysis -- **`profile_insights`** — One row per analysis run (history preserved) -- **`profile_summary`** (VIEW) — Joins each profile with its latest insight row - -See [`sql/schema.sql`](./sql/schema.sql) for full schema with indexes. - ---- - -## 🚀 Deployment - -### Railway / Render / Fly.io - -1. Set all environment variables from `.env.example` in your platform dashboard -2. Set start command to `npm start` -3. Provision a MySQL database and point `DB_*` vars at it -4. Run `sql/schema.sql` against your production DB - -### Docker (optional) - -```dockerfile -FROM node:18-alpine -WORKDIR /app -COPY package*.json ./ -RUN npm install --omit=dev -COPY . . -EXPOSE 3000 -CMD ["npm", "start"] -``` - ---- - -## 📦 Postman Collection - -Import `GitHub_Analyzer.postman_collection.json` from the repo root. - -Set the collection variable `base_url` to your deployed or local URL. - ---- +GitHub Actions runs the same checks on Node.js 18, 20, and 22 for every pull request and every push to `main`. The regression suite covers aggregate metrics, empty profiles, recent activity, profile scoring, and input-order stability. -## ✅ Validation +For an end-to-end smoke test, start MySQL, apply `sql/schema.sql`, run the server, check `/health`, analyze a public account, and read the saved result back from `/api/profiles/:username`. -This repository currently includes a manual smoke-test path: +## Database model -1. Start MySQL and apply `sql/schema.sql`. -2. Run `npm install` and `npm start`. -3. Check `GET /health` for server and database status. -4. Analyze a public account with `POST /api/profiles/analyze/:username`. -5. Confirm the saved result with `GET /api/profiles/:username`. +- `github_profiles` stores the latest core profile fields. +- `profile_insights` stores one immutable snapshot per analysis run. +- `profile_summary` joins each profile to its latest insight row. -Automated tests and CI are not included yet; treat this as a reference implementation until that gap is closed. +See [`sql/schema.sql`](sql/schema.sql) for the complete schema. ---- +## Deployment -## 📝 Notes +The service can run on Railway, Render, Fly.io, or another Node.js host with MySQL: -- Without a `GITHUB_TOKEN`, the GitHub API allows 60 requests/hour. With a token, this increases to **5,000/hour**. Tokens for public data require no scopes. -- The `profile_insights` table keeps a full history of every analysis run, so you can track metric changes over time. -- All DB queries use parameterized statements — no SQL injection risk. +1. Provision a MySQL database. +2. Apply `sql/schema.sql` once. +3. Set the variables from `.env.example` in the platform dashboard. +4. Use `npm start` as the start command. +5. Monitor `/health` for database readiness. +## Operational notes ---- +- Anonymous GitHub API access is limited to 60 requests per hour; authenticated public requests typically allow 5,000 per hour. +- The analyzer intentionally caps repository fetching at 200 repositories per profile. +- Cached reads use the `CACHE_TTL` value and do not require Redis. +- Never commit `.env` or a GitHub token. The included `.gitignore` excludes local environment files. -## 📄 License +## License Licensed under the [ISC License](LICENSE).