# mohdzaidnagori/meta-one architecture

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

- Interactive diagram: https://gitdiagram.com/mohdzaidnagori/meta-one
- Repository: https://github.com/mohdzaidnagori/meta-one

## Overview

##### Project type and purpose
- This is a full-stack web application built with Next.js (React framework) that embeds a WebGL Unity build, integrates real-time video calls via Agora, and uses Firebase for backend services (authentication, database, hosting).
- Key user flows include: user authentication/registration, browsing “spaces,” launching Unity experiences, and joining peer video calls.

##### File structure
- Top-level framework:
- pages/ → Next.js page-based routing (UI + API routes)
- component/ → shared React UI pieces (cards, navbar, loader, Unity integration, router guards)
- public/Build/ → exported Unity WebGL build (loader, .wasm, framework)
- assets/ → static data for UI
- firebase.js & .firebaserc → Firebase initialization & config
- component/redux/CounterSlice.js → Redux state management
- component/router/AuthContext & ProtectedRouter → client-side auth guard
- component/agora/VideoCall.tsx → Agora video call integration

##### README for additional insights
- Confirms Next.js architecture with API routes under pages/api.
- Standard dev commands (npm run dev) and Vercel deploy.

##### Main components
a. Frontend (Next.js React)
– pages/ UI entry points (index.js, login, spaces/unity.jsx)
– component/ reusable UI + routing + global state
– Redux store for shared client state
– AuthContext & ProtectedRouter for client-side route protection
– UnityLoader component embedding public/Build files into a <canvas>
– Agora VideoCall component for in-app video sessions
b. Backend/API (Next.js API routes)
– pages/api/hello.js (example)
– any future API routes (e.g., user/profile, space/data)
c. External Services
– Firebase Auth & Firestore (initialized in firebase.js)
– Firebase Hosting (firebase.json config)
– Agora Real-Time Communication service
d. Static Assets & Build
– public/Build (Unity WebGL loader & binaries)
– assets/data JSON or JS modules
– public/video & public/images for media

##### Relationships & interactions
- Browser ↔ Next.js Frontend (HTTP/HTTPS)
- Frontend → Firebase Auth (via firebase.js) for sign-in flows
- Frontend → Firestore for data reads/writes (spaces, user profiles)
- Frontend → Next.js API routes (serverless handlers) for custom logic
- Frontend → public/Build loader to fetch Unity engine files
- In-page Unity <canvas> ↔ React components (postMessage or UnityWebGL events)
- Frontend ↔ Agora SDK via WebRTC for peer video streams

##### Architectural patterns & design principles
- Component-based UI (React) with a clear pages/ vs. component/ separation
- API routes as serverless micro-endpoints (Next.js functions)
- Context + Redux for state and auth propagation
- Static build assets (Unity) served from CDN/hosting
- Service-oriented external integration (Firebase, Agora)

