# neoascetic/rawgithack architecture

> Architecture diagram of the GitHub repository neoascetic/rawgithack, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/neoascetic/rawgithack
- Repository: https://github.com/neoascetic/rawgithack

## Overview

##### Project Type Analysis
This is a web service that acts as a CDN for serving source code files with proper Content-Type headers. It consists of both frontend and backend components, with integration to Cloudflare and Patreon services.

##### Main Components

a. Client Layer:
- Web Browser/Git Client
- Interaction with the main service endpoint

b. Frontend Layer:
- Static website components (generated using jopa)
- Main pages: index, FAQ, and cache purge interface
- CSS and JS assets

c. Backend Service:
- Lua-based server (indicated by rawgithack.lua)
- Configuration management
- Content-Type detection and serving logic

d. External Services:
- Cloudflare integration (for CDN functionality)
- Patreon integration (for campaign management)
- GitHub (source repository interaction)

##### Specific Elements

a. Request Flow:
**Client → Cloudflare → raw.githack.com → GitHub**

b. Component Details:
- Frontend Static Site:
- Layout template (layout.jsh)
- Page components (index, FAQ, purge-cache)
- Assets (CSS/JS)

- Backend Service:
- Configuration management
- Content-Type detection
- Cache management
- Rate limiting

c. Infrastructure:
- Docker container setup
- Cloudflare CDN integration
- GitHub source repository interaction

##### Technical Details to Highlight

- Docker containerization
- Lua-based backend
- Static site generation workflow
- External service authentication flows
- Cache management system

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser/Git Client"]:::client
    end

    subgraph "Frontend Layer"
        Template["Layout Template"]:::frontend
        Pages["Static Pages"]:::frontend
        Assets["CSS/JS Assets"]:::frontend
        Search["OpenSearch"]:::frontend
    end

    subgraph "Backend Service"
        Server["Lua Server"]:::backend
        Config["Configuration"]:::backend
        ContentType["Content-Type Detection"]:::backend
        Cache["Cache Management"]:::backend
        RateLimit["Rate Limiting"]:::backend
    end

    subgraph "Infrastructure"
        Docker["Docker Container"]:::infra
        CloudflareProxy["Cloudflare CDN"]:::infra
    end

    subgraph "External Services"
        GitHub["GitHub Repository"]:::external
        Patreon["Patreon Campaign"]:::external
    end

    Browser --> CloudflareProxy
    CloudflareProxy --> Server
    Server --> GitHub
    Server --> ContentType
    Server --> Cache
    Server --> RateLimit
    Server --> Config
    Template --> Pages
    Assets --> Pages
    Search --> Pages
    Docker --> Server
    Server --> Patreon

    %% Click Events
    click Template "https://github.com/neoascetic/rawgithack/blob/master/web/layout.jsh"
    click Pages "https://github.com/neoascetic/rawgithack/tree/master/web/pages"
    click Assets "https://github.com/neoascetic/rawgithack/tree/master/web"
    click Search "https://github.com/neoascetic/rawgithack/blob/master/web/opensearch.xml"
    click Server "https://github.com/neoascetic/rawgithack/blob/master/rawgithack.lua"
    click Config "https://github.com/neoascetic/rawgithack/blob/master/rawgithack.conf"
    click Docker "https://github.com/neoascetic/rawgithack/blob/master/.docker"
    click Patreon "https://github.com/neoascetic/rawgithack/blob/master/.github/FUNDING.yml"

    %% Styles
    classDef client fill:#FFA500,stroke:#333,stroke-width:2px
    classDef frontend fill:#3498db,stroke:#333,stroke-width:2px
    classDef backend fill:#2ecc71,stroke:#333,stroke-width:2px
    classDef infra fill:#95a5a6,stroke:#333,stroke-width:2px
    classDef external fill:#e74c3c,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        Client_L["Client"]:::client
        Frontend_L["Frontend"]:::frontend
        Backend_L["Backend"]:::backend
        Infra_L["Infrastructure"]:::infra
        External_L["External Services"]:::external
    end
```
