# nirajanmahato/revivereads-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/nirajanmahato/revivereads-frontend
- Repository: https://github.com/nirajanmahato/revivereads-frontend

## Overview

##### Project type and purpose
- This is a single-page, full-stack-style front-end application built with React and Vite. It serves as a marketplace for books with user authentication, admin dashboards, real-time messaging, notifications, and product listing features. Although the repository only contains front-end code, it clearly depends on external back-end APIs (for auth, data persistence, messaging) and a WebSocket service for real-time updates.

##### File structure
- Top-level:
- public/ contains static assets (fonts, images, logos) served by the web server or CDN.
- src/ is the React application. Within src/:
– core/ separates public (unauthenticated) flows under core/public from private (authenticated/admin) flows under core/private.
– components/ holds shared UI components (Navbar, Footer, Modals, Map).
– context/ provides React Context providers (UserContext for auth state, SocketContext for real-time, NotificationContext).
– store/ and zustand/ implement client-side state management for auth and conversations.
– hooks/ define custom hooks that wrap API calls (useLogin, useBooks, useSendMessage, etc.).
- config files (vite.config.js, tailwind.config.js, eslint.config.js, playwright.config.js) define build, linting, styling, and end-to-end testing setups.
- Patterns:
- The “core” folder suggests an MVVM or feature-based modular structure.
- Routes are guarded via AdminRoute, ProtectedRoute, PublicRoute.
- Real-time via SocketContext.
- API interactions encapsulated in hooks and state stores.

