# grisolfi/pocci architecture

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

- Interactive diagram: https://gitdiagram.com/grisolfi/pocci
- Repository: https://github.com/grisolfi/pocci

## Overview

##### Project type and purpose
- This is a lightweight Python-based backend service that acts as a demonstration CI server.
- It registers as a GitHub App, listens for incoming webhook events, and uses the GitHub Checks API to report status back to GitHub.

##### File structure
- Top‐level:
- main.py – the HTTP server entrypoint that receives GitHub webhooks and orchestrates the workflow
- requirements.txt – lists Python dependencies (e.g., Flask or aiohttp, PyJWT, requests)
- tool/ directory:
- auth_helper.py – generates JWTs or installations tokens for authenticating as the GitHub App
- repo.py – encapsulates API calls to GitHub (creating/updating check runs)
- No database or UI components; no persistent storage.

##### README for additional insights
- Expects two env vars: GH_APPLICATION_ID and GH_PEM_FILE
- Invoked by running main.py
- Optionally uses an external tunneling service (smee.io) to forward GitHub traffic to your local host

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Systems
    GitHub["GitHub (Checks API & Webhooks)"]:::external
    Smee["smee.io (Optional Tunnel)"]:::external

    %% CI Server Subgraph
    subgraph "CI Server" 
        direction TB
        Listener["HTTP Listener\n(main.py)"]:::internal
        Auth["Auth Helper Module\n(tool/auth_helper.py)"]:::internal
        Repo["GitHub API Client\n(tool/repo.py)"]:::internal
    end

    %% Configuration
    Config["Env Config\n(GH_APPLICATION_ID, GH_PEM_FILE)"]:::config

    %% External Dependencies
    Deps["Python Dependencies\n(requirements.txt)"]:::config
    Readme["README.md"]:::config

    %% Connections
    GitHub -->|"Webhook payload (JSON)"| Listener
    Smee -->|"Forwarded Webhook"| Listener
    Listener -->|"Validate & Parse Event"| Listener
    Listener -->|"Generate JWT/Installation Token"| Auth
    Config -->|"Env Vars"| Auth
    Auth -->|"JWT/Token"| Repo
    Deps -->|"Provides frameworks\n& libraries"| Listener
    Repo -->|"POST /repos/:owner/:repo/check-runs"| GitHub

    %% Click Events
    click Listener "https://github.com/grisolfi/pocci/blob/main/main.py"
    click Auth "https://github.com/grisolfi/pocci/blob/main/tool/auth_helper.py"
    click Repo "https://github.com/grisolfi/pocci/blob/main/tool/repo.py"
    click Config "https://github.com/grisolfi/pocci/blob/main/README.md"
    click Deps "https://github.com/grisolfi/pocci/blob/main/requirements.txt"

    %% Styles
    classDef internal fill:#D6EAF8,stroke:#1F618D,stroke-width:2px;
    classDef external fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef config fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
```
