# mohaiminul375/merit-matrix-client architecture

> Architecture diagram of the GitHub repository mohaiminul375/merit-matrix-client, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohaiminul375/merit-matrix-client
- Repository: https://github.com/mohaiminul375/merit-matrix-client

## Overview

##### Project Type and Purpose
- This is a full-stack scholarship-management application called “Merit-Matrix.”
- The repository you provided is the front-end client, built as a React SPA with Vite, TailwindCSS and DaisyUI.
- According to the README, the overall system also includes:
– A Node/Express backend exposing REST endpoints
– A MongoDB database
– Firebase (for auth+hosting)
– Stripe (for payments)

##### File Structure (Front-end)
Top-level files
- index.html, package.json, vite.config.js, tailwind.config.js
- firebase.json, .firebaserc (Firebase hosting)
src/
- main.jsx + index.css – application entry point
- Router/ – React Router v6 routes and guarded-route components
- Provider/AuthProvider.jsx – React Context for Firebase authentication
- Pages/ – top-level route pages (Home, AllScholarship, Checkout, Dashboard, etc.)
- component/ – reusable UI components (tables, cards, modals, shared Navbar/Footer)
- hooks/ – custom hooks for data fetching (axiosPublic, axiosSecure), auth, roles, dates
- firebase/firebase.config.js – Firebase SDK initialization

##### README for Additional Insights
- UI: React + Tailwind + DaisyUI + Meraki UI
- Routing: react-router-dom
- Data: Axios + TanStack Query
- Auth: Firebase
- Payments: Stripe (react-stripe)
- Deployment: Firebase Hosting (client), Vercel (presumably backend)
- Backend: Express.js + MongoDB (separate repo)

##### Main Components & Their Interactions
a. Front-end SPA
– React pages and components
– AuthProvider supplies user&role context via Firebase tokens
– useAxiosPublic/useAxiosSecure call backend REST APIs
– Stripe Checkout integration for payments
b. Backend API (Node/Express)
– /api/scholarships, /api/applications, /api/users, /api/reviews, /api/payments
– Secured endpoints validate Firebase JWT
– Role checks for Admin/Moderator via middleware
c. Database (MongoDB)
– Collections: users, scholarships, applications, reviews, payments
d. External Services
– Firebase Auth (sign-in, social login)
– Firebase Hosting (Serve static SPA)
– Stripe (payments)

##### Architectural Patterns & Design Principles
- Component-based UI with clear separation of pages vs. shared components
- Context + custom hooks for cross-cutting concerns (auth, data fetching)
- RESTful backend with role-based access control
- SPA routing with public, private, admin and moderator guards
- Third-party integrations (Firebase, Stripe) abstracted behind hooks

##### Details
- Sub-components that have their own responsibilities (AuthProvider, useAxiosSecure, CheckoutForm, PrivateRoute, etc.)
- How role-based route guards (AdminRoute, ModeratorRoute) connect to AuthProvider.
- Payment flow (React-Stripe → Stripe → backend webhook).
- Hosting/deployment context: Firebase Hosting serves the SPA; backend deployed to Vercel or another host.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Side - React SPA
    subgraph "Client: React SPA" 
        direction TB
        subgraph "Entry & Config" 
            direction TB
            A["main.jsx"]:::client
            B["index.css"]:::client
            C["App.css"]:::client
        end
        subgraph "Routing Layer" 
            direction TB
            D["Router.jsx"]:::client
            E["Main.jsx"]:::client
            F["PrivateRoute.jsx"]:::client
            G["OnlyAdminRoute.jsx"]:::client
            H["AdminAndModeratorRoute.jsx"]:::client
        end
        subgraph "Auth & Data Layer"
            direction TB
            I["AuthProvider.jsx"]:::client
            J["firebase.config.js"]:::client
            subgraph "Hooks" 
                direction TB
                K["useAuth.jsx"]:::client
                L["useAdmin.jsx"]:::client
                M["useAppliedDate.jsx"]:::client
                N["useAxiosPublic.jsx"]:::client
                O["useAxiosSecure.jsx"]:::client
            end
        end
        subgraph "UI Components"
            direction TB
            P["Pages"]:::client
            Q["Shared Components"]:::client
        end
    end

    %% Server Side - Backend API
    subgraph "Server: Node/Express API" 
        direction TB
        R["Express.js API"]:::server
        subgraph "Middleware"
            direction TB
            S["Auth Middleware"]:::server
            T["Role Check Middleware"]:::server
        end
        U["Business Logic"]:::server
        V["MongoDB Driver"]:::server
    end

    %% Database
    DB[(MongoDB)]:::database

    %% External Services
    subgraph "External Services"
        direction TB
        W["Firebase Auth"]:::external
        X["Firebase Hosting"]:::external
        Y["Stripe"]:::external
    end

    %% Data Flows
    user["User (Browser)"]:::external
    user -->|"1. Load SPA"| A
    A -->|"2. Init Auth"| W
    A -->|"3. Init Stripe UI"| Y
    A -->|"4. Fetch Routes"| D
    D -->|"5. Guard Routes"| F
    F -->|"6. Fetch Data (Secure)"| N
    N -->|"7. API Request (HTTPS)"| R
    R -->|"8. Verify JWT"| S
    S -->|"9. Role Check"| T
    T -->|"10. CRUD Ops"| V
    V -->|"11. Data Stored"| DB
    A -->|"12. Payment UI"| Y
    Y -->|"13. Webhook"| R
    R -->|"14. Update Payment"| V

    %% Click events
    click A "https://github.com/mohaiminul375/merit-matrix-client/blob/main/src/main.jsx"
    click B "https://github.com/mohaiminul375/merit-matrix-client/blob/main/src/index.css"
    click C "https://github.com/mohaiminul375/merit-matrix-client/blob/main/src/App.css"
    click D "https://github.com/mohaiminul375/merit-matrix-client/blob/main/src/Router/Router.jsx"
    click E "https://github.com/mohaiminul375/merit-matrix-client/blob/main/src/Router/Main.jsx"
    click F "https://github.com/mohaiminul375/merit-matrix-client/blob/main/src/Router/PrivateRoute.jsx"
    click G "https://github.com/mohaiminul375/merit-matrix-client/blob/main/src/Router/OnlyAdminRoute.jsx"
    click H "https://github.com/mohaiminul375/merit-matrix-client/blob/main/src/Router/AdminAndModeratorRoute.jsx"
    click I "https://github.com/mohaiminul375/merit-matrix-client/blob/main/src/Provider/AuthProvider.jsx"
    click J "https://github.com/mohaiminul375/merit-matrix-client/blob/main/src/firebase/firebase.config.js"
    click K "https://github.com/mohaiminul375/merit-matrix-client/blob/main/src/hooks/useAuth.jsx"
    click L "https://github.com/mohaiminul375/merit-matrix-client/blob/main/src/hooks/useAdmin.jsx"
    click M "https://github.com/mohaiminul375/merit-matrix-client/blob/main/src/hooks/useAppliedDate.jsx"
    click N "https://github.com/mohaiminul375/merit-matrix-client/blob/main/src/hooks/useAxiosPublic.jsx"
    click O "https://github.com/mohaiminul375/merit-matrix-client/blob/main/src/hooks/useAxiosSecure.jsx"

    %% Styles
    classDef client fill:#cce5ff,stroke:#004085,color:#004085
    classDef server fill:#d4edda,stroke:#155724,color:#155724
    classDef database fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef external fill:#fff3cd,stroke:#856404,color:#856404
```
