How bambadiagne/github-user-stats works
Main components
• API Server: Represented by the Flask application (app.py). This server handles incoming HTTP requests, processes GraphQL queries, and returns data.
• Data Query/Processing Module: The query.py script (or similar modules) likely encapsulates logic for interacting with GitHub’s APIs and processing the fetched data.
• Data Store: The users.json file acts as the local storage for the user statistics that the API returns.
• Cron Job Scheduler: GitHub Actions workflows (in .github/workflows/ - deploy.yaml and update_data.yml) are used to invoke periodic updates of user data by triggering the query.py or related scripts.
• Containerization Infrastructure: The Dockerfile indicates that the API is containerized for deployment.
• External Clients: Consumers (e.g., web or mobile applications, or even command-line tools) that issue GET requests to endpoints like /users/contributions/senegal, /users/search, and /users/:username.
• Environment & Configuration: Environment variables such as GITHUB_TOKEN and FLASK_DEBUG play key roles in the setup and production/development behavior.
Relationships and Interactions
• The Client makes HTTP requests to the API server running the Flask application.
• When a client request is received, the API server uses its GraphQL layer to process the request. In some cases, it may pull or update data from the local users.json file.
• Independently, GitHub Actions (triggered by cron jobs) periodically execute update procedures (likely encapsulated in query.py) to fetch fresh statistics from GitHub’s API. This process uses the provided GitHub token for authentication and updates the users.json file.
• The Docker container wraps the entire application, making it easy to deploy across environments.
• External GitHub endpoints (the actual GitHub API) are accessed during data fetch operations.
Architectural Patterns and Design Principles
• Separation of Concerns: The system divides responsibilities among the API server, data update processes, and the external integrations.
• Containerization: Docker ensures an isolated, consistent deployment environment.
• Event-Driven Updates: The use of GitHub Actions for scheduled cron jobs adds a reactive element to data updates.
• API Layer Abstraction: Using Flask with GraphQL abstracts the client interface from direct data-access complexities.
Relevant Technologies
• Flask for the API server.
• GraphQL for querying user data.
• Docker for containerization.
• GitHub Actions (cron jobs) for scheduling periodic updates.
• Python as the primary development language.
• Environment variables for configuration management.