# nnq1610/bookstore_frontend architecture

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

- Interactive diagram: https://gitdiagram.com/nnq1610/bookstore_frontend
- Repository: https://github.com/nnq1610/bookstore_frontend

## Overview

##### Project type and purpose
- This is a frontend-only Single-Page Application (SPA) built with Create React App and TypeScript.
- Its purpose is to present books (Sách) to users: list books, show details (images, reviews), and allow user registration. It fetches data from a RESTful backend via API wrappers in `src/api`.

##### File structure
- Top‐level:
- public/ — static HTML/CSS/manifest for the SPA entrypoint.
- src/ — TypeScript code for the React app.
- package.json, tsconfig.json, etc. — build/configuration.
- In src/:
- api/ — service layer (`Request.ts`, `SachApi.ts`, `HinhAnhApi.ts`, `DanhGiaApi.ts`) that handles HTTP calls.
- models/ — shared data models (`SachModel`, `HinhAnhModel`, `DanhGiaModel`).
- layouts/ — feature folders:
– header-footer (Navbar, Footer)
– homepage (Banner, Carousel, Pagination)
– product (ProductList, ProductDetail components: images, reviews)
– about, user (registration), util (number formatting, ranking).
- App.tsx & index.tsx — application entry and router setup.

##### README
- It’s the default Create React App README, confirming the dev server, build scripts, and that this is purely a React front-end.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External
    Backend["External RESTful Backend\n(/api/books, /api/images, /api/reviews)"]:::external

    %% Browser and Static Assets
    Browser["Browser"]:::external
    StaticAssets["Static Asset Server\n(public/index.html, JS, CSS)"]:::external

    Browser -->|"GET index.html, JS, CSS"| StaticAssets
    StaticAssets -->|"Serves bundle"| Browser

    %% React Entrypoint and Router
    subgraph "React Application" 
        EntryIndex["index.tsx"]:::frontend
        EntryApp["App.tsx"]:::frontend
        EntryIndex --> EntryApp
        EntryApp --> Router["Router"]:::frontend
    end

    Browser -->|"loads bundle"| EntryIndex

    %% UI Layer
    subgraph "UI Components" 
        subgraph "Layout: Header/Footer" 
            Navbar["Navbar"]:::frontend
            Footer["Footer"]:::frontend
        end

        subgraph "Feature: Homepage"
            HomePage["HomePage"]:::frontend
            Banner["Banner"]:::frontend
            Carousel["Carousel"]:::frontend
            CarouselItem["CarouselItem"]:::frontend
            Pagination["PhanTrang"]:::frontend
            HomePage --> Banner
            HomePage --> Carousel
            Carousel --> CarouselItem
            HomePage --> Pagination
        end

        subgraph "Feature: Product (Sach)"
            ProductList["DanhSachSanPham"]:::frontend
            DetailView["ChiTietSanPham"]:::frontend
            ProductImages["HinhAnhSanPham"]:::frontend
            ProductReviews["DanhGiaSanPham"]:::frontend
            Props["SachProps"]:::frontend
            DetailView --> ProductImages
            DetailView --> ProductReviews
            DetailView --> Props
        end

        About["About"]:::frontend
        UserReg["DangKyNguoiDung"]:::frontend

        subgraph "Utils"
            FormatNumber["DinhDangSo"]:::frontend
            Ranking["XepHang"]:::frontend
        end

        Router --> Navbar
        Router --> Footer
        Router --> HomePage
        Router --> ProductList
        Router --> DetailView
        Router --> About
        Router --> UserReg
    end

    %% Service Layer
    subgraph "API Service Layer"
        RequestCore["Request.ts"]:::service
        SachApi["SachApi.ts"]:::service
        HinhAnhApi["HinhAnhApi.ts"]:::service
        DanhGiaApi["DanhGiaApi.ts"]:::service
        RequestCore --> SachApi
        RequestCore --> HinhAnhApi
        RequestCore --> DanhGiaApi
    end

    %% Data Models
    subgraph "Data Models"
        BookModel["Book.ts"]:::data
        SachModel["SachModel.ts"]:::data
        HinhAnhModel["HinhAnhModel.ts"]:::data
        DanhGiaModel["DanhGiaModel.ts"]:::data
    end

    %% Interactions
    HomePage -->|"calls SachApi"| SachApi
    ProductList -->|"calls SachApi"| SachApi
    DetailView -->|"calls SachApi, HinhAnhApi, DanhGiaApi"| SachApi
    DetailView --> HinhAnhApi
    DetailView --> DanhGiaApi

    SachApi -->|"GET /api/books → JSON"| Backend
    HinhAnhApi -->|"GET /api/images → JSON"| Backend
    DanhGiaApi -->|"GET /api/reviews → JSON"| Backend

    SachApi --> BookModel
    SachApi --> SachModel
    HinhAnhApi --> HinhAnhModel
    DanhGiaApi --> DanhGiaModel

    %% Click Events
    click StaticAssets "https://github.com/nnq1610/bookstore_frontend/blob/master/public/index.html"
    click EntryIndex "https://github.com/nnq1610/bookstore_frontend/blob/master/src/index.tsx"
    click EntryApp "https://github.com/nnq1610/bookstore_frontend/blob/master/src/App.tsx"
    click RequestCore "https://github.com/nnq1610/bookstore_frontend/blob/master/src/api/Request.ts"
    click SachApi "https://github.com/nnq1610/bookstore_frontend/blob/master/src/api/SachApi.ts"
    click HinhAnhApi "https://github.com/nnq1610/bookstore_frontend/blob/master/src/api/HinhAnhApi.ts"
    click DanhGiaApi "https://github.com/nnq1610/bookstore_frontend/blob/master/src/api/DanhGiaApi.ts"
    click BookModel "https://github.com/nnq1610/bookstore_frontend/blob/master/src/models/Book.ts"
    click SachModel "https://github.com/nnq1610/bookstore_frontend/blob/master/src/models/SachModel.ts"
    click HinhAnhModel "https://github.com/nnq1610/bookstore_frontend/blob/master/src/models/HinhAnhModel.ts"
    click DanhGiaModel "https://github.com/nnq1610/bookstore_frontend/blob/master/src/models/DanhGiaModel.ts"
    click Navbar "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/header-footer/Navbar.tsx"
    click Footer "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/header-footer/Footer.jsx"
    click HomePage "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/homepage/component/HomePage.tsx"
    click Banner "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/homepage/component/components.tsx/Banner.tsx"
    click Carousel "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/homepage/component/components.tsx/Carousel.tsx"
    click CarouselItem "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/homepage/component/components.tsx/CarouselItem.tsx"
    click Pagination "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/homepage/component/components.tsx/PhanTrang.tsx"
    click ProductList "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/product/DanhSachSanPham.tsx"
    click DetailView "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/product/components/ChiTietSanPham.tsx"
    click ProductImages "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/product/components/HinhAnhSanPham.tsx"
    click ProductReviews "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/product/components/DanhGiaSanPham.tsx"
    click Props "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/product/components/SachProps.tsx"
    click About "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/about/About.tsx"
    click UserReg "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/user/DangKyNguoiDung.tsx"
    click FormatNumber "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/util/DinhDangSo.tsx"
    click Ranking "https://github.com/nnq1610/bookstore_frontend/blob/master/src/layouts/util/XepHang.tsx"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#0288D1,stroke-width:1px
    classDef service fill:#C8E6C9,stroke:#2E7D32,stroke-width:1px
    classDef data fill:#DCEDC8,stroke:#558B2F,stroke-width:1px
    classDef external fill:#FFE0B2,stroke:#EF6C00,stroke-width:1px
```
