Skip to content

Amritbhardwajgsv/githubcalendarapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Calendar API

A production-ready backend API that fetches GitHub contribution data using the GitHub GraphQL API and serves it to the frontend.
Built with Node.js, Express, and secure environment variables, and deployed live on the cloud.

Live API:
https://githubcalendarapi.onrender.com/


Why This Project?

This project was built to power a real frontend application with live GitHub contribution data instead of mock or static JSON.

It represents:

  • My first fully deployed backend
  • Real API integration
  • Secure handling of secrets using .env
  • End-to-end full-stack thinking

What started as rejection became real engineering.


Tech Stack

  • Backend: Node.js, Express
  • API: GitHub GraphQL API
  • Authentication: GitHub Personal Access Token (via environment variables)
  • Deployment: Render
  • Module System: ES Modules
  • Security: .env for secrets

API Endpoint

Base URL: https://githubcalendarapi.onrender.com/

Method: GET

Description: Fetches GitHub contribution activity (last 12 months) for the configured user and returns raw GraphQL data.


Example Response

{ "data": { "user": { "contributionsCollection": { "contributionCalendar": { "weeks": [ { "contributionDays": [ { "date": "2025-01-10", "contributionCount": 3 } ] } ] } } } } }


Frontend Usage Example (React)

useEffect(() => { fetch("https://githubcalendarapi.onrender.com/") .then(res => res.json()) .then(data => { console.log(data); }) .catch(err => console.error(err)); }, []);


Environment Variables

This project uses a GitHub Personal Access Token stored securely in .env.

.env file (local): GITHUB_TOKEN=ghp_your_github_token_here

Important:

  • Never commit .env to GitHub
  • The token is injected securely during deployment (Render environment variables)

Local Setup

  1. Clone the Repository
    git clone https://github.com/your-username/github-calendar-api.git
    cd github-calendar-api

  2. Install Dependencies
    npm install

  3. Create .env
    GITHUB_TOKEN=your_github_personal_access_token

  4. Start the Server
    npm start

Server will run on:
http://localhost:5000/


Deployment

The backend is deployed using Render with:

  • Environment variables for secrets
  • Dynamic port handling via process.env.PORT

Live Version:
https://githubcalendarapi.onrender.com/


What I Learned

  • Working with real-world APIs
  • Using GraphQL in production
  • Securing secrets using environment variables
  • Handling async requests in Express
  • Debugging real backend errors
  • Deploying a live backend service
  • Connecting backend to frontend

This project marks my transition from learning backend to building real backend systems.


Future Improvements

  • Dynamic username support (/username)
  • Format response for heatmaps and charts
  • GitHub OAuth login (no tokens required)
  • Caching for better performance
  • Frontend dashboard integration

Author

Amrit Bhardwaj
Electronics & Communication Engineering Student
Backend • Frontend • Full-Stack Enthusiast

"I waited a year for this moment. I didn’t quit. I built."

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors