A lightweight Express API that fetches GitHub user data, analyzes repository metrics, and stores profile summaries in a MySQL database.
server.js— Express app entry pointsrc/config/db.js— MySQL connection and schema initializationsrc/routes/githubRoutes.js— API route definitionssrc/controller/githubController.js— request handling and DB persistencesrc/services/githubService.js— GitHub API calls and repo analysisschema.sql— database table definition
-
Clone repository:
git clone https://github.com/DeShyam01/github-profile-analyzer.git cd github-profile-analyzer -
Install dependencies:
npm install
-
Create a
.envfile in the project root with these values:PORT=3000 DB_HOST=localhost DB_PORT=your_mysql_port DB_USER=root DB_PASSWORD=yourpassword DB_NAME=github_analyzer GITHUB_TOKEN=your_github_token # optional, improves GitHub rate limits
-
Start the app:
npm run start
-
Confirm the server is running:
http://localhost:3000
The application initializes the MySQL schema automatically on startup using schema.sql.
id— INT, primary key, auto-incrementusername— VARCHAR(100), unique GitHub loginname— VARCHAR(100)bio— TEXTpublic_repos— INTfollowers— INTfollowing— INTlocation— VARCHAR(100)company— VARCHAR(100)blog— VARCHAR(255)github_created_at— DATETIMEgithub_updated_at— DATETIMEtotal_stars— INTtop_language— VARCHAR(50)analyzed_at— TIMESTAMP DEFAULT CURRENT_TIMESTAMP
| Method | Path | Description |
|---|---|---|
| POST | /api/github/analyze/:username |
Fetch and analyze GitHub profile, then persist summary |
| GET | /api/github/profiles/ |
List all analyzed profiles |
| GET | /api/github/profiles/:username |
Retrieve a single analyzed profile |
Use curl, Postman, or any HTTP client.
curl -X POST http://localhost:3000/api/github/analyze/octocatExpected response:
{
"message": "Profile analyzed successfully",
"username": "octocat"
}curl http://localhost:3000/api/github/profiles/curl http://localhost:3000/api/github/profiles/octocat- The app uses
axiosto fetch GitHub data andmysql2for database access. src/config/db.jsreadsschema.sqlon startup and creates theprofilestable if it does not exist.- Providing
GITHUB_TOKENis recommended for higher GitHub API rate limits.