π GitHub Repository & Commit Explorer
A simple full-stack application that fetches GitHub repositories, displays commit counts, and supports filtering by language and stars. This project uses: Backend: Node.js, Express, Axios Frontend: HTML, CSS, Vanilla JavaScript
π Features β Fetch all repositories of a user-> Uses /users/:username/repos β Fetch commit count of a specific repository-> Uses /repos/:username/:repo/commits β Filters implemented
- Language filter β Show repos of a selected programming language
- Star sorting β Sort repos based on star count (High β Low)
β Robust Error Handling Network failures, Timeout handling, Invalid JSON responses, Malformed fields, GitHub API rate-limit or token errors
π οΈ Setup Instructions 1οΈβ£ Create a remote repository(Global Trend) Creating local folder(GLOBAL Trend) -> frontend and backend folder inside it.
2οΈβ£ Backend Setup (Node.js) Install dependencies(express, cors, axios, dotenv) cd backend npm install
Create .env file GITHUB_TOKEN=your_github_token GITHUB_USERNAME=your_github_username PORT=5000
Start the backend:- nodemon index.js Backend runs on: http://localhost:5000/
3οΈβ£ Frontend Setup Simply open: frontend/index.html
π API Endpoints Used
- Get all repositories
GET /api/repos
Optional Query Params Param Type Description
language string Filter by programming language sort string stars to sort by stars search string Search repos by name
Example /api/repos?language=JavaScript&sort=stars
-
Get details of a single repo GET /api/repos/:repoName Returns: id, name, description, stars, forks, createdAt, language
-
Get commit count GET /api/commits/:repoName Returns:
{ "repo": "AnimatedWebsites", "totalCommits": 42 }
π§ How Filtering Works Language Filter
Extracts all unique languages from repo list
Filters only repos matching selected language
Star Filter
sort=stars
β Sorts repos by stargazers_count (descending)
βοΈ Assumptions & Notes β GitHub Token Required GitHub API limits unauthenticated requests β So a Personal Access Token is mandatory.
β Rate-Limits & Token Errors If token expires or GitHub blocks due to rate-limit, UI displays: β Error: API Rate Limit / Invalid Token
β Commit Count Logic GitHub API returns commits in pages; for simplicity: /commits endpoint is used with default pagination.
β Network Safety Frontend includes: Timeout system (7 seconds) JSON parsing validation Graceful error messages
β Malformed API Fields If any field like language or stars is missing β handled safely.