# rajafawady/pak-financials architecture

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

- Interactive diagram: https://gitdiagram.com/rajafawady/pak-financials
- Repository: https://github.com/rajafawady/pak-financials

## Overview

##### Project Type and Purpose
- This is a full-stack (mostly frontend-centric) React application built with Next.js (App Router).
- It provides multiple static/SSR pages (home, about, contact, tutorials, “halal-investments,” etc.), localized via JSON message bundles and an i18n service.
- Assets (video tutorials, fonts) and UI components are organized under `public/` and `src/components/`.

##### File Structure
- `src/app/`: Next.js App-router pages and layout (SSR/SSG).
- `src/components/`: Reusable UI building blocks (FeatureSection, Navbar, Footer, etc.) and a subfolder `ui/` for primitives (button, dropdown, navigation).
- `src/i18n/` & `messages/`: Locale configuration, request wrapper, and translation JSON files (`en.json`, `nl.json`, `ur.json`).
- `src/services/locale.ts`: Runtime locale detection or switching logic.
- `src/lib/utils.ts`: Shared utility functions.
- Config/build files: `next.config.js`, `postcss.config.mjs`, `tailwind.config.ts`, `tsconfig.json`.
- `public/`: Static assets served directly (tutorial videos, etc.).

##### README Insights
- Project bootstrapped with Create-Next-App.
- Uses built-in Next.js features: automatic code splitting, SSR/SSG, `next/font` optimization.
- Deployable to Vercel; no external backend beyond Next.js server.

##### Main Components
a. Client Browser
b. Next.js Server
– App-Router (pages in `src/app/`)
– Layout (`layout.tsx`)
– React Components (`src/components/`)
– i18n Service/Config (`src/i18n/`, `src/services/locale.ts`, `messages/`)
– Utility Layer (`src/lib/utils.ts`)
c. Static Asset Store (`public/`)
d. Build System
– Tailwind CSS / PostCSS
– Next.js Bundler (Webpack/Turbopack)
e. Package Manager & Runtime (Node.js + npm/yarn/pnpm)

##### Relationships & Data Flow
1. Browser → HTTP request → Next.js Server
2. Server reads the route handler in `src/app/[route]/page.tsx`
3. Server invokes React components, applies layouts, pulls in translations via i18n service
4. Server compiles/SSG or SSR pages, outputting HTML + hydration JS
5. Browser receives HTML, loads JS bundle + CSS (Tailwind-generated)
6. Browser requests static assets (videos, fonts) from `public/` on demand
7. Locale switching: user interacts with `LocaleSwitcher` component → calls `services/locale.ts` → updates UI strings

