# christiaan-fourie/ibean architecture

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

- Interactive diagram: https://gitdiagram.com/christiaan-fourie/ibean
- Repository: https://github.com/christiaan-fourie/ibean

## Overview

##### Project type and purpose
- This is a Next.js full-stack web application (React framework with built-in routing, SSR/SSG).
- From the components (ConfirmOrder, Dashboard, ManageProducts, etc.) and `utils/firebase.js`, it’s an e-commerce or POS admin dashboard that handles products, orders, refunds, and sales, backed by Firebase.

##### File structure
- Top-level files:
- next.config.mjs, tsconfig.json/jsconfig.json, postcss.config.mjs → build/config for Next.js and TypeScript/JavaScript tooling.
- package.json & lock → dependencies (Next.js, React, Firebase, etc.).
- `app/` directory (Next.js 13+ App Router) contains:
- `layout.js` → wraps every page with common UI (header, menu).
- `page.jsx` → the root page entry.
- `components/` → presentational and container components (Login, Dashboard, OrderCheckout, etc.).
- `context/StoreContext.jsx` → React Context for global state (e.g., user auth, cart).
- `utils/firebase.js` → abstraction over Firebase SDK (Auth, Firestore).

##### Key insights from the README
- Standard Create-Next-App bootstrapped project.
- Uses next/font optimization for Geist fonts.
- Intended to be deployed on Vercel (serverless hosts).

##### Main components & interactions
a. Frontend (Client Browser)
- React components within Next.js App Router.
- Global CSS (`globals.css`) and next/font for styling & performance.
b. Next.js Framework Layer
- App Router handles routing and SSR/SSG.
- `layout.js` injects shared UI.
c. State Management
- `StoreContext` provides auth state, cart data, product listings across components.
d. Data Service Layer
- `utils/firebase.js` manages connections to Firebase Auth and Firestore.
e. External Services
- Firebase Auth (user login, session).
- Firestore Database (products, orders, refunds, sales).
- Vercel CDN & serverless runtime for hosting.

##### Architectural patterns & design principles
- React + Next.js App Router (component-based, SSR/SSG, file-based routing).
- Provider-Consumer pattern via React Context for global state.
- Service abstraction over Firebase SDK for decoupling.
- Separation of concerns: UI components vs. data fetching logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Browser Layer
    subgraph "Client Browser"
        direction TB
        User["User"]:::external
        subgraph "React Components"
            direction TB
            ConfirmOrder["ConfirmOrder"]:::frontend
            Dashboard["Dashboard"]:::frontend
            Header["Header"]:::frontend
            Login["Login"]:::frontend
            ManageProducts["ManageProducts"]:::frontend
            Menu["Menu"]:::frontend
            OrderCheckout["OrderCheckout"]:::frontend
            Products["Products"]:::frontend
            Refunds["Refunds"]:::frontend
            Sales["Sales"]:::frontend
        end
        Static["Static Assets (public/)"]:::external
    end

    %% Framework Layer
    subgraph "Next.js App Router"
        direction TB
        AppRouter["Next.js App Router"]:::framework
        Layout["Root Layout"]:::framework
        Page["Root Page Entry"]:::framework
        Styles["Global Styles"]:::framework
    end

    %% State Management
    Store["StoreContext"]:::data

    %% Data Service Layer
    FirebaseService["Firebase Abstraction"]:::data

    %% External Services
    subgraph "Firebase Services"
        direction TB
        Auth["Firebase Auth"]:::external
        Firestore["Firestore Database"]:::external
    end

    %% Hosting & CDN
    Vercel["Vercel Hosting/CDN"]:::external

    %% Configuration Files
    subgraph "Config & Build"
        nextcfg["next.config.mjs"]:::config
        tsconfig["tsconfig.json / jsconfig.json"]:::config
        postcss["postcss.config.mjs"]:::config
        pkg["package.json & lock"]:::config
    end

    %% Connections
    User -->|"interacts with"| Login
    User -->|"navigates to"| Dashboard
    Static -->|"served via CDN"| User

    Login -->|uses| Store
    Dashboard -->|uses| Store
    ConfirmOrder -->|uses| Store
    ManageProducts -->|uses| Store
    OrderCheckout -->|uses| Store
    Products -->|uses| Store
    Refunds -->|uses| Store
    Sales -->|uses| Store
    Header -->|uses| Store
    Menu -->|uses| Store

    Store -->|"calls"| FirebaseService
    AppRouter -->|"SSR/SSG data fetch via"| FirebaseService

    FirebaseService -->|"auth calls"| Auth
    FirebaseService -->|"db calls"| Firestore

    AppRouter -->|"deployed on"| Vercel
    Static -->|"cached on"| Vercel

    nextcfg --> AppRouter
    tsconfig --> AppRouter
    postcss --> Styles
    pkg --> AppRouter

    %% Click Events
    click AppRouter "https://github.com/christiaan-fourie/ibean/tree/main/app/"
    click Layout "https://github.com/christiaan-fourie/ibean/blob/main/app/layout.js"
    click Page "https://github.com/christiaan-fourie/ibean/blob/main/app/page.jsx"
    click Styles "https://github.com/christiaan-fourie/ibean/blob/main/app/globals.css"
    click ConfirmOrder "https://github.com/christiaan-fourie/ibean/blob/main/app/components/ConfirmOrder.jsx"
    click Dashboard "https://github.com/christiaan-fourie/ibean/blob/main/app/components/Dashboard.jsx"
    click Header "https://github.com/christiaan-fourie/ibean/blob/main/app/components/Header.jsx"
    click Login "https://github.com/christiaan-fourie/ibean/blob/main/app/components/Login.jsx"
    click ManageProducts "https://github.com/christiaan-fourie/ibean/blob/main/app/components/ManageProducts.jsx"
    click Menu "https://github.com/christiaan-fourie/ibean/blob/main/app/components/Menu.jsx"
    click OrderCheckout "https://github.com/christiaan-fourie/ibean/blob/main/app/components/OrderCheckout.jsx"
    click Products "https://github.com/christiaan-fourie/ibean/blob/main/app/components/Products.jsx"
    click Refunds "https://github.com/christiaan-fourie/ibean/blob/main/app/components/Refunds.jsx"
    click Sales "https://github.com/christiaan-fourie/ibean/blob/main/app/components/Sales.jsx"
    click Store "https://github.com/christiaan-fourie/ibean/blob/main/app/context/StoreContext.jsx"
    click FirebaseService "https://github.com/christiaan-fourie/ibean/blob/main/utils/firebase.js"
    click Static "https://github.com/christiaan-fourie/ibean/tree/main/public/"
    click nextcfg "https://github.com/christiaan-fourie/ibean/blob/main/next.config.mjs"
    click tsconfig "https://github.com/christiaan-fourie/ibean/blob/main/tsconfig.json"
    click postcss "https://github.com/christiaan-fourie/ibean/blob/main/postcss.config.mjs"
    click pkg "https://github.com/christiaan-fourie/ibean/blob/main/package.json"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#42A5F5,color:#0D47A1
    classDef framework fill:#F3E5F5,stroke:#AB47BC,color:#4A148C
    classDef data fill:#E8F5E9,stroke:#66BB6A,color:#1B5E20
    classDef external fill:#FFF3E0,stroke:#FFA726,color:#E65100
    classDef config fill:#ECEFF1,stroke:#90A4AE,color:#37474F
```
