# sumitha05/finchamp-24 architecture

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

- Interactive diagram: https://gitdiagram.com/sumitha05/finchamp-24
- Repository: https://github.com/sumitha05/finchamp-24

## Overview

##### Project type and purpose
- FinChamp is a full-stack Next.js web application providing a financial companion platform with personalized advice, interactive learning, product comparisons, news feeds, a chatbot, and virtual trading.
- The README confirms key technologies: Next.js (app router), Drizzle + Neon (database), Clerk (authentication), Botpress (chatbot), plus various React components and static assets.

##### File structure
- Top-level “app” directory: Next.js app-router pages and layouts for “main” (courses, leaderboard, shop, learn), “marketing,” and dozens of domain-specific routes (comparisons, news, banks, loans, etc.).
- “components”: reusable UI pieces (Navbar, Footer, modals, trade-app widgets, home cards).
- “app/api”: server-side API endpoints (Clerk webhooks).
- “db” + “migrations”: Drizzle ORM layer and SQL migrations targeting a Neon database.
- “lib”: business-logic helpers and modal state controllers.
- “store”: client-side modal state (Zustand hooks).
- “public”: static assets (videos, audio, images).
- Configuration and build files: next.config.mjs, tsconfig.json, tailwind.config.ts, lint/build scripts.

##### README for additional insights
- The system uses server-side rendering (SSR) and static assets via Next.js app router.
- Authentication is offloaded to Clerk (OTP flow).
- Chatbot uses Botpress for AI-driven assistance.
- Database operations are managed by Drizzle (TypeScript ORM) over a Neon Postgres instance.