##### Architectural Patterns & Design Principles
- Component-based UI (React).
- Page/Layout pattern (Next.js App Router).
- Static Generation (SSG) + Server-Side Rendering (SSR) hybrid strategy.
- Separation of concerns: UI components vs. services vs. utilities.
- i18n integration via JSON resources and runtime locale service.
- Utility-first styling with Tailwind CSS.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client
    Browser["Client Browser"]:::browser

    %% Server
    NextServer["Next.js Server (App Router)"]:::server

    subgraph "Server Components"
        AppRouter["App Router (src/app/)"]:::server
        Layout["Layout (layout.tsx)"]:::server
        GlobalsCSS["Global Styles (globals.css)"]:::server
        PagesHome["Home Page (page.tsx)"]:::server
        PagesAbout["About Page (about/page.tsx)"]:::server
        PagesContact["Contact Page (contact/page.tsx)"]:::server
        PagesTutorials["Tutorials Page (tutorials/page.tsx)"]:::server
        PagesHalal["Halal Investments Page (halal-investments/page.tsx)"]:::server
        PagesStock["Stock Market Page (stock-market/page.tsx)"]:::server
        FontsDir["Fonts Directory (fonts)"]:::server
        ReactComponents["React UI Components (src/components/)"]:::server
        UIPrimitives["UI Primitives (src/components/ui/)"]:::server
        LocaleSwitcher["LocaleSwitcher Components"]:::server
        Navbar["Navbar & Footer"]:::server
        Sections["Feature & Showcase Sections"]:::server
        I18nConfig["i18n Config (src/i18n/config.ts)"]:::server
        I18nRequest["i18n Request Wrapper (src/i18n/request.ts)"]:::server
        Translations["Translation Bundles (messages/*.json)"]:::server
        LocaleService["Locale Service (src/services/locale.ts)"]:::server
        Utils["Utility Layer (src/lib/utils.ts)"]:::server
    end

    %% Static Assets
    StaticAssets["Static Assets (public/)"]:::asset

    %% Build Pipeline
    subgraph "Build Pipeline"
        Tailwind["Tailwind Config (tailwind.config.ts)"]:::build
        PostCSS["PostCSS Config (postcss.config.mjs)"]:::build
        Bundler["Next.js Bundler"]:::build
    end

    %% Configurations
    subgraph "Configurations"
        NextConfig["next.config.js"]:::config
        TSConfig["tsconfig.json"]:::config
        PackageJSON["package.json & package-lock.json"]:::config
        ESLint[".eslintrc.json"]:::config
    end

    %% Relationships
    Browser -->|"HTTP request"| NextServer
    NextServer -->|"serves HTML + JS"| Browser
    Browser -->|"requests asset"| StaticAssets

    NextServer --> AppRouter
    AppRouter --> Layout
    AppRouter --> GlobalsCSS
    AppRouter --> PagesHome
    AppRouter --> PagesAbout
    AppRouter --> PagesContact
    AppRouter --> PagesTutorials
    AppRouter --> PagesHalal
    AppRouter --> PagesStock
    AppRouter --> FontsDir

    Layout --> ReactComponents
    ReactComponents --> UIPrimitives
    ReactComponents --> LocaleSwitcher
    ReactComponents --> Navbar
    ReactComponents --> Sections
    ReactComponents --> Utils

    LocaleSwitcher --> LocaleService
    LocaleService --> Translations
    ReactComponents --> I18nConfig
    ReactComponents --> I18nRequest

    Tailwind --> Bundler
    PostCSS --> Bundler
    Bundler --> NextServer

    NextConfig --> Bundler
    TSConfig --> Bundler
    PackageJSON --> Bundler
    ESLint --> Bundler

    %% Click Events
    click AppRouter "https://github.com/rajafawady/pak-financials/tree/main/src/app/"
    click Layout "https://github.com/rajafawady/pak-financials/blob/main/src/app/layout.tsx"
    click GlobalsCSS "https://github.com/rajafawady/pak-financials/blob/main/src/app/globals.css"
    click PagesHome "https://github.com/rajafawady/pak-financials/blob/main/src/app/page.tsx"
    click PagesAbout "https://github.com/rajafawady/pak-financials/blob/main/src/app/about/page.tsx"
    click PagesContact "https://github.com/rajafawady/pak-financials/blob/main/src/app/contact/page.tsx"
    click PagesTutorials "https://github.com/rajafawady/pak-financials/blob/main/src/app/tutorials/page.tsx"
    click PagesHalal "https://github.com/rajafawady/pak-financials/blob/main/src/app/halal-investments/page.tsx"
    click PagesStock "https://github.com/rajafawady/pak-financials/blob/main/src/app/stock-market/page.tsx"
    click FontsDir "https://github.com/rajafawady/pak-financials/tree/main/src/app/fonts"
    click ReactComponents "https://github.com/rajafawady/pak-financials/tree/main/src/components/"
    click UIPrimitives "https://github.com/rajafawady/pak-financials/tree/main/src/components/ui/"
    click LocaleSwitcher "https://github.com/rajafawady/pak-financials/blob/main/src/components/LocaleSwitcher.tsx"
    click LocaleSwitcher "https://github.com/rajafawady/pak-financials/blob/main/src/components/LocaleSwitcherSelect.tsx"
    click Navbar "https://github.com/rajafawady/pak-financials/blob/main/src/components/Navbar.tsx"
    click Navbar "https://github.com/rajafawady/pak-financials/blob/main/src/components/Footer.tsx"
    click Sections "https://github.com/rajafawady/pak-financials/blob/main/src/components/FeatureSection.tsx"
    click Sections "https://github.com/rajafawady/pak-financials/blob/main/src/components/WhyChooseSection.tsx"
    click Sections "https://github.com/rajafawady/pak-financials/blob/main/src/components/FinancialFuture.tsx"
    click Sections "https://github.com/rajafawady/pak-financials/blob/main/src/components/ImageShowcase.tsx"
    click I18nConfig "https://github.com/rajafawady/pak-financials/blob/main/src/i18n/config.ts"
    click I18nRequest "https://github.com/rajafawady/pak-financials/blob/main/src/i18n/request.ts"
    click Translations "https://github.com/rajafawady/pak-financials/blob/main/messages/en.json"
    click Translations "https://github.com/rajafawady/pak-financials/blob/main/messages/nl.json"
    click Translations "https://github.com/rajafawady/pak-financials/blob/main/messages/ur.json"
    click LocaleService "https://github.com/rajafawady/pak-financials/blob/main/src/services/locale.ts"
    click Utils "https://github.com/rajafawady/pak-financials/blob/main/src/lib/utils.ts"
    click StaticAssets "https://github.com/rajafawady/pak-financials/tree/main/public/"
    click NextConfig "https://github.com/rajafawady/pak-financials/blob/main/next.config.js"
    click PostCSS "https://github.com/rajafawady/pak-financials/blob/main/postcss.config.mjs"
    click Tailwind "https://github.com/rajafawady/pak-financials/blob/main/tailwind.config.ts"
    click TSConfig "https://github.com/rajafawady/pak-financials/blob/main/tsconfig.json"
    click PackageJSON "https://github.com/rajafawady/pak-financials/blob/main/package.json"
    click ESLint "https://github.com/rajafawady/pak-financials/blob/main/.eslintrc.json"

    %% Styles
    classDef browser fill:#D0E8FF,stroke:#0366d6;
    classDef server fill:#E6F4EA,stroke:#28a745;
    classDef asset fill:#FFF5BA,stroke:#FFDF00;
    classDef build fill:#F0F0F0,stroke:#6a737d;
    classDef config fill:#F9F9F9,stroke:#c6cbd1;
```
