# skilvul-km4-fe8/fatkid architecture

> Architecture diagram of the GitHub repository skilvul-km4-fe8/fatkid, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/skilvul-km4-fe8/fatkid
- Repository: https://github.com/skilvul-km4-fe8/fatkid

## Overview

##### Project Type & Purpose
- This is a full-stack Next.js application (“Nextvul App”) used to manage menus and transactions with an overview dashboard.
- It implements server-side rendering (SSR), client-side components, file-based routing, API routes, and Prisma ORM for database access.

##### File-Structure Analysis
- **app/**: Next.js “App Router” directory.
- UI pages & layouts under subfolders `(auth)`, `(menu)`, `(overview)`, `(transaction)`.
- API routes under `app/api/.../route.ts`.
- **components/**: Reusable React UI and chart components.
- **features/**: Feature modules (menu, overview, transaction) organizing hooks, API-calling functions, and local components.
- **lib/**: Shared utilities and `prisma.ts` (Prisma client entry point).
- **prisma/**: Schema and migration files describing the relational database model.
- **providers/**: Context providers for dialogs, query clients, sheets.
- **config & infra**: Dockerfile, docker-compose.yml, GitHub Actions workflow for CI/CD, ESLint, Tailwind, PostCSS, TypeScript configs.

##### README Insights
- Bootstrapped with Create Next App using Next.js App Router.
- Uses next/font, targets Vercel deployment.

a. Main Components
- Browser (Client): React components, charts, forms.
- Next.js Server: Handles SSR/SSG for pages, serves static assets (fonts, CSS), and processes API route requests.
- Feature Modules: BFF-style layer in Next.js API routes (menu, overview, transaction).
- Prisma Client: Node module in lib/prisma.ts communicating with the database.
- Database: PostgreSQL (or other SQL) defined by prisma/schema.prisma and run via migrations.
- CI/CD Pipeline: GitHub Actions workflow triggers on push, builds Docker image, runs tests, and deploys.
- Docker & Docker-Compose: Containerizes Next.js app and database for local development.

b. Relationships & Data Flows
- Client ↔ Next.js Server: HTTP(S) requests for pages (SSR) and client-side API calls (`fetch('/api/...')`).
- Next.js API Routes → Prisma Client → Database: Query and mutation flows.
- Providers & Feature Hooks: In-app, React context providers supply data-fetching hooks to components.
- CI/CD → Docker Registry → Cloud Host: Push & deploy container.

c. Architectural Patterns & Principles
- File-based routing (App Router) separating page UI and API logic.
- Feature-based module grouping (features/menu, features/transaction, etc.).
- BFF (Backend-for-Frontend) in Next.js API routes.
- ORM abstraction via Prisma for maintainable database schema & migrations.
- Containerized development & deployment via Docker/Docker-Compose.
- Context-driven state & data provisioning using React providers.

d. Key Technologies & Frameworks
- Frontend: Next.js (React), Tailwind CSS, next/font.
- Backend: Node.js, Next.js API Routes, Prisma ORM.
- Database: PostgreSQL (or configured SQL engine).
- DevOps: Docker, Docker-Compose, GitHub Actions, Vercel (target).
- Utilities: ESLint, TypeScript.

- Client → Server (page/API requests)
- API Routes → Prisma → Database (query/mutation)
- GitHub Actions → Docker Build → Deployment target
- Blue for UI/frontend
- Green for server/API
- Orange for database
- Gray for DevOps pipeline
- Related elements (e.g., all feature API routes in one server-side cluster).

##### Detail & Coverage
- Break out subcomponents where important (e.g., feature-specific API routes or providers).
- Middleware (e.g., `middleware.ts`) intercepting requests if relevant.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Classes
    classDef frontend fill:#bbdefb,stroke:#1e88e5,stroke-width:2px;
    classDef backend fill:#c8e6c9,stroke:#43a047,stroke-width:2px;
    classDef database fill:#ffe0b2,stroke:#fb8c00,stroke-width:2px;
    classDef devops fill:#eeeeee,stroke:#757575,stroke-width:2px;

    %% Frontend Layer
    subgraph "Frontend (Browser)" 
        BROWSER["Browser (Client – React UI & Charts)"]:::frontend
    end
    click BROWSER "https://github.com/skilvul-km4-fe8/fatkid/tree/main/components/"

    %% Feature Modules (Frontend)
    subgraph "Feature Modules (Hooks & Logic)" 
        MENU_FEAT["Menu Module"]:::frontend
        OVERVIEW_FEAT["Overview Module"]:::frontend
        TRANSACTION_FEAT["Transaction Module"]:::frontend
    end
    click MENU_FEAT "https://github.com/skilvul-km4-fe8/fatkid/tree/main/features/menu/"
    click OVERVIEW_FEAT "https://github.com/skilvul-km4-fe8/fatkid/tree/main/features/overview/"
    click TRANSACTION_FEAT "https://github.com/skilvul-km4-fe8/fatkid/tree/main/features/transaction/"

    %% Reusable UI Components
    UI_COMPS["Reusable UI Components"]:::frontend
    click UI_COMPS "https://github.com/skilvul-km4-fe8/fatkid/tree/main/components/ui/"

    %% Next.js App Router UI Pages & Layouts
    subgraph "Next.js App Router (UI Pages & Layouts)" 
        APP_PAGES["app/"]:::backend
    end
    click APP_PAGES "https://github.com/skilvul-km4-fe8/fatkid/tree/main/app/"

    %% Auth Pages
    AUTH_SIGNIN["Sign-In Page"]:::backend
    AUTH_SIGNUP["Sign-Up Page"]:::backend
    click AUTH_SIGNIN "https://github.com/skilvul-km4-fe8/fatkid/blob/main/app/(auth)/sign-in/[[...sign-in]]/page.tsx"
    click AUTH_SIGNUP "https://github.com/skilvul-km4-fe8/fatkid/blob/main/app/(auth)/sign-up/[[...sign-up]]/page.tsx"

    %% Menu Pages
    MENU_PAGE["Menu Main Page"]:::backend
    MENU_MGMT["Menu Management Page"]:::backend
    MENU_OVW["Menu Overview Page"]:::backend
    MENU_TRX_PAGE["Menu Transaction Page"]:::backend
    click MENU_PAGE "https://github.com/skilvul-km4-fe8/fatkid/blob/main/app/(menu)/page.tsx"
    click MENU_MGMT "https://github.com/skilvul-km4-fe8/fatkid/blob/main/app/(menu)/management/page.tsx"
    click MENU_OVW "https://github.com/skilvul-km4-fe8/fatkid/blob/main/app/(menu)/overview/page.tsx"
    click MENU_TRX_PAGE "https://github.com/skilvul-km4-fe8/fatkid/blob/main/app/(menu)/transaction/page.tsx"

    %% Next.js Server and Middleware
    NEXT_SERVER["Next.js Server"]:::backend
    MIDDLEWARE["Request Middleware"]:::backend
    click MIDDLEWARE "https://github.com/skilvul-km4-fe8/fatkid/blob/main/middleware.ts"
    
    %% API Routes (BFF)
    subgraph "API Routes (BFF Layer)" 
        API_MENU["Menu API Routes"]:::backend
        API_OVW["Overview API Route"]:::backend
        API_TRX["Transaction API Routes"]:::backend
    end
    click API_MENU "https://github.com/skilvul-km4-fe8/fatkid/tree/main/app/api/menu/"
    click API_OVW "https://github.com/skilvul-km4-fe8/fatkid/blob/main/app/api/overview/route.ts"
    click API_TRX "https://github.com/skilvul-km4-fe8/fatkid/blob/main/app/api/transaction/route.ts"
    click API_TRX "https://github.com/skilvul-km4-fe8/fatkid/blob/main/app/api/transaction/bulk-delete/route.ts"
    click API_MENU "https://github.com/skilvul-km4-fe8/fatkid/blob/main/app/api/menu/route.ts"
    click API_MENU "https://github.com/skilvul-km4-fe8/fatkid/blob/main/app/api/menu/[id]/route.ts"
    click API_MENU "https://github.com/skilvul-km4-fe8/fatkid/blob/main/app/api/menu/bulk-delete/route.ts"

    %% Data Access Layer
    subgraph "Data Access Layer" 
        PRISMA["Prisma Client"]:::backend
        UTILS["Shared Utilities"]:::backend
    end
    click PRISMA "https://github.com/skilvul-km4-fe8/fatkid/blob/main/lib/prisma.ts"
    click UTILS "https://github.com/skilvul-km4-fe8/fatkid/blob/main/lib/utils.ts"

    %% Database
    subgraph "Database (PostgreSQL)" 
        SCHEMA["Database Schema"]:::database
        MIGRATIONS["Migrations"]:::database
    end
    click SCHEMA "https://github.com/skilvul-km4-fe8/fatkid/blob/main/prisma/schema.prisma"
    click MIGRATIONS "https://github.com/skilvul-km4-fe8/fatkid/tree/main/prisma/migrations/"

    %% Context Providers
    PROVIDERS["Context Providers"]:::backend
    click PROVIDERS "https://github.com/skilvul-km4-fe8/fatkid/blob/main/providers/dialog-providers.tsx"
    click PROVIDERS "https://github.com/skilvul-km4-fe8/fatkid/blob/main/providers/query-providers.tsx"
    click PROVIDERS "https://github.com/skilvul-km4-fe8/fatkid/blob/main/providers/sheet-providres.tsx"

    %% Global Layout & Styles
    GLOBAL_LAYOUT["Global Layout & Styles"]:::backend
    click GLOBAL_LAYOUT "https://github.com/skilvul-km4-fe8/fatkid/blob/main/app/layout.tsx"
    click GLOBAL_LAYOUT "https://github.com/skilvul-km4-fe8/fatkid/blob/main/app/globals.css"
    click GLOBAL_LAYOUT "https://github.com/skilvul-km4-fe8/fatkid/blob/main/tailwind.config.ts"
    click GLOBAL_LAYOUT "https://github.com/skilvul-km4-fe8/fatkid/blob/main/postcss.config.mjs"

    %% Next.js Config
    NEXT_CONF["Next.js Config"]:::backend
    click NEXT_CONF "https://github.com/skilvul-km4-fe8/fatkid/blob/main/next.config.mjs"

    %% DevOps / CI-CD
    subgraph "DevOps & CI/CD" 
        DOCKERFILE["Dockerfile"]:::devops
        COMPOSE["docker-compose.yml"]:::devops
        CI_CD["GitHub Actions Workflow"]:::devops
        DOCKER_BUILD["Docker Build & Push"]:::devops
        DEPLOY["Deploy to Vercel"]:::devops
    end
    click DOCKERFILE "https://github.com/skilvul-km4-fe8/fatkid/tree/main/Dockerfile"
    click COMPOSE "https://github.com/skilvul-km4-fe8/fatkid/blob/main/docker-compose.yml"
    click CI_CD "https://github.com/skilvul-km4-fe8/fatkid/blob/main/.github/workflows/deploy.yml"

    %% Connections
    BROWSER -->|"requests pages / API"| NEXT_SERVER
    BROWSER --> UI_COMPS

    MENU_FEAT --> BROWSER
    OVERVIEW_FEAT --> BROWSER
    TRANSACTION_FEAT --> BROWSER

    NEXT_SERVER --> APP_PAGES
    APP_PAGES --> AUTH_SIGNIN
    APP_PAGES --> AUTH_SIGNUP
    APP_PAGES --> MENU_PAGE
    APP_PAGES --> MENU_MGMT
    APP_PAGES --> MENU_OVW
    APP_PAGES --> MENU_TRX_PAGE

    NEXT_SERVER --> MIDDLEWARE
    NEXT_SERVER --> PROVIDERS
    NEXT_SERVER --> NEXT_CONF
    NEXT_SERVER --> GLOBAL_LAYOUT

    NEXT_SERVER -->|"calls"| API_MENU
    NEXT_SERVER -->|"calls"| API_OVW
    NEXT_SERVER -->|"calls"| API_TRX

    API_MENU --> PRISMA
    API_OVW --> PRISMA
    API_TRX --> PRISMA

    PRISMA --> SCHEMA
    PRISMA --> MIGRATIONS
    UTILS --> NEXT_SERVER

    CI_CD --> DOCKER_BUILD --> DEPLOY
    COMPOSE --> NEXT_SERVER
    COMPOSE --> SCHEMA
    DOCKERFILE --> NEXT_SERVER

    %% Styles
    class BROWSER,UI_COMPS,MENU_FEAT,OVERVIEW_FEAT,TRANSACTION_FEAT frontend
    class NEXT_SERVER,API_MENU,API_OVW,API_TRX,PRISMA,UTILS,MIDDLEWARE,PROVIDERS,NEXT_CONF,GLOBAL_LAYOUT backend
    class SCHEMA,MIGRATIONS database
    class DOCKERFILE,COMPOSE,CI_CD,DOCKER_BUILD,DEPLOY devops
```