##### Elements the engineer must include
- Component blocks labeled: “Next.js Pages,” “React Components,” “Redux Store,” “AuthContext,” “Unity Loader,” “Agora VideoCall.”
- External blocks: “Firebase Auth,” “Firestore,” “Firebase Hosting,” “Agora RTC.”
- Static assets block: “Unity WebGL Build (.data, .wasm, .loader.js).”
- Browser → Next.js (page fetch)
- Next.js → Firebase (auth, data)
- React → Unity build (fetch engine files)
- React → Agora (initiate/join call)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Layers
    Browser((User Browser)):::ui

    subgraph "Frontend (Next.js)" 
        subgraph "Next.js Pages" 
            Index["index.js"]:::ui
            LoginIndex["login/index.jsx"]:::ui
            LoginRegister["login/register.jsx"]:::ui
            LoginReset["login/resetpassword.jsx"]:::ui
            LoginVerified["login/verified.jsx"]:::ui
            SpacesIndex["spaces/index.jsx"]:::ui
            SpacesTest["spaces/test.jsx"]:::ui
            SpacesUnity["spaces/unity.jsx"]:::ui
        end

        subgraph "React UI Components"
            Card["Card.js"]:::ui
            LoadingCard["LoadingCard.js"]:::ui
            NewScard["NewScard.js"]:::ui
            Newspace["Newspace.js"]:::ui
            Serach["Serach.js"]:::ui
            Userspaces["Userspaces.js"]:::ui
            Navbar["Navbar.js"]:::ui
            Loginleft["Loginleft.js"]:::ui
            Exclusive["Exclusive.js"]:::ui
        end

        subgraph "Loader & Unity Integration"
            Unityloader["Unityloader.js"]:::ui
            Loader["Loader.js"]:::ui
        end

        subgraph "Auth & Routing Guards"
            AuthContext["AuthContext.js"]:::state
            ProtectedRouter["ProtectedRouter.js"]:::state
        end

        subgraph "State Management"
            CounterSlice["CounterSlice.js"]:::state
        end

        subgraph "Agora Video Call"
            VideoCall["VideoCall.tsx"]:::ui
        end

        Browser --> Index
        Index --> ReactComponents
        LoginIndex --> ReactComponents
        SpacesUnity --> Unityloader
        ReactComponents --> AuthContext
        ReactComponents --> CounterSlice
        ReactComponents --> VideoCall
        AuthContext --> ProtectedRouter
        ReactComponents --> Loader
        ReactComponents --> Unityloader
    end

    subgraph "Backend / API Routes"
        HelloAPI["hello.js"]:::ui
    end

    subgraph "External Services"
        FirebaseAuth[(Firebase Auth)]:::ext
        Firestore[(Firestore)]:::ext
        FirebaseHosting[(Firebase Hosting)]:::ext
        AgoraRTC[(Agora RTC)]:::ext
    end

    subgraph "Static Assets"
        subgraph UnityBuild["Unity WebGL Build"]
            DataFile["meta-one-V1.data"]:::doc
            FrameworkJS["meta-one-V1.framework.js"]:::doc
            LoaderJS["meta-one-V1.loader.js"]:::doc
            WasmFile["meta-one-V1.wasm"]:::doc
        end
        subgraph DataAssets["Data Modules"]
            ExploreData["exploreData.js"]:::doc
            ModalLink["modalLink.js"]:::doc
        end
        subgraph Media["Media Assets"]
            Images["public/images/"]:::doc
            Videos["public/video/1.mp4"]:::doc
        end
    end

    %% Connections
    Browser -->|"HTTP/HTTPS"| Index
    Index -->|"Render UI"| ReactComponents
    ReactComponents -->|"init auth"| FirebaseAuth
    ReactComponents -->|"read/write data"| Firestore
    ReactComponents -->|"fetch Engine Files"| UnityBuild
    Unityloader -.->|"postMessage events"| ReactComponents
    VideoCall -->|"initiate/join call"| AgoraRTC
    HelloAPI -->|"serverless request"| Firestore
    HelloAPI --> FirebaseAuth
    FirebaseHosting --> UnityBuild
    FirebaseHosting --> DataAssets
    FirebaseHosting --> Media

    %% Click Events
    click Index "https://github.com/mohdzaidnagori/meta-one/blob/main/pages/index.js"
    click LoginIndex "https://github.com/mohdzaidnagori/meta-one/blob/main/pages/login/index.jsx"
    click LoginRegister "https://github.com/mohdzaidnagori/meta-one/blob/main/pages/login/register.jsx"
    click LoginReset "https://github.com/mohdzaidnagori/meta-one/blob/main/pages/login/resetpassword.jsx"
    click LoginVerified "https://github.com/mohdzaidnagori/meta-one/blob/main/pages/login/verified.jsx"
    click SpacesIndex "https://github.com/mohdzaidnagori/meta-one/blob/main/pages/spaces/index.jsx"
    click SpacesTest "https://github.com/mohdzaidnagori/meta-one/blob/main/pages/spaces/test.jsx"
    click SpacesUnity "https://github.com/mohdzaidnagori/meta-one/blob/main/pages/spaces/unity.jsx"
    click Card "https://github.com/mohdzaidnagori/meta-one/blob/main/component/card/Card.js"
    click LoadingCard "https://github.com/mohdzaidnagori/meta-one/blob/main/component/card/LoadingCard.js"
    click NewScard "https://github.com/mohdzaidnagori/meta-one/blob/main/component/card/NewScard.js"
    click Newspace "https://github.com/mohdzaidnagori/meta-one/blob/main/component/card/Newspace.js"
    click Serach "https://github.com/mohdzaidnagori/meta-one/blob/main/component/card/Serach.js"
    click Userspaces "https://github.com/mohdzaidnagori/meta-one/blob/main/component/card/Userspaces.js"
    click Navbar "https://github.com/mohdzaidnagori/meta-one/blob/main/component/navbar/Navbar.js"
    click Loginleft "https://github.com/mohdzaidnagori/meta-one/blob/main/component/login-left/Loginleft.js"
    click Exclusive "https://github.com/mohdzaidnagori/meta-one/blob/main/component/home/Exclusive.js"
    click Unityloader "https://github.com/mohdzaidnagori/meta-one/blob/main/component/loader/Unityloader.js"
    click Loader "https://github.com/mohdzaidnagori/meta-one/blob/main/component/loader/Loader.js"
    click AuthContext "https://github.com/mohdzaidnagori/meta-one/blob/main/component/router/AuthContext.js"
    click ProtectedRouter "https://github.com/mohdzaidnagori/meta-one/blob/main/component/router/ProtectedRouter.js"
    click CounterSlice "https://github.com/mohdzaidnagori/meta-one/blob/main/component/redux/CounterSlice.js"
    click VideoCall "https://github.com/mohdzaidnagori/meta-one/blob/main/component/agora/VideoCall.tsx"
    click HelloAPI "https://github.com/mohdzaidnagori/meta-one/blob/main/pages/api/hello.js"
    click FirebaseAuth "https://github.com/mohdzaidnagori/meta-one/blob/main/firebase.js"
    click FirebaseHosting "https://github.com/mohdzaidnagori/meta-one/blob/main/.firebaserc"
    click FirebaseHosting "https://github.com/mohdzaidnagori/meta-one/blob/main/firebase.json"
    click DataFile "https://github.com/mohdzaidnagori/meta-one/blob/main/public/Build/meta-one-V1.data"
    click FrameworkJS "https://github.com/mohdzaidnagori/meta-one/blob/main/public/Build/meta-one-V1.framework.js"
    click LoaderJS "https://github.com/mohdzaidnagori/meta-one/blob/main/public/Build/meta-one-V1.loader.js"
    click WasmFile "https://github.com/mohdzaidnagori/meta-one/blob/main/public/Build/meta-one-V1.wasm"
    click ExploreData "https://github.com/mohdzaidnagori/meta-one/blob/main/assets/data/exploreData.js"
    click ModalLink "https://github.com/mohdzaidnagori/meta-one/blob/main/assets/data/modalLink.js"
    click Images "https://github.com/mohdzaidnagori/meta-one/tree/main/public/images/"
    click Videos "https://github.com/mohdzaidnagori/meta-one/blob/main/public/video/1.mp4"

    %% Styles
    classDef ui fill:#bbdefb,stroke:#0d47a1,color:#000
    classDef state fill:#c8e6c9,stroke:#1b5e20,color:#000
    classDef ext fill:#ffe0b2,stroke:#e65100,color:#000
    classDef doc fill:#e1bee7,stroke:#4a148c,color:#000
```
