# hanshans135/boardmate architecture

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

- Interactive diagram: https://gitdiagram.com/hanshans135/boardmate
- Repository: https://github.com/hanshans135/boardmate

## Overview

##### Project type and purpose
- This is a full-stack, monolithic web application built with Python Flask.
- Purpose: provide a user-friendly panel (“BoardMate”) for Pterodactyl server management, with features like Discord OAuth login, code redemption, an administrator backend, and a simple Admin API.

##### File structure
- app.py at project root – main Flask application entrypoint.
- /views – Flask view-functions organized by feature (admin, api, code, index, oauth, shop).
- /templates – Jinja2 HTML templates for user pages and admin pages.
- /static – CSS, JS, images, third-party assets (Tailwind, Alpine.js, Chart scripts).
- /utils – helper modules (dc.py for Discord, ptero_api.py for Pterodactyl API).
- /data – simple JSON file store (code.json, user.json).
- api.md & install.md – API documentation and install instructions.

##### Insights from README
- Core features: Chinese UI, no-pain install, automated workflows, Discord login, admin backend, exposed Admin API.
- Dependencies: Flask, Jinja2, TailwindCSS, Alpine.js, Chart.js.

##### Details
- Admin API as a separate external-facing interface.
- Common endpoints (e.g., /login → Discord OAuth flow, /shop → ptero_api calls, /admin/setting → JSON store).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        Browser["User Browser"]:::frontend
        StaticAssets["Static Asset Server"]:::frontend
        Templates["Jinja2 Templates"]:::frontend
    end

    %% Backend Layer
    subgraph "Flask Application" 
        direction TB
        App["Flask Web Server (app.py)"]:::backend

        subgraph "Routing Layer (/views)"
            direction TB
            AdminView["views/admin.py"]:::backend
            APIView["views/api.py"]:::backend
            CodeView["views/code.py"]:::backend
            IndexView["views/index.py"]:::backend
            OAuthView["views/oauth.py"]:::backend
            ShopView["views/shop.py"]:::backend
        end

        subgraph "Service Layer (/utils)"
            direction TB
            PteroService["utils/ptero_api.py"]:::service
            DiscordService["utils/dc.py"]:::service
        end

        subgraph "Templating Layer (/templates)"
            direction TB
            TemplatesSub["templates/"]:::frontend
        end
    end

    %% Data Layer
    DataStore["JSON Data Store (data/*.json)"]:::datastore

    %% External Services
    PteroAPI["Pterodactyl API"]:::external
    DiscordOAuth["Discord OAuth Service"]:::external

    %% Connections
    Browser -->|"HTTP GET/POST"| App
    Browser --> StaticAssets
    App --> TemplatesSub
    App --> AdminView
    App --> APIView
    App --> CodeView
    App --> IndexView
    App --> OAuthView
    App --> ShopView

    AdminView --> DataStore
    CodeView --> DataStore
    IndexView --> DataStore
    ShopView --> PteroService
    OAuthView --> DiscordService
    APIView --> DataStore

    PteroService --> PteroAPI
    DiscordService --> DiscordOAuth
    App --> APIView

    %% Click Events
    click App "https://github.com/hanshans135/boardmate/blob/main/app.py"
    click AdminView "https://github.com/hanshans135/boardmate/blob/main/views/admin.py"
    click APIView "https://github.com/hanshans135/boardmate/blob/main/views/api.py"
    click CodeView "https://github.com/hanshans135/boardmate/blob/main/views/code.py"
    click IndexView "https://github.com/hanshans135/boardmate/blob/main/views/index.py"
    click OAuthView "https://github.com/hanshans135/boardmate/blob/main/views/oauth.py"
    click ShopView "https://github.com/hanshans135/boardmate/blob/main/views/shop.py"
    click TemplatesSub "https://github.com/hanshans135/boardmate/tree/main/templates/"
    click PteroService "https://github.com/hanshans135/boardmate/blob/main/utils/ptero_api.py"
    click DiscordService "https://github.com/hanshans135/boardmate/blob/main/utils/dc.py"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef service fill:#98FB98,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef datastore fill:#D3D3D3,stroke:#333,stroke-width:1px
```
