# prima101112/github-copilot-report architecture

> Architecture diagram of the GitHub repository prima101112/github-copilot-report, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prima101112/github-copilot-report
- Repository: https://github.com/prima101112/github-copilot-report

## Overview

##### Main Components
- User Interface (UI): The Streamlit frontend served by the permonth.py script.
- Data Fetching/Integration Layer: The portion of the app that communicates with the GitHub API using a provided token (integrated into the app’s logic).
- Data Storage: A local SQLite database that caches/enables faster retrieval and historical trend analysis.
- Deployment/Containerization:
- Docker: A Dockerfile is available for containerized deployments.
- Kubernetes: A YAML configuration is provided for running the app on a Kubernetes cluster.
- External Dependencies and Environment: GitHub’s metrics API, environment variables (GITHUB_TOKEN, ORG_SLUG, and optionally DB_PATH).

##### Component Interactions
- Deployment: Include components for Docker and Kubernetes, clearly labeling that these are deployment methods. Indicate that configuration files are used to set up environment variables and manage secrets (for example, the GitHub token).

##### Architectural Patterns & Design Principles
- Separation of Concerns: The design clearly separates the UI, business logic/API integration, and data storage layers.
- Containerization: The Dockerfile and Kubernetes YAML demonstrate a focus on portability and deployment scalability.
- Local Data Caching: Emphasize that SQLite is used to cache metrics locally, which is important for performance and offline access.

##### Technologies and Frameworks
- Streamlit: The primary framework to build and serve the dashboard.
- SQLite: For local data storage.
- Docker & Kubernetes: For containerizing the application and managing its deployment.
- Python: The programming language used (as seen from permonth.py and requirements.txt).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Service
    GitHub["GitHub Copilot Metrics API"]:::external

    %% User Interface Layer
    subgraph "User Interface Layer"
        UI["Streamlit Dashboard (permonth.py)"]:::internal
    end

    %% Business Logic / API Integration
    subgraph "Business Logic / API Integration"
        API["API Integration (permonth.py)"]:::internal
    end

    %% Data Persistence Layer
    subgraph "Persistence / Data Layer"
        DB["SQLite Database"]:::storage
    end

    %% Deployment / Infrastructure
    subgraph "Deployment / Infrastructure"
        Docker["Docker Container"]:::deployment
        K8s["Kubernetes Configuration"]:::deployment
        Config["Environment Config"]:::config
    end

    %% Data Flow Relationships
    UI -->|"RefreshRequest"| API
    API -->|"CallsAPI"| GitHub
    API <-->|"ReadWriteCaching"| DB
    API -->|"RenderData"| UI
    Docker -->|"ContainersApp"| UI
    Docker -->|"ContainersApp"| API
    K8s -->|"Manages"| Docker
    Config -->|"SetsEnv"| API

    %% Styling Classes
    classDef internal fill:#BBDEFB,stroke:#1E88E5,stroke-width:2px;
    classDef storage fill:#C8E6C9,stroke:#43A047,stroke-width:2px;
    classDef deployment fill:#FFF9C4,stroke:#FDD835,stroke-width:2px;
    classDef external fill:#FFCDD2,stroke:#E53935,stroke-width:2px;
    classDef config fill:#D1C4E9,stroke:#7E57C2,stroke-width:2px;

    %% Click Events
    click UI "https://github.com/prima101112/github-copilot-report/blob/main/permonth.py"
    click API "https://github.com/prima101112/github-copilot-report/blob/main/permonth.py"
    click Docker "https://github.com/prima101112/github-copilot-report/tree/main/Dockerfile"
    click K8s "https://github.com/prima101112/github-copilot-report/blob/main/github-copilot-report.yaml"
    click Config "https://github.com/prima101112/github-copilot-report/blob/main/.streamlit/config.toml"
```
