# daniiprietoo/github-pipeline architecture

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

- Interactive diagram: https://gitdiagram.com/daniiprietoo/github-pipeline
- Repository: https://github.com/daniiprietoo/github-pipeline

## Overview

##### Main Components Identification

a) Data Source Layer:
- GitHub API (external service)

b) Application Layer:
- API Handler (api_handler.py)
- Database Handler (cloud_db_handler.py)
- Main Application (main.py)

c) Storage Layer:
- Google Cloud SQL (PostgreSQL)

d) Automation Layer:
- GitHub Actions

**┌─ GitHub Actions Workflow ─┐**
- ┬───────────────┘
- ↓
**┌─ Main Application Logic ─┐**
- ┬───────────────┘
- ↓

**┌─ API Handler ─┐    ┌─ DB Handler ─┐**
- ┬────────┘    └──────┬───────┘

**┌─ GitHub API ─┐    ┌─ Google Cloud SQL ─┐**
- ┘    └───────────────────┘

##### Database Schema Representation

**┌─ Database Schema ──────────┐**
- ┌─ repositories ─────────┐ │
- repo_id              │ │
- name                 │ │
- full_name           │ │
- ┘ │ │
- ┌─ trends ──────────────┐ │
- repo_id (FK)        │ │
- stars               │ │
- forks              │ │
- ┘ │ │
- ┌─ issues_prs ──────────┐ │
- repo_id (FK)        │ │
- open_issues         │ │
- closed_issues       │ │
- ┘ │ │
- ┘

##### Additional Elements

a) Environment Configuration:
- Environment variables connection to components
- Security configurations

b) Authentication Flow:
- GitHub Token authentication
- Google Cloud SQL authentication

##### Specific Implementation Details

- The scheduled nature of the pipeline (GitHub Actions trigger)
- The separation of concerns between API handling and database operations
- The three-table database schema and their relationships
- Error handling and retry mechanisms
- Data flow direction and transformation

##### Notes for Implementation

- Keep the main flow clear and centered
- Related components together
- Use consistent sizing for similar components
- Version information for major components
- Scaling capabilities and potential bottlenecks

- Connectors with different styles
- Text formatting
- Export to various formats
- Collaboration features

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Automation Layer"
        GHA["GitHub Actions Workflow"]:::automation
    end

    subgraph "Application Layer"
        MAIN["Main Application"]:::core
        API["API Handler"]:::core
        DB["Database Handler"]:::core
    end

    subgraph "External Services"
        GHAPI["GitHub API"]:::external
        GCSQL["Google Cloud SQL"]:::external
    end

    subgraph "Database Schema"
        REPOS["Repositories Table<br/>- repo_id<br/>- name<br/>- full_name"]:::db
        TRENDS["Trends Table<br/>- repo_id (FK)<br/>- stars<br/>- forks"]:::db
        ISSUES["Issues/PRs Table<br/>- repo_id (FK)<br/>- open_issues<br/>- closed_issues"]:::db
    end

    GHA --> MAIN
    MAIN --> API
    MAIN --> DB
    API -.-> GHAPI
    DB -.-> GCSQL
    GCSQL --- REPOS
    GCSQL --- TRENDS
    GCSQL --- ISSUES
    REPOS --- TRENDS
    REPOS --- ISSUES

    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef external fill:#2ecc71,stroke:#27ae60,color:white
    classDef db fill:#f1c40f,stroke:#f39c12,color:black
    classDef automation fill:#95a5a6,stroke:#7f8c8d,color:white

    click GHA "https://github.com/daniiprietoo/github-pipeline/blob/main/.github/workflows/run_main.yml"
    click API "https://github.com/daniiprietoo/github-pipeline/blob/main/api_handler.py"
    click DB "https://github.com/daniiprietoo/github-pipeline/blob/main/cloud_db_handler.py"
    click MAIN "https://github.com/daniiprietoo/github-pipeline/blob/main/main.py"

    subgraph "Legend"
        L1["Core Components"]:::core
        L2["External Services"]:::external
        L3["Database Components"]:::db
        L4["Automation"]:::automation
    end
```
