# mazharuldev/interspace architecture

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

- Interactive diagram: https://gitdiagram.com/mazharuldev/interspace
- Repository: https://github.com/mazharuldev/interspace

## Overview

##### Main System Components

a) Client Layer:
- Next.js Frontend (src/app directory structure)
- Routes into three main sections:
- Public Routes (root)
- Authentication Routes
- Dashboard Routes (with role-based access)

b) Application Layer:
- Components (src/components)
- Redux Store (src/redux)
- API Services (src/redux/api)
- Form Schemas (src/schemas)
- Helpers & Utils (src/helpers, src/utils)

c) External Services:
- SSLCommerz Payment Gateway
- Authentication System (JWT)

##### Architectural Patterns to Highlight

- Feature-based modular architecture (shown in the dashboard structure)
- Redux state management pattern
- Role-based access control (RBAC) with three distinct roles:
- Super Admin
- Admin
- User

##### Component Relationships

**Client Browser → Next.js Frontend → Redux Store → API Services → External Services**

##### Specific Elements

Frontend Layer:
**Public Routes:**
- Home
- Packages
- Booking
- Reviews

**Auth Routes:**
- Login
- Sign Up
- Profile Management

**Dashboard Routes (Role-based):**
- Super Admin Section
- Admin Section
- User Section

State Management:
**Redux Store**
- API Slices
- Admin API
- Auth API
- Booking API
- FAQ API
- Payment API
- Review API
- Service API
- User API
- Root Reducer

##### Important Flows to Highlight

a) Authentication Flow:
**Login/Signup → JWT Generation → Role-based Routing**

b) Booking Flow:
**Service Selection → Booking Creation → Payment Processing (SSLCommerz) → Confirmation**

c) Admin Management Flow:
**Super Admin → Admin Management → User Management → Service Management**

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        Browser["Web Browser"]
    end

    subgraph Frontend["Frontend Layer"]
        direction TB
        PublicRoutes["Public Routes"]:::frontend
        AuthRoutes["Auth Routes"]:::frontend
        DashboardRoutes["Dashboard Routes"]:::frontend

        subgraph Public["Public Section"]
            direction TB
            Home["Home"]:::frontend
            Packages["Packages"]:::frontend
            Booking["Booking"]:::frontend
            Reviews["Reviews"]:::frontend
        end

        subgraph Auth["Auth Section"]
            direction TB
            Login["Login"]:::frontend
            SignUp["Sign Up"]:::frontend
            Profile["Profile"]:::frontend
        end

        subgraph Dashboard["Role-Based Dashboard"]
            direction TB
            SuperAdmin["Super Admin"]:::frontend
            Admin["Admin"]:::frontend
            User["User"]:::frontend
        end
    end

    subgraph Core["Core Components"]
        direction TB
        Forms["Forms"]:::component
        UI["UI Components"]:::component
        Helpers["Helpers"]:::util
        Utils["Utils"]:::util
    end

    subgraph State["State Management"]
        direction TB
        ReduxStore["Redux Store"]:::state
        RootReducer["Root Reducer"]:::state

        subgraph APIs["API Services"]
            direction TB
            AdminAPI["Admin API"]:::api
            AuthAPI["Auth API"]:::api
            BookingAPI["Booking API"]:::api
            PaymentAPI["Payment API"]:::api
            ReviewAPI["Review API"]:::api
            ServiceAPI["Service API"]:::api
            UserAPI["User API"]:::api
        end
    end

    subgraph External["External Services"]
        direction TB
        SSLCommerz["SSLCommerz Payment"]:::external
        JWT["JWT Auth"]:::external
    end

    %% Relationships
    Browser --> PublicRoutes
    Browser --> AuthRoutes
    Browser --> DashboardRoutes

    PublicRoutes --> Public
    AuthRoutes --> Auth
    DashboardRoutes --> Dashboard

    Dashboard --> ReduxStore
    Public --> ReduxStore
    Auth --> ReduxStore

    ReduxStore --> RootReducer
    RootReducer --> APIs

    APIs --> SSLCommerz
    APIs --> JWT

    %% Click Events
    click PublicRoutes "https://github.com/MazharulDev/interspace/tree/master/src/app/(root)"
    click AuthRoutes "https://github.com/MazharulDev/interspace/tree/master/src/app/(auth)"
    click DashboardRoutes "https://github.com/MazharulDev/interspace/tree/master/src/app/(dashboard)"
    click SuperAdmin "https://github.com/MazharulDev/interspace/tree/master/src/app/(dashboard)/super_admin"
    click Admin "https://github.com/MazharulDev/interspace/tree/master/src/app/(dashboard)/admin"
    click User "https://github.com/MazharulDev/interspace/tree/master/src/app/(dashboard)/user"
    click ReduxStore "https://github.com/MazharulDev/interspace/blob/master/src/redux/store.ts"
    click RootReducer "https://github.com/MazharulDev/interspace/blob/master/src/redux/rootReducer.ts"
    click AdminAPI "https://github.com/MazharulDev/interspace/tree/master/src/redux/api"
    click AuthAPI "https://github.com/MazharulDev/interspace/blob/master/src/redux/api/authApi.ts"
    click BookingAPI "https://github.com/MazharulDev/interspace/blob/master/src/redux/api/bookingApi.ts"
    click PaymentAPI "https://github.com/MazharulDev/interspace/blob/master/src/redux/api/paymentApi.ts"
    click ReviewAPI "https://github.com/MazharulDev/interspace/blob/master/src/redux/api/reviewApi.ts"
    click ServiceAPI "https://github.com/MazharulDev/interspace/blob/master/src/redux/api/serviceApi.ts"
    click UserAPI "https://github.com/MazharulDev/interspace/blob/master/src/redux/api/userApi.ts"
    click Forms "https://github.com/MazharulDev/interspace/tree/master/src/components/forms"
    click UI "https://github.com/MazharulDev/interspace/tree/master/src/components/ui"
    click Helpers "https://github.com/MazharulDev/interspace/tree/master/src/helpers"
    click Utils "https://github.com/MazharulDev/interspace/tree/master/src/utils"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef state fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef util fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef component fill:#e74c3c,stroke:#c0392b,color:white
```