##### Extract insights from README
- The README only describes the baseline React+Vite template. It does not detail the domain-specific architecture. All domain details must come from the file tree.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Services
    subgraph "External Services"
        direction TB
        AuthAPI[("Auth REST API")]:::external
        BookAPI[("Books REST API")]:::external
        MessageAPI[("Messaging REST API")]:::external
        NotificationAPI[("Notifications REST API")]:::external
        WebSocketServer[("WebSocket Service")]:::external
        CDN[("CDN / Object Storage")]:::external
    end

    %% Dev & CI/CD
    subgraph "Development & Deployment"
        direction TB
        ViteConfig[("Vite Dev Server\nConfiguration")]:::config
        TailwindConfig[("TailwindCSS\nConfiguration")]:::config
        PostCSSConfig[("PostCSS\nConfiguration")]:::config
        ESLintConfig[("ESLint\nConfiguration")]:::config
        PlaywrightConfig[("Playwright\nConfiguration")]:::test
        TestsExamples[("Example Tests")]:::test
        DomainTests[("Domain-Specific Tests")]:::test
    end

    %% Build & Serve
    ViteConfig -->|build assets| StaticAssets["Static Assets\n(index.html,\npublic/)"]:::external
    StaticAssets -->|served via| CDN

    %% Client Application
    subgraph "Browser / React SPA"
        direction TB
        EntryPoint[("src/main.jsx")]:::config
        RootComponent[("src/App.jsx")]:::ui
        CSSGlobal[("Global CSS\nsrc/index.css,\nsrc/App.css")]:::config

        subgraph "Contexts & Stores"
            direction TB
            UserContext[("UserContext\nAuthentication State")]:::service
            SocketContext[("SocketContext\nWebSocket Connection")]:::service
            NotificationContext[("NotificationContext\nIn-App Notifications")]:::service
            AuthStore[("Auth Store\nsrc/store/auth.js")]:::service
            RootStore[("Root Store\nsrc/store/index.js")]:::service
            ConversationStore[("Conversation Store\nsrc/zustand/useConverstaion.js")]:::service
        end

        subgraph "Shared UI Components"
            direction TB
            Components[("UI Components\nsrc/components/")]:::ui
            AdminRoute[("AdminRoute")]:::ui
            ProtectedRoute[("ProtectedRoute")]:::ui
            PublicRoute[("PublicRoute")]:::ui
        end

        subgraph "Custom Hooks"
            direction TB
            AuthHooks[("Auth Hooks\nuseLogin.js,\nuseRegister.js,\nuseUpdateUserStatus.js")]:::service
            BookHooks[("Book Hooks\nuseBooks.js,\nuseApprovedBooks.js,\nuseUserBooks.js,\nuseBookActions.js")]:::service
            MessageHooks[("Messaging Hooks\nuseGetConversations.js,\nuseGetMessages.js,\nuseSendMessage.js,\nuseListenMessages.js")]:::service
            DashboardHooks[("Dashboard Hooks\nuseDashboardSummary.js,\nuseDashboardGraphs.js,\nuseFetchUsers.js")]:::service
            ProductDetailsHook[("Product Details Hook\nuseProductDetails.js")]:::service
        end

        subgraph "Feature Modules"
            direction TB
            subgraph "Public Flows"
                direction TB
                PublicCore[("src/core/public/")]
            end
            subgraph "Private Flows"
                direction TB
                PrivateCore[("src/core/private/")]
            end
        end

        EntryPoint --> RootComponent --> CSSGlobal
        RootComponent --> UserContext --> SocketContext --> NotificationContext
        RootComponent --> AuthStore --> RootStore --> ConversationStore
        RootComponent --> Components
        Components --> AdminRoute
        Components --> ProtectedRoute
        Components --> PublicRoute
        RootComponent --> AuthHooks
        RootComponent --> BookHooks
        RootComponent --> MessageHooks
        RootComponent --> DashboardHooks
        RootComponent --> ProductDetailsHook
        RootComponent --> PublicCore
        RootComponent --> PrivateCore
    end

    %% Interactions
    RootComponent -->|REST Calls| AuthAPI
    RootComponent -->|REST Calls| BookAPI
    RootComponent -->|REST Calls| MessageAPI
    RootComponent -->|REST Calls| NotificationAPI
    SocketContext -->|WebSocket| WebSocketServer
    PublicCore -->|static fetch| CDN
    PrivateCore -->|static fetch| CDN

    %% CI/CD Tests
    PlaywrightConfig --> TestsExamples
    PlaywrightConfig --> DomainTests
    TestsExamples -->|run on| ViteConfig
    DomainTests -->|run on| ViteConfig

    %% Click Events
    click EntryPoint "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/main.jsx"
    click RootComponent "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/App.jsx"
    click ViteConfig "https://github.com/nirajanmahato/revivereads-frontend/blob/main/vite.config.js"
    click TailwindConfig "https://github.com/nirajanmahato/revivereads-frontend/blob/main/tailwind.config.js"
    click PostCSSConfig "https://github.com/nirajanmahato/revivereads-frontend/blob/main/postcss.config.js"
    click ESLintConfig "https://github.com/nirajanmahato/revivereads-frontend/blob/main/eslint.config.js"
    click Components "https://github.com/nirajanmahato/revivereads-frontend/tree/main/src/components/"
    click AdminRoute "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/components/routes/AdminRoute.jsx"
    click ProtectedRoute "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/components/routes/ProtectedRoute.jsx"
    click PublicRoute "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/components/routes/PublicRoute.jsx"
    click UserContext "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/context/UserContext.jsx"
    click SocketContext "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/context/SocketContext.jsx"
    click NotificationContext "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/context/NotificationContext.jsx"
    click AuthStore "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/store/auth.js"
    click RootStore "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/store/index.js"
    click ConversationStore "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/zustand/useConverstaion.js"
    click AuthHooks "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/hooks/useLogin.js"
    click AuthHooks "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/hooks/useRegister.js"
    click AuthHooks "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/hooks/useUpdateUserStatus.js"
    click BookHooks "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/hooks/useBooks.js"
    click BookHooks "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/hooks/useApprovedBooks.js"
    click BookHooks "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/hooks/useUserBooks.js"
    click BookHooks "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/hooks/useBookActions.js"
    click MessageHooks "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/hooks/useGetConversations.js"
    click MessageHooks "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/hooks/useGetMessages.js"
    click MessageHooks "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/hooks/useSendMessage.js"
    click MessageHooks "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/hooks/useListenMessages.js"
    click DashboardHooks "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/hooks/useDashboardSummary.js"
    click DashboardHooks "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/hooks/useDashboardGraphs.js"
    click DashboardHooks "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/hooks/useFetchUsers.js"
    click ProductDetailsHook "https://github.com/nirajanmahato/revivereads-frontend/blob/main/src/hooks/useProductDetails.js"
    click PublicCore "https://github.com/nirajanmahato/revivereads-frontend/tree/main/src/core/public/"
    click PrivateCore "https://github.com/nirajanmahato/revivereads-frontend/tree/main/src/core/private/"
    click PlaywrightConfig "https://github.com/nirajanmahato/revivereads-frontend/blob/main/playwright.config.js"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366D6,color:#000
    classDef service fill:#E6F4EA,stroke:#22863A,color:#000
    classDef external fill:#FFECD1,stroke:#D15704,color:#000
    classDef config fill:#F0F0F0,stroke:#6A737D,color:#000
    classDef test fill:#F5E1FF,stroke:#7928CA,color:#000
```