##### Detail
- Every major feature area (courses, quizzes, comparisons, trade app, news feeds).
- UI components back to the app router layout structure.
- Where static assets are served from public/.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Browser["User Browser"]:::client
        NextApp["Next.js App Server"]:::internal
        Browser -->|"HTTP(S) SSR & API Calls"| NextApp

        subgraph "App Router & Components"
            AppDir["app/"]:::internal
            MainLayout["app/(main)/layout.tsx"]:::internal
            MktLayout["app/(marketing)/layout.tsx"]:::internal
            Comparisons["app/comparisons/"]:::internal
            News["app/news/"]:::internal
            Bank["app/bank/"]:::internal
            Loans["app/loans/"]:::internal
            Stocks["app/stocks/"]:::internal
            Trade["app/trade/"]:::internal
            ChatBot["ChatBot.jsx"]:::clientcomp

            NextApp --> AppDir
            AppDir --> MainLayout
            AppDir --> MktLayout
            AppDir --> Comparisons
            AppDir --> News
            AppDir --> Bank
            AppDir --> Loans
            AppDir --> Stocks
            AppDir --> Trade
            AppDir --> ChatBot
        end

        subgraph "UI Components & Styles"
            Components["components/"]:::internal
            Tailwind["tailwind.config.ts"]:::internal
            GlobalsCSS["app/globals.css"]:::internal
            NextApp --> Components
            NextApp --> Tailwind
            NextApp --> GlobalsCSS
        end
    end

    %% API Layer
    subgraph "API Layer"
        ClerkWebhook["app/api/webhooks/clerk/courses/route.ts"]:::internal
        NextApp --> ClerkWebhook
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        UserAction["lib/actions/user.action.ts"]:::internal
        AdminLib["lib/admin.ts"]:::internal
        UtilsLib["lib/utils.ts"]:::internal
        Modals["lib/modals/user.modal.ts"]:::internal
        NextApp --> UserAction
        NextApp --> AdminLib
        NextApp --> UtilsLib
        NextApp --> Modals
    end

    %% State Management
    subgraph "Client State (Zustand)"
        UseExit["store/use-exit-modal.ts"]:::internal
        UseHearts["store/use-hearts-modal.ts"]:::internal
        UsePractice["store/use-practice-modal.ts"]:::internal
        NextApp --> UseExit
        NextApp --> UseHearts
        NextApp --> UsePractice
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DBSetup["db/db.ts"]:::db
        DrizzleSetup["db/drizzle.ts"]:::db
        Queries["db/queries.ts"]:::db
        Schema["db/schema.ts"]:::db
        NextApp --> DBSetup
        DBSetup --> DrizzleSetup
        DrizzleSetup --> Queries
        Queries --> Schema
    end

    %% Migrations
    subgraph "Database Migrations"
        M1["migrations/0000_left_marvel_boy.sql"]:::db
        M2["migrations/0001_fair_warhawk.sql"]:::db
        DBSetup --> M1
        DBSetup --> M2
    end

    %% Static Assets
    PublicAssets["public/"]:::internal
    NextApp --> PublicAssets

    %% External Services
    subgraph "External Services"
        Clerk["Clerk Auth Service"]:::external
        Botpress["Botpress Chatbot Service"]:::external
        MarketAPI["Financial Markets API"]:::external
        NeonDB["Neon Postgres DB"]:::db
        NextApp --> Clerk
        NextApp --> Botpress
        Trade --> MarketAPI
        DBSetup --> NeonDB
    end

    %% Click Events
    click AppDir "https://github.com/sumitha05/finchamp-24/tree/master/app/"
    click MainLayout "https://github.com/sumitha05/finchamp-24/blob/master/app/(main)/layout.tsx"
    click MktLayout "https://github.com/sumitha05/finchamp-24/blob/master/app/(marketing)/layout.tsx"
    click Comparisons "https://github.com/sumitha05/finchamp-24/tree/master/app/comparisons/"
    click News "https://github.com/sumitha05/finchamp-24/tree/master/app/news/"
    click Bank "https://github.com/sumitha05/finchamp-24/tree/master/app/bank/"
    click Loans "https://github.com/sumitha05/finchamp-24/tree/master/app/loans/"
    click Stocks "https://github.com/sumitha05/finchamp-24/tree/master/app/stocks/"
    click Trade "https://github.com/sumitha05/finchamp-24/tree/master/app/trade/"
    click ChatBot "https://github.com/sumitha05/finchamp-24/blob/master/app/ChatBot.jsx"
    click ClerkWebhook "https://github.com/sumitha05/finchamp-24/blob/master/app/api/webhooks/clerk/courses/route.ts"
    click UserAction "https://github.com/sumitha05/finchamp-24/blob/master/lib/actions/user.action.ts"
    click AdminLib "https://github.com/sumitha05/finchamp-24/blob/master/lib/admin.ts"
    click UtilsLib "https://github.com/sumitha05/finchamp-24/blob/master/lib/utils.ts"
    click Modals "https://github.com/sumitha05/finchamp-24/blob/master/lib/modals/user.modal.ts"
    click UseExit "https://github.com/sumitha05/finchamp-24/blob/master/store/use-exit-modal.ts"
    click UseHearts "https://github.com/sumitha05/finchamp-24/blob/master/store/use-hearts-modal.ts"
    click UsePractice "https://github.com/sumitha05/finchamp-24/blob/master/store/use-practice-modal.ts"
    click DBSetup "https://github.com/sumitha05/finchamp-24/blob/master/db/db.ts"
    click DrizzleSetup "https://github.com/sumitha05/finchamp-24/blob/master/db/drizzle.ts"
    click Queries "https://github.com/sumitha05/finchamp-24/blob/master/db/queries.ts"
    click Schema "https://github.com/sumitha05/finchamp-24/blob/master/db/schema.ts"
    click M1 "https://github.com/sumitha05/finchamp-24/blob/master/migrations/0000_left_marvel_boy.sql"
    click M2 "https://github.com/sumitha05/finchamp-24/blob/master/migrations/0001_fair_warhawk.sql"
    click Components "https://github.com/sumitha05/finchamp-24/tree/master/components/"
    click PublicAssets "https://github.com/sumitha05/finchamp-24/tree/master/public/"
    click Tailwind "https://github.com/sumitha05/finchamp-24/blob/master/tailwind.config.ts"
    click GlobalsCSS "https://github.com/sumitha05/finchamp-24/blob/master/app/globals.css"
    click NextConfig "https://github.com/sumitha05/finchamp-24/blob/master/next.config.mjs"
    click TSConfig "https://github.com/sumitha05/finchamp-24/blob/master/tsconfig.json"

    %% Styles
    classDef client fill:#f9e79f,stroke:#b7950b
    classDef internal fill:#aed6f1,stroke:#2874a6
    classDef clientcomp fill:#d6eaf8,stroke:#1b4f72
    classDef db fill:#abebc6,stroke:#196f3d
    classDef external fill:#d2b4de,stroke:#6c3483
```
