# book-social-network/front_end architecture

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

- Interactive diagram: https://gitdiagram.com/book-social-network/front_end
- Repository: https://github.com/book-social-network/front_end

## Overview

##### Project type and purpose
- This is a React single‐page application (SPA) that provides a book‐centric social platform with two main user roles: Admin and User.
- Features (inferred from file names): user authentication, group creation/joining, posting and commenting on books, real‐time notifications (Pusher), admin dashboards for managing books/authors/groups/posts/users/types, and standard profile/leaderboard functionality.

##### File structure
- Top‐level:
- public/ – static HTML, manifest, robots.txt
- src/ – application source code
- src/index.js, src/App.jsx – entry points, root router
- src/routes/index.js – React Router configuration
- src/middleware/useAuth.jsx – authentication wrapper
- src/layout – high‐level layout per role:
- Admin/Components & Pages
- User/Components & Poster
- src/pages – feature pages (Login, Register, HomePage, DetailBook, CreateGroup, etc.)
- src/assets & src/css – static assets (images, banners) and CSS by feature
- package.json, .env – project dependencies and environment variables

##### README for additional insights
- Simple “npm install” & “npm run dev” process
- Requires the backend to be running before the front‐end

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client (Browser)" 
        direction TB
        subgraph "Entry Point"
            direction TB
            IDX["src/index.js"]:::frontend
            APP["src/App.jsx"]:::frontend
        end
        IDX -->|renders| APP

        subgraph "Routing"
            direction TB
            ROUTER["src/routes/index.js"]:::frontend
        end
        APP -->|uses Router| ROUTER

        subgraph "Auth Middleware"
            direction TB
            AUTH["useAuth.jsx"]:::frontend
        end
        ROUTER -->|guards routes via| AUTH

        subgraph "Layouts"
            direction TB
            ADMINLAY["Admin Layout"]:::frontend
            USERLAY["User Layout"]:::frontend
        end
        AUTH -->|renders| ADMINLAY
        AUTH -->|renders| USERLAY

        subgraph "Pages & Components"
            direction TB
            PAGES["src/pages"]:::frontend
        end
        ADMINLAY --> PAGES
        USERLAY --> PAGES

        subgraph "Hooks & Context"
            direction TB
            REQ["Request.jsx"]:::frontend
            PUSH["usePusher.jsx"]:::frontend
            MODAL["ModalContext.jsx"]:::frontend
            PROFILE["useUserProfile.jsx"]:::frontend
            ICON1["HeaderIcon.jsx"]:::frontend
            ICON2["IconAdmin.jsx"]:::frontend
            ICON3["IconToIcon.jsx"]:::frontend
            PROG["LinearProgessLabel.jsx"]:::frontend
            MYGRP["MyGroupItem.jsx"]:::frontend
            RECG["RecommendedGroup.jsx"]:::frontend
            CONTX["UseContext.jsx"]:::frontend
        end
        PAGES --> REQ
        PAGES --> PUSH
        PAGES --> MODAL
        PAGES --> PROFILE
        PAGES --> ICON1
        PAGES --> ICON2
        PAGES --> ICON3
        PAGES --> PROG
        PAGES --> MYGRP
        PAGES --> RECG
        PAGES --> CONTX

        subgraph "Assets & Styles"
            direction TB
            IMGS["src/assets/images"]:::assets
            BANN["src/assets/banners"]:::assets
            CSSG["src/index.css"]:::assets
            CSSF["src/css/*.css"]:::assets
        end
        APP --> IMGS
        APP --> BANN
        APP --> CSSG
        APP --> CSSF

        TEST["src/App.test.js"]:::frontend
        APP --> TEST
    end

    %% Server Layer
    subgraph "Server (API)"
        direction TB
        subgraph "Auth Service"
            direction TB
            AUTHAPI["/api/auth"]:::backend
        end
        subgraph "Book Service"
            direction TB
            BOOKAPI["/api/books"]:::backend
        end
        subgraph "Group Service"
            direction TB
            GROUPAPI["/api/groups"]:::backend
        end
        subgraph "Post Service"
            direction TB
            POSTAPI["/api/posts"]:::backend
        end
        subgraph "User Service"
            direction TB
            USERAPI["/api/users"]:::backend
        end
        subgraph "Type Service"
            direction TB
            TYPEAPI["/api/types"]:::backend
        end
    end

    DB["Database"]:::database

    %% External Services
    subgraph "External"
        direction TB
        PUSHER["Pusher"]:::external
        STORAGE["File Storage"]:::external
    end

    %% Connections
    REQ -->|HTTP Requests| AUTHAPI
    REQ -->|HTTP Requests| BOOKAPI
    REQ -->|HTTP Requests| GROUPAPI
    REQ -->|HTTP Requests| POSTAPI
    REQ -->|HTTP Requests| USERAPI
    REQ -->|HTTP Requests| TYPEAPI

    AUTHAPI -->|reads/writes| DB
    BOOKAPI -->|reads/writes| DB
    GROUPAPI -->|reads/writes| DB
    POSTAPI -->|reads/writes| DB
    USERAPI -->|reads/writes| DB
    TYPEAPI -->|reads/writes| DB

    PUSH -->|subscribes| PUSHER
    AUTHAPI -->|publishes events| PUSHER

    APP -->|loads static| STORAGE

    %% Click events
    click IDX "https://github.com/book-social-network/front_end/blob/main/src/index.js"
    click APP "https://github.com/book-social-network/front_end/blob/main/src/App.jsx"
    click ROUTER "https://github.com/book-social-network/front_end/blob/main/src/routes/index.js"
    click AUTH "https://github.com/book-social-network/front_end/blob/main/src/middleware/useAuth.jsx"
    click ADMINLAY "https://github.com/book-social-network/front_end/tree/main/src/layout/Admin"
    click USERLAY "https://github.com/book-social-network/front_end/tree/main/src/layout/User"
    click PAGES "https://github.com/book-social-network/front_end/tree/main/src/pages"
    click REQ "https://github.com/book-social-network/front_end/blob/main/src/hooks/Request.jsx"
    click PUSH "https://github.com/book-social-network/front_end/blob/main/src/hooks/usePusher.jsx"
    click MODAL "https://github.com/book-social-network/front_end/blob/main/src/hooks/ModalContext.jsx"
    click PROFILE "https://github.com/book-social-network/front_end/blob/main/src/hooks/useUserProfile.jsx"
    click ICON1 "https://github.com/book-social-network/front_end/blob/main/src/hooks/HeaderIcon.jsx"
    click ICON2 "https://github.com/book-social-network/front_end/blob/main/src/hooks/IconAdmin.jsx"
    click ICON3 "https://github.com/book-social-network/front_end/blob/main/src/hooks/IconToIcon.jsx"
    click PROG "https://github.com/book-social-network/front_end/blob/main/src/hooks/LinearProgessLabel.jsx"
    click MYGRP "https://github.com/book-social-network/front_end/blob/main/src/hooks/MyGroupItem.jsx"
    click RECG "https://github.com/book-social-network/front_end/blob/main/src/hooks/RecommendedGroup.jsx"
    click CONTX "https://github.com/book-social-network/front_end/blob/main/src/hooks/UseContext.jsx"
    click IMGS "https://github.com/book-social-network/front_end/tree/main/src/assets/images"
    click BANN "https://github.com/book-social-network/front_end/tree/main/src/assets/banners"
    click CSSG "https://github.com/book-social-network/front_end/blob/main/src/index.css"
    click CSSF "https://github.com/book-social-network/front_end/tree/main/src/css/"

    %% Styles
    classDef frontend fill:#cde8ff,stroke:#0366d6,color:#0366d6
    classDef backend fill:#e0f8e0,stroke:#2d8f2d,color:#2d8f2d
    classDef database fill:#ffe4b3,stroke:#cc7a00,color:#cc7a00
    classDef external fill:#f0d0ff,stroke:#a040a0,color:#a040a0
    classDef assets fill:#f7f7f7,stroke:#999999,color:#555555,stroke-dasharray: 2 2
```
