# kwamevaughan/credit-bank-microsite architecture

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

- Interactive diagram: https://gitdiagram.com/kwamevaughan/credit-bank-microsite
- Repository: https://github.com/kwamevaughan/credit-bank-microsite

## Overview

##### Project type and purpose
- This is a full-stack React/Next.js web application, bootstrapped with create-next-app.
- It provides a client dashboard (account opening, transactions, quizzes, referrals, leaderboards, help-desk), uses Supabase as its backend, and offers a set of serverless API endpoints for transactional workflows (email, transaction verification, referrals).

##### File structure
- Top level
- next.config.js, jsconfig.json, tailwind.config.mjs, postcss.config.mjs: build and framework configs
- lib/supabase.js: Supabase client wrapper
- public/: static assets (images, misc data like countries.json, sample-data.xls, web manifest)
- src/
- app/: global CSS and Next.js app config
- pages/: routing layer
– pages/api/: serverless API endpoints (helpdeskEmail, leaderboard, redeemReferral, etc.)
– pages/*.js: client-side routes (dashboard, login, quiz, referrals, etc.)
– _app.js/_document.js: app bootstrap and document overrides
- layouts/: shared layout wrappers (headers, footer, sidebar)
- context/: React context for user/session state
- hooks/: custom React hooks for business logic (data fetching, real-time updates, modals, theme)
- utils/imageKitService.js: integration with ImageKit for image uploads
- data/: client-side JSON (questions.js)
- styles/: global and utility CSS

##### README for additional insights
- Confirms Next.js usage, optimization via next/font, deployment on Vercel

##### Detail
- Context/hooks layer feeding into UI components (optional sub-layer)

- Clearly separate frontend vs. backend concerns
- Data flow from user actions → API → database/external services → UI updates
- Your use of Next.js serverless architecture, Supabase, and third-party integrations
- Be easy to read, maintain, and extend as the product evolves

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["Browser"]:::frontend
        UI["Next.js UI"]:::frontend
        subgraph "UI Pages"
            P1["index.js"]:::frontend
            P2["dashboard.js"]:::frontend
            P3["quiz.js"]:::frontend
            P4["referrals.js"]:::frontend
            P5["leaderboard.js"]:::frontend
        end
        Context["UserContext & Hooks"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        APIRoutes["API Routes"]:::backend
        subgraph "Serverless Functions"
            A1["helpdeskEmail.js"]:::backend
            A2["leaderboard.js"]:::backend
            A3["redeemReferral.js"]:::backend
            A4["sendDeleteAccountEmail.js"]:::backend
            A5["sendEmail.js"]:::backend
            A6["sendPasswordReset.js"]:::backend
            A7["transaction-verification.js"]:::backend
            A8["verifyReferral.js"]:::backend
        end
        SupabaseClient["Supabase Client"]:::backend
    end

    %% Database & Services
    Supabase["Supabase (DB/Auth)"]:::database
    Email["Email Service"]:::external
    ImageKit["ImageKit Service"]:::external
    CDN["CDN / Static Assets"]:::cdn

    %% Connections
    Browser --> UI
    Browser --> CDN
    UI --> P1
    UI --> P2
    UI --> P3
    UI --> P4
    UI --> P5
    UI --> Context
    UI --> APIRoutes
    APIRoutes --> A1
    APIRoutes --> A2
    APIRoutes --> A3
    APIRoutes --> A4
    APIRoutes --> A5
    APIRoutes --> A6
    APIRoutes --> A7
    APIRoutes --> A8
    APIRoutes --> SupabaseClient
    SupabaseClient --> Supabase
    APIRoutes --> Email
    APIRoutes --> ImageKit
    CDN --> Browser

    %% Click Events
    click P1 "https://github.com/kwamevaughan/credit-bank-microsite/blob/master/src/pages/index.js"
    click P2 "https://github.com/kwamevaughan/credit-bank-microsite/blob/master/src/pages/dashboard.js"
    click P3 "https://github.com/kwamevaughan/credit-bank-microsite/blob/master/src/pages/quiz.js"
    click P4 "https://github.com/kwamevaughan/credit-bank-microsite/blob/master/src/pages/referrals.js"
    click P5 "https://github.com/kwamevaughan/credit-bank-microsite/blob/master/src/pages/leaderboard.js"
    click A1 "https://github.com/kwamevaughan/credit-bank-microsite/blob/master/src/pages/api/helpdeskEmail.js"
    click A2 "https://github.com/kwamevaughan/credit-bank-microsite/blob/master/src/pages/api/leaderboard.js"
    click A3 "https://github.com/kwamevaughan/credit-bank-microsite/blob/master/src/pages/api/redeemReferral.js"
    click A4 "https://github.com/kwamevaughan/credit-bank-microsite/blob/master/src/pages/api/sendDeleteAccountEmail.js"
    click A5 "https://github.com/kwamevaughan/credit-bank-microsite/blob/master/src/pages/api/sendEmail.js"
    click A6 "https://github.com/kwamevaughan/credit-bank-microsite/blob/master/src/pages/api/sendPasswordReset.js"
    click A7 "https://github.com/kwamevaughan/credit-bank-microsite/blob/master/src/pages/api/transaction-verification.js"
    click A8 "https://github.com/kwamevaughan/credit-bank-microsite/blob/master/src/pages/api/verifyReferral.js"
    click SupabaseClient "https://github.com/kwamevaughan/credit-bank-microsite/blob/master/lib/supabase.js"
    click CDN "https://github.com/kwamevaughan/credit-bank-microsite/tree/master/public/"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef backend fill:#DFFFE0,stroke:#22863A,color:#22863A
    classDef database fill:#FFEFD5,stroke:#DAA520,color:#DAA520
    classDef external fill:#E8E8E8,stroke:#6A737D,color:#6A737D
    classDef cdn fill:#FFF5B1,stroke:#D73A49,color:#D73A49
```
