A production-ready Node.js backend service that analyzes GitHub user profiles using the GitHub REST API, generates developer insights, and persists the results in a MySQL database for fast querying and analytics.
GitHub Profile Analyzer is a RESTful API built with Node.js, Express.js, MySQL, and the GitHub Public API.
The service allows users to:
- Synchronize GitHub profiles into a local database
- Generate repository-based developer insights
- Store profile analytics for future access
- Search developers by primary programming language
- Retrieve top influencers based on GitHub stars
- Generate ecosystem-level analytics
- Avoid unnecessary GitHub API calls using change detection
The application follows a layered architecture with clear separation between:
- Controllers
- Services
- Repositories
- Middleware
- Utilities
- Database Layer
Fetches public GitHub profile information and repository metadata.
Example:
POST /api/users/sync/octocatCollected profile data includes:
- GitHub ID
- Username
- Name
- Company
- Blog
- Location
- Public Repository Count
- Followers
- Following
The system analyzes repositories and generates:
| Insight | Description |
|---|---|
| Total Stars | Sum of stars across all repositories |
| Total Forks | Sum of forks across all repositories |
| Top Language | Most frequently used language |
| Repository Count | Public repository count |
| Followers | Social influence metric |
Example:
{
"totalStars": 1540,
"totalForks": 231,
"topLanguage": "TypeScript"
}Before processing repositories, the application compares:
stored.updated_at === github.updated_at;If no changes are detected:
{
"status": "UNCHANGED",
"message": "GitHub profile unchanged"
}This reduces:
- GitHub API consumption
- Response time
- Rate-limit exposure
Fetch previously synchronized profiles without contacting GitHub.
GET /api/users/local/:usernameProvides system-wide analytics.
GET /api/users/analyticsReturns:
- Total synced users
- Average repositories
- Ecosystem impact score
- Top influencer
GET /api/users/top?limit=10Ranks users by:
total_stars DESCGET /api/users/search?language=TypeScriptFind developers whose primary language matches the requested ecosystem.
GET /healthReturns:
- Uptime
- Memory usage
- Node version
- Database status
- Timestamp
Client
|
v
Routes
|
v
Controllers
|
v
Services
|
v
Repositories
|
v
MySQL Database
Responsible for:
- URL mapping
- Validation middleware
- Controller delegation
Files:
src/routes/
├── userRoutes.js
└── healthRoutes.js
Handle HTTP requests and responses.
Files:
src/controllers/
├── userController.js
└── healthController.js
Contain business logic.
Files:
src/services/
├── githubService.js
├── insightService.js
├── syncService.js
└── userService.js
Responsibilities:
- GitHub communication
- Insight generation
- Synchronization workflow
- Analytics processing
Handles database operations.
src/repositories/
└── userRepository.js
src/middleware/
├── errorMiddleware.js
└── validateRequest.js
Provides:
- Global error handling
- Request validation
src/utils/
├── AppError.js
├── asyncHandler.js
├── githubErrorHandler.js
└── validateUser.js
github-profile-analyzer/
│
├── src/
│ ├── config/
│ │ ├── env.js
│ │ └── githubClient.js
│ │
│ ├── controllers/
│ │ ├── healthController.js
│ │ └── userController.js
│ │
│ ├── db/
│ │ ├── connection.js
│ │ └── connectWithRetry.js
│ │
│ ├── middleware/
│ │ ├── errorMiddleware.js
│ │ └── validateRequest.js
│ │
│ ├── repositories/
│ │ └── userRepository.js
│ │
│ ├── routes/
│ │ ├── healthRoutes.js
│ │ └── userRoutes.js
│ │
│ ├── services/
│ │ ├── githubService.js
│ │ ├── insightService.js
│ │ ├── syncService.js
│ │ └── userService.js
│ │
│ ├── tests/
│ │ └── user.test.js
│ │
│ ├── utils/
│ │ ├── AppError.js
│ │ ├── asyncHandler.js
│ │ ├── githubErrorHandler.js
│ │ └── validateUser.js
│ │
│ └── app.js
│
├── docker-compose.yml
├── dockerfile
├── init.sql
├── package.json
└── README.md
- Node.js
- Express.js
- MySQL 8
- Zod
- Axios
- Axios Retry
- Helmet
- Express Rate Limit
- Morgan
- Jest
- Supertest
- Docker
- Docker Compose
Adds security headers:
app.use(helmet());max: 100 requests
window: 15 minutesProtects API from abuse.
Implemented using Zod.
Example:
usernameSchema;Validates:
- Length
- Format
- Consecutive hyphens
- Illegal characters
10kbProtection against payload abuse.
All environment variables are validated at startup.
Application fails fast if required variables are missing.
CREATE TABLE github_users (
github_id BIGINT PRIMARY KEY,
login VARCHAR(255) UNIQUE,
name VARCHAR(255),
company VARCHAR(255),
blog VARCHAR(500),
location VARCHAR(255),
public_repos INT,
followers INT,
following INT,
total_stars INT,
total_forks INT,
top_language VARCHAR(100),
created_at DATETIME,
updated_at DATETIME,
synced_at TIMESTAMP
);idx_login
idx_language
idx_stars
idx_synced_atOptimized for:
- User lookups
- Language search
- Rankings
- Recent synchronization queries
The project includes a comprehensive Postman collection covering:
- Health checks
- Profile synchronization
- Validation testing
- Analytics endpoints
- Search functionality
- Error handling scenarios
- Open Postman
- Click Import
- Select:
postman/GitHub-Profile-Analyzer.postman_collection.json
{
"base_url": "http://localhost:5000"
}For deployed environments:
{
"base_url": "https://github-profile-analyzer-production.up.railway.app"
}GET /health{
"success": true,
"database": "connected"
}POST /api/users/sync/octocat{
"success": true,
"status": "UPDATED"
}GET /api/usersGET /api/users/local/octocatGET /api/users/analyticsGET /api/users/top?limit=5GET /api/users/search?language=TypeScriptCreate a .env file:
PORT=5000
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=root
DB_NAME=githubdb
GITHUB_TOKEN=your_github_tokengit clone <repository-url>
cd github-profile-analyzernpm installcp .env.example .envUpdate values.
mysql -u root -pCreate database:
CREATE DATABASE githubdb;Run schema:
mysql -u root -p githubdb < init.sqlDevelopment:
npm run devProduction:
npm startdocker compose up --buildServices:
| Service | Port |
|---|---|
| API | 5000 |
| MySQL | 3306 |
docker compose downFrameworks:
- Jest
- Supertest
Run:
npm testThe project has been successfully tested against:
✓ Standard user synchronization
✓ High-volume organization accounts
✓ Enterprise repositories
✓ Repeat sync cache detection
✓ Invalid username
✓ Consecutive hyphens
✓ Length violations
✓ Illegal characters
✓ Empty language query
✓ Invalid limits
✓ Fetch all users
✓ Fetch local user
✓ Missing user handling
✓ Analytics summary
✓ Top influencers
✓ Custom limit values
✓ Language ecosystem filtering
✓ Health endpoint
✓ Database connectivity
✓ Runtime metadata
Centralized error architecture.
Examples:
{
"success": false,
"message": "GitHub user not found"
}{
"success": false,
"message": "Invalid GitHub username format"
}{
"success": false,
"message": "GitHub API rate limit exceeded"
}Optimized search and ranking queries.
connectionLimit: 10;GitHub API requests automatically retry transient failures.
Avoids unnecessary synchronization operations.
Potential enhancements:
- Redis caching layer
- GitHub GraphQL API integration
- Historical profile tracking
- Scheduled background synchronization
- Pagination support
- OpenAPI / Swagger documentation
- Authentication & RBAC
- Prometheus metrics
- CI/CD pipeline
- GitHub Actions deployment
| Requirement | Status |
|---|---|
| Node.js | Completed |
| Express.js | Completed |
| MySQL | Completed |
| GitHub API Integration | Completed |
| Store Insights | Completed |
| Persist Data | Completed |
| Fetch All Profiles API | Completed |
| Fetch Single Profile API | Completed |
| Docker Support | Completed |
| Validation Layer | Completed |
| Error Handling | Completed |
| Automated Testing | Completed |
| Production Hardening | Completed |
Yash Chincholi
Backend Developer
Node.js • Express.js • MySQL • REST APIs
Built as part of the GitHub Profile Analyzer Backend Engineering Assignment.