How rmncldyo/github-stats-checker works
Project Type and Purpose
• This is an open-source Python command-line tool (“GitHub Stats Checker”) that fetches and analyzes GitHub user profile and repository statistics via the GitHub REST API. It is not a web app or microservices platform, but a layered CLI utility with clear separation of concerns.
File-Structure Analysis
• Top-level
• example.py: entry-point demo script
• config.yaml: default behavior settings
• example.env: sample environment for GITHUB_ACCESS_TOKEN
• README.md, LICENSE, requirements.txt
• Package “github/”
• core/: orchestration (main.py, run.py)
• api/: thin GitHub API client (github_client.py)
• http/: HTTP layer (client.py, exceptions.py)
• services/: business-logic layer (auth_service, user_service, repository_service)
• utils/: config loader (config.py), URL parsing (url_parser.py)
• GitHub-related CI/CD and governance files under .github/
Key Insights from README
• Usage: import github; github.crawl()
• Optional authentication via environment or .env for private repos
• Behavior customization via config.yaml (repo_limit, include_private_repos, etc.)
• Error types: TokenError, ConfigError, RateLimitError, NetworkError, ValidationError
Components
a. Main Components
• CLI Interface (example.py or direct module import)
• Core Orchestrator (github/core/main.py & run.py)
• Configuration Loader (github/utils/config.py + config.yaml + environment variables)
• Services Layer
– AuthService: manages token injection, authentication errors
– UserService: fetches user profile stats
– RepositoryService: fetches repo stats
• API Client Layer (github/api/github_client.py)
• HTTP Client (github/http/client.py + exceptions)
• External System: GitHub REST API
b. Relationships & Data Flow
1. CLI triggers Core.run()
2. Core loads configuration via ConfigLoader
3. Core calls Services (AuthService → UserService & RepositoryService)
4. Each Service uses API Client
5. API Client delegates HTTP calls to HTTP Client
6. HTTP Client performs REST calls to GitHub API and returns JSON
7. Services process JSON and return domain objects or stats back to Core
8. Core aggregates results, applies formatting, and outputs to user
c. Architectural Patterns/Principles
• Layered architecture: separate config, orchestration, service logic, API client, transport
• Single responsibility per module
• Dependency inversion: services depend on interfaces of API client, not on HTTP layer directly
• Config-driven behavior for flexibility
d. Technologies/Frameworks
• Python 3.x
• requests (HTTP client dependency in requirements.txt)
• PyYAML (for config.yaml parsing)
• python-dotenv (optional, for .env support)
• GitHub REST API v3