# yamakazeankk/book-store-be architecture

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

- Interactive diagram: https://gitdiagram.com/yamakazeankk/book-store-be
- Repository: https://github.com/yamakazeankk/book-store-be

## Overview

1. A .NET 6 back-end API (the “BookStore” project) that handles the core business logic, data access, and exposes REST API endpoints.
3. A Flutter mobile application for the Book Store client that interacts with the API (with configuration differences for web versus emulator/mobile).

##### Main Components
- API Backend (.NET 6):
- Controllers (provide REST endpoints for authentication, book management, orders, reviews, etc.)
- DTOs (for data transfer between layers)
- Models (domain/data objects like Book, Order, User, Voucher, etc.)
- Data Layer (includes the BookStoreContext for EF Core, Migrations to handle schema changes)
- Repositories (abstract the data access logic; interfaces and concrete implementations)
- Services (business logic handling such as BookService, EmailService, FileUploadService, etc.)
- Helper utilities (AutoMapperProfile for mapping, NotificationHub, etc.)
- Database:
- SQL Server (as configured in appsettings.json and data.sql for initial seeding)
- Admin Web (React Dashboard):
- Likely making API calls to the back-end to perform administrative tasks.
- Mobile Client (Flutter Book_Store):
- A Flutter/Dart application configured via api_config.dart to point to the back-end API.
- Implements UI and logic for mobile users to interact with the book store.

##### Relationships and Interactions
- The API Backend serves as the central hub for the system:
- It processes HTTP requests coming from both the Admin Dashboard and Flutter Mobile application.
- Controllers receive requests, invoke Services for business processing, then interact with Repositories which communicate with the Database.
- The Database (SQL Server) stores all persistent data (books, orders, users, reviews, etc.).
- The API layer might also integrate with external services (e.g., FirebaseStorageService indicates file storage integration).
- The Admin Dashboard and Mobile Client interact with the API through clearly defined endpoints:
- Use HTTP protocols where requests and responses are exchanged via JSON.
- Authentication, data fetching, and business operations are triggered from the client side.

##### Architectural Patterns and Design Principles
- Layered (n-tier) architecture within the API:
- Presentation Layer (Controllers)
- Business Logic Layer (Services)
- Data Access Layer (Repositories, Data Context, and EF Core Migrations)
- Separation of concerns:
- Each directory (Controllers, DTOs, Models, Repositories, Services, etc.) is responsible for a distinct aspect of the application.
- Use of dependency injection and mapping (AutoMapper) are evident for decoupling components.
- RESTful API design is presumed for handling client-server interactions.

##### Relevant Technologies, Frameworks, and Libraries
- .NET 6, ASP.NET Core for the API.
- Entity Framework Core for ORM with SQL Server.
- Flutter and Dart for the mobile application.
- Supporting tools like Git, SQL Server, and development tools (Visual Studio, VS Code).

##### Elements
- Use clear labels for each component:
- “Web API (BookStore)”, “React Admin Dashboard”, “Flutter Mobile Client”, and “SQL Server Database”.
- Controllers (entry point) → Services (business logic) → Repositories (data access) → EF Core and Database.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    subgraph "Clients"
        A["React Admin Dashboard"]:::client
        B["Flutter Mobile Client"]:::client
    end

    %% API Backend (.NET 6)
    subgraph "API Backend (.NET 6)"
        C["Controllers"]:::controllers
        D["DTOs"]:::dtos
        E["Models"]:::models
        H["Services"]:::services
        G["Repositories"]:::repository
        F["Data Layer (EF Core, BookStoreContext)"]:::data
        M["Migrations"]:::data
        I["Helper Utilities"]:::helper
    end

    %% Database Layer
    subgraph "Database"
        J["SQL Server Database"]:::database
        K["App Settings"]:::config
        L["Data Seeding"]:::config
    end

    %% Connections between Clients and API
    A -->|"HTTP_JSON"| C
    B -->|"HTTP_JSON"| C

    %% Internal API Flow
    C -->|"calls"| H
    C -->|"transfers"| D
    C -->|"accesses"| E
    H -->|"utilizes"| I
    H -->|"invokes"| G
    G -->|"queries"| F
    F -->|"communicates"| J
    M -->|"updates_schema"| J

    %% Database configuration connections (dashed)
    K ---|"configures"| J
    L ---|"seeds"| J

    %% Click Events
    click C "https://github.com/yamakazeankk/book-store-be/tree/master/BookStore/Controllers"
    click D "https://github.com/yamakazeankk/book-store-be/tree/master/BookStore/DTOs"
    click E "https://github.com/yamakazeankk/book-store-be/tree/master/BookStore/Models"
    click F "https://github.com/yamakazeankk/book-store-be/tree/master/BookStore/Data"
    click M "https://github.com/yamakazeankk/book-store-be/tree/master/BookStore/Migrations"
    click G "https://github.com/yamakazeankk/book-store-be/tree/master/BookStore/Repositories"
    click H "https://github.com/yamakazeankk/book-store-be/tree/master/BookStore/Services"
    click I "https://github.com/yamakazeankk/book-store-be/tree/master/BookStore/Helper"
    click K "https://github.com/yamakazeankk/book-store-be/blob/master/BookStore/appsettings.json"
    click L "https://github.com/yamakazeankk/book-store-be/blob/master/data.sql"

    %% Styles
    classDef client fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef controllers fill:#a2d2ff,stroke:#000,stroke-width:1px;
    classDef dtos fill:#cdeac0,stroke:#000,stroke-width:1px;
    classDef models fill:#dcedf2,stroke:#000,stroke-width:1px;
    classDef services fill:#fcbf49,stroke:#000,stroke-width:1px;
    classDef repository fill:#f4acb7,stroke:#000,stroke-width:1px;
    classDef data fill:#d3e0dc,stroke:#000,stroke-width:1px;
    classDef helper fill:#f4e1d2,stroke:#000,stroke-width:1px;
    classDef database fill:#bde0fe,stroke:#000,stroke-width:1px;
    classDef config fill:#ffc8dd,stroke:#000,stroke-width:1px;
```
