# felirian/flux architecture

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

- Interactive diagram: https://gitdiagram.com/felirian/flux
- Repository: https://github.com/felirian/flux

## Overview

##### Project Type and Purpose
- This is a Next.js web application created using create-next-app.
- The project primarily serves as a full-stack web frontend, leveraging Next.js’ server-side capabilities along with React components.
- There is integration with an external service (Supabase) as indicated by the presence of a supabase directory, suggesting that backend data operations (authentication, data fetching, storage, etc.) are handled there.
- Docker-related files (.dockerignore, Dockerfile, docker-compose.yaml) and Vercel deployment configuration (vercel.json) indicate containerization and cloud deployment considerations.

##### File Structure
- Top-level configuration files (package.json, next.config.js, jsconfig.json, etc.) indicate the use of Next.js and related tooling.
- The “src” directory encompasses the bulk of the application, separated into clear subdirectories:
- "pages": Contains route-specific files which define the application’s pages for routing (e.g., account pages, item pages, error pages).
- "components": Houses reusable UI components grouped by functionality (e.g., account components, game card components, card groups, etc.).
- "style": Contains styled components definitions, SCSS files, and font settings.
- "supabase": Holds integration code and services for interfacing with the Supabase backend.
- "widgets": Contains additional UI elements and possibly more complex composite components.
- Additionally, configuration files for Docker and GitHub workflows indicate build and deployment automation.

a. Main Components:
- Next.js Server/App Layer: Representing where pages are rendered and routing logic is managed (the “pages” directory).
- Styling/Presentation Layer: Represented by the “style” directory which defines typography, container styles, and global SCSS customizations.
- Configuration & Deployment: Docker files, GitHub workflows, and environment variables represent build, deployment, and runtime configuration.
- Public Assets: “public” folder holding static files (web manifests, images, etc.) that are served directly.

b. Relationships and Interactions:
- The Next.js pages load and orchestrate the composition of various components (from “components” and “widgets”).
- Docker and GitHub actions are part of the CI/CD pipeline – these components interact at deployment time to build and ship the application to Vercel or another cloud platform.
- There is a clear flow of data: user interactions in the UI trigger backend communications, which in turn manipulate or fetch data via Supabase.

c. Architectural Patterns or Design Principles:
- Component-based architecture: Using React/Next.js’s emphasis on modular, reusable UI components.
- Separation of concerns: Dividing routing, UI components, styling, and external service interactions into dedicated directories.
- Environment-based deployment: Use of Docker, GitHub workflows, and Vercel for streamlined containerized builds and deployments.
- Use of React Context (as seen in “src/shared/Context.js”) for managing state across components.

d. Relevant Technologies, Frameworks, or Libraries:
- Next.js for rendering, routing, and overall structure.
- React for component management.
- Supabase for handling backend data operations.
- Docker for containerization.
- Styled Components/SCSS for styling and theming.
- Vercel for deployment.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        P["Next.js App Layer (Pages)"]:::frontend
        C["UI Components"]:::frontend
        W["UI Widgets"]:::frontend
        S["Styling/Presentation Layer"]:::frontend
        CT["Global State Management (React Context)"]:::frontend
        PA["Public Assets"]:::assets
    end

    %% Backend/Data Service
    subgraph "Backend/Data Service"
        DB["Data/Service Layer (Supabase Integration)"]:::backend
    end

    %% Configuration & Deployment Layer
    subgraph "Configuration & Deployment"
        Dep["Configuration & Deployment"]:::deployment
        D1["Dockerfile"]:::deployment
        D2["docker-compose.yaml"]:::deployment
        D3[".github/workflows/docker-image.yml"]:::deployment
        D4["vercel.json"]:::deployment
        V["Vercel Deployment"]:::deployment
        Dep -->|"build"| V
    end

    %% Relationships within Frontend
    P -->|"renders"| C
    P -->|"renders"| W
    P -->|"managesState"| CT
    P -->|"appliesStyles"| S
    P -->|"serves"| PA

    %% Interaction between Frontend and Backend
    C -->|"fetchesData"| DB
    W -->|"fetchesData"| DB

    %% Build and Deployment Trigger
    P -->|"triggersBuild"| Dep

    %% Click Events for Component Mapping
    click P "https://github.com/felirian/flux/tree/main/src/pages"
    click C "https://github.com/felirian/flux/tree/main/src/components"
    click W "https://github.com/felirian/flux/tree/main/src/widgets"
    click S "https://github.com/felirian/flux/tree/main/src/style"
    click CT "https://github.com/felirian/flux/blob/main/src/shared/Context.js"
    click DB "https://github.com/felirian/flux/blob/main/src/supabase/services.js"
    click PA "https://github.com/felirian/flux/tree/main/public"
    click D1 "https://github.com/felirian/flux/tree/main/Dockerfile"
    click D2 "https://github.com/felirian/flux/blob/main/docker-compose.yaml"
    click D3 "https://github.com/felirian/flux/blob/main/.github/workflows/docker-image.yml"
    click D4 "https://github.com/felirian/flux/blob/main/vercel.json"

    %% Styles
    classDef frontend fill:#bbf,stroke:#003399,stroke-width:2px;
    classDef backend fill:#cfc,stroke:#006600,stroke-width:2px;
    classDef assets fill:#ffd,stroke:#996600,stroke-width:2px;
    classDef deployment fill:#fcc,stroke:#990000,stroke-width:2px;
```
