{"id":29502973,"url":"https://github.com/shushantrishav/github-stats-generator","last_synced_at":"2026-05-09T09:03:58.554Z","repository":{"id":304692474,"uuid":"1019615854","full_name":"shushantrishav/github-stats-generator","owner":"shushantrishav","description":"A FastAPI application that fetches, aggregates, and caches comprehensive GitHub user statistics, including total stars, commits, contributions, and contribution streaks. It also provides the functionality to generate dynamic SVG images of these statistics, perfect for embedding in GitHub profiles or project READMEs.","archived":false,"fork":false,"pushed_at":"2025-07-14T16:57:44.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-14T21:06:58.005Z","etag":null,"topics":["docker","fastapi","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shushantrishav.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-14T15:48:34.000Z","updated_at":"2025-07-14T17:10:42.000Z","dependencies_parsed_at":"2025-07-14T21:07:34.896Z","dependency_job_id":"7cf2b2a1-d2e1-4be4-91a4-449eefbcbfa2","html_url":"https://github.com/shushantrishav/github-stats-generator","commit_stats":null,"previous_names":["shushantrishav/github-stats-generator"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/shushantrishav/github-stats-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shushantrishav%2Fgithub-stats-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shushantrishav%2Fgithub-stats-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shushantrishav%2Fgithub-stats-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shushantrishav%2Fgithub-stats-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shushantrishav","download_url":"https://codeload.github.com/shushantrishav/github-stats-generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shushantrishav%2Fgithub-stats-generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265465862,"owners_count":23770448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","fastapi","python"],"created_at":"2025-07-15T23:00:53.642Z","updated_at":"2026-05-09T09:03:58.542Z","avatar_url":"https://github.com/shushantrishav.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHub Stats API\n\nA FastAPI application that fetches, aggregates, and caches comprehensive GitHub user statistics, including total stars, commits, contributions, and contribution streaks. It also provides the functionality to generate dynamic SVG images of these statistics, perfect for embedding in GitHub profiles or project READMEs.\n\n## ✨ Features\n\n* **Comprehensive Stats**: Fetches detailed user statistics from the GitHub API (REST and GraphQL).\n* **SVG Generation**: Dynamically generates customizable SVG images of GitHub stats for visual representation.\n* **Caching**: Implements a robust caching mechanism for both JSON data and generated SVGs to minimize GitHub API calls and improve response times.\n* **Dockerized**: Easily deployable using Docker for consistent environments.\n* **Modular Design**: Structured with services and clear responsibilities for maintainability.\n* **CORS Enabled**: Configured for Cross-Origin Resource Sharing, allowing access from various front-end applications.\n\n## 🚀 Technologies Used\n\n* **FastAPI**: A modern, fast (high-performance) web framework for building APIs with Python 3.7+ based on standard Python type hints.\n* **Uvicorn**: An ASGI server, used to run the FastAPI application.\n* **Pydantic**: For data validation and settings management using Python type hints.\n* **Jinja2**: A modern and designer-friendly templating language for Python, used for SVG generation.\n* **Requests**: An elegant and simple HTTP library for Python.\n* **python-dotenv**: Loads environment variables from a `.env` file.\n* **Docker**: For containerization and easy deployment.\n\n## 🖥️ Preview\n![svg](https://github-stats-generator.onrender.com/stats/shushantrishav/svg?v=2)\n\n## 🛠️ Setup and Installation\n\nFollow these steps to get your project up and running locally.\n\n### Prerequisites\n\n* Python 3.10+\n* `pip` (Python package installer)\n* Docker (Optional, but recommended for deployment)\n* A GitHub Personal Access Token (PAT). You can generate one [here](https://github.com/settings/tokens). It needs `public_repo` (if fetching private repo data) and `read:user` permissions.\n\n### Steps\n**fork this repo\n1.  **Clone the repository:**\n    ```bash\n\n    git clone https://github.com/\u003cyour-username\u003e/github-stats-api.git\n\n    cd github-stats-api\n    ```\n    (Remember to replace `your-username` and `github-stats-api` if you rename your repository.)\n\n2.  **Create a virtual environment (recommended):**\n    ```bash\n    python -m venv venv\n    source venv/bin/activate  # On Windows: venv\\Scripts\\activate\n    ```\n\n3.  **Install dependencies:**\n    ```bash\n    pip install -r requirements.txt\n    ```\n\n4.  **Create a `.env` file:**\n    In the root directory of your project, create a file named `.env` and add your GitHub Personal Access Token:\n    ```dotenv\n    GITHUB_TOKEN=\"YOUR_ACTUAL_GITHUB_TOKEN_HERE\"\n    ```\n    **Replace `YOUR_ACTUAL_GITHUB_TOKEN_HERE` with your token.**\n\n5.  **Run the application locally:**\n    ```bash\n    uvicorn app:app --host 0.0.0.0 --port 8000 --reload\n    ```\n    The `--reload` flag is for development purposes; it will automatically restart the server on code changes. Remove it for production.\n\n    Your API will be accessible at `http://localhost:8000`.\n\n## 🐳 Docker Setup\n\nFor a consistent and isolated environment, you can use Docker.\n\n1.  **Build the Docker image:**\n    Navigate to the root of your project where the `Dockerfile` is located.\n    ```bash\n    docker build -t github-stats-api .\n    ```\n\n2.  **Run the Docker container:**\n    ```bash\n    docker run -d -p 8000:8000 --name my-github-stats-app -e GITHUB_TOKEN=\"YOUR_ACTUAL_GITHUB_TOKEN_HERE\" github-stats-api\n    ```\n    **Again, replace `YOUR_ACTUAL_GITHUB_TOKEN_HERE` with your GitHub PAT.**\n\n    The application will be running in a Docker container, accessible at `http://localhost:8000`.\n\n## 💡 API Endpoints\n\nThe API provides the following endpoints:\n\n* **Root Endpoint**:\n    * `GET /`\n    * Provides a basic HTML welcome page with API instructions.\n\n* **Get JSON Stats**:\n    * `GET /stats/{username}`\n    * Fetches comprehensive GitHub profile statistics for a given `{username}` in JSON format.\n    * **Example**: `http://localhost:8000/stats/shushantrishav`\n\n* **Get SVG Stats Image**:\n    * `GET /stats/{username}/svg`\n    * Generates a dynamic SVG image displaying the GitHub statistics for a given `{username}`.\n    * **Example**: `http://localhost:8000/stats/shushantrishav/svg`\n\n## 📊 SVG Usage (Embedding in READMEs)\n\nYou can easily embed the generated SVG into your GitHub profile README, repository READMEs, or any webpage using Markdown's image syntax or HTML `\u003cimg\u003e` tag:\n\n```markdown\n![GitHub Stats](http://localhost:8000/stats/your-github-username/svg)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshushantrishav%2Fgithub-stats-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshushantrishav%2Fgithub-stats-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshushantrishav%2Fgithub-stats-generator/lists"}