# kubernetes-bad/metachar architecture

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

- Interactive diagram: https://gitdiagram.com/kubernetes-bad/metachar
- Repository: https://github.com/kubernetes-bad/metachar

## Overview

##### Project Type & Purpose
- MetaChar is a full-stack application: It has both a backend (written in NestJS) and a frontend (React with TypeScript).
- It scrapes character data from supported sites (Chub and Janitor) and manages related assets (images, tags) while leveraging external services like MySQL (database), Minio (S3-like storage), and FlareSolverr (a request proxy).

##### File Structure
- The project is clearly divided into at least two major top-level directories: “backend” and “frontend.”
- The backend contains several modules (e.g., chars, chub, janitor, images, tags, s3) and a “lib” directory for shared API abstractions.
- The existence of Dockerfiles in both “backend” and “frontend,” along with a “docker-compose.yml” at the root, indicates containerization and orchestration.
- Configuration files (YAML files, environment examples) suggest that external dependencies (database, storage, proxy) are configurable and possibly replaceable.

##### README Insights
- The README describes the use of MySQL as the database, Minio for image storage, and FlareSolverr as a request proxy.
- It shows that the system is meant to be deployed in a Docker environment, echoing the modular containerized design.
- The instructions detail how to set up environment files for both backend and optionally separate the API backend from the frontend service.

a. Main Components:
- Frontend Service: A React application running in its container handling the user interface.
- Backend Service: A NestJS-based API server organized into separate modules:
- Chub Module (handles scraping and API endpoints for Chub-related character data)
- Janitor Module (handles scraping for Janitor content)
- Frontend Module (possibly for server-rendered endpoints or data for the frontend)
- Tags, Images, and S3 Modules (for managing associated data/assets)
- Core Shared Libraries in “lib” (contain integrations with external APIs like FlareSolverr).
- Database: MySQL, used by the backend for persistent storage.
- Storage: Minio (or S3 alternative) for image storage.
- External Service: FlareSolverr as the request proxy (enables the scraping mechanism).

b. Relationships & Interactions:
- The Frontend Service interacts with the Backend Service through defined API endpoints.
- The Backend Service, made up of various modules, fetches/saves data into the MySQL database.
- For image handling, backend components communicate with the S3/Minio storage.
- Scraping operations in the Chub and Janitor modules are facilitated by calls to external APIs, such as FlareSolverr.
- The Docker Compose file shows these services are orchestrated together, so data flow between containers (e.g., backend calling database/storage/proxy) must be represented.

c. Architectural Patterns & Principles:
- Modular Design: Each backend module (e.g., chub, janitor, tags) encapsulates its own responsibilities.
- Separation of Concerns: Frontend and backend are separated, with clear API contracts.
- Containerization: Use of Docker for isolated services and clear dependency boundaries.
- Configuration Flexibility: External configuration via environment files and YAML files allows for pluggable components.

d. Key Technologies/Frameworks:
- NodeJS and NestJS for the backend.
- React with TypeScript for the frontend.
- MySQL for the database.
- Minio for object storage.
- Docker and Docker Compose for container orchestration.
- FlareSolverr to bypass request challenges (used by scraper modules).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Orchestration & Configuration
    subgraph "Orchestration & Configuration"
        DC1["Docker Compose"]:::orchestration
        BDF["Backend Dockerfile"]:::orchestration
        FDF["Frontend Dockerfile"]:::orchestration
    end

    %% Services
    subgraph "Services"
        FS["Frontend Service (React)"]:::frontend
        BS["Backend Service (NestJS API)"]:::backend
    end

    %% Backend Internal Modules
    subgraph "Backend Modules"
        CHUB["Chub Module"]:::module
        JAN["Janitor Module"]:::module
        FRT["Frontend Module"]:::module
        TAGS["Tags Module"]:::module
        IMG["Images Module"]:::module
        S3["S3 Module"]:::module
        SHARED["Core Shared Libs"]:::shared
    end

    %% External Dependencies
    subgraph "External Services"
        MYSQL["MySQL Database"]:::db
        MINIO["Minio/S3 Storage"]:::storage
        FSOLV["FlareSolverr Proxy"]:::proxy
    end

    %% Connections from Orchestration to Services
    DC1 -->|"deploys"| FS
    DC1 -->|"deploys"| BS
    BDF -->|"builds"| BS
    FDF -->|"builds"| FS

    %% Service Interactions
    FS -->|"API_calls"| BS
    BS -->|"CRUD"| MYSQL
    BS -->|"asset-storage"| MINIO

    %% Backend Service to Modules
    BS --> CHUB
    BS --> JAN
    BS --> FRT
    BS --> TAGS
    BS --> IMG
    BS --> S3
    BS --> SHARED

    %% Module Internal Dependencies
    CHUB -->|"scrapes_using"| FSOLV
    JAN -->|"scrapes_using"| FSOLV
    IMG -->|"stores"| MINIO
    S3 -->|"interfaces_with"| MINIO

    CHUB ---|"uses"| SHARED
    JAN ---|"uses"| SHARED
    FRT ---|"uses"| SHARED
    TAGS ---|"uses"| SHARED
    IMG ---|"uses"| SHARED
    S3 ---|"uses"| SHARED

    %% Click Events
    click FS "https://github.com/kubernetes-bad/metachar/tree/main/frontend/"
    click BS "https://github.com/kubernetes-bad/metachar/blob/main/backend/src/app.module.ts"
    click BDF "https://github.com/kubernetes-bad/metachar/tree/main/backend/Dockerfile"
    click CHUB "https://github.com/kubernetes-bad/metachar/tree/main/backend/src/chub/"
    click JAN "https://github.com/kubernetes-bad/metachar/tree/main/backend/src/janitor/"
    click FRT "https://github.com/kubernetes-bad/metachar/tree/main/backend/src/frontend/"
    click TAGS "https://github.com/kubernetes-bad/metachar/tree/main/backend/src/tags/"
    click IMG "https://github.com/kubernetes-bad/metachar/tree/main/backend/src/images/"
    click S3 "https://github.com/kubernetes-bad/metachar/tree/main/backend/src/s3/"
    click SHARED "https://github.com/kubernetes-bad/metachar/tree/main/backend/src/lib/"
    click DC1 "https://github.com/kubernetes-bad/metachar/blob/main/docker-compose.yml"
    click FDF "https://github.com/kubernetes-bad/metachar/tree/main/frontend/Dockerfile"

    %% Styles
    classDef frontend fill:#D0E8F2,stroke:#1E90FF,stroke-width:2px;
    classDef backend fill:#F2D0D0,stroke:#FF4500,stroke-width:2px;
    classDef module fill:#E0F7DA,stroke:#32CD32,stroke-width:2px;
    classDef shared fill:#FFF2CC,stroke:#DAA520,stroke-width:2px;
    classDef orchestration fill:#E2E2E2,stroke:#696969,stroke-width:2px;
    classDef db fill:#FFFACD,stroke:#DAA520,stroke-width:2px;
    classDef storage fill:#CDEAC0,stroke:#228B22,stroke-width:2px;
    classDef proxy fill:#D9E8FB,stroke:#4169E1,stroke-width:2px;
```
