# raxa-akh/reactapp1 architecture

> Architecture diagram of the GitHub repository raxa-akh/reactapp1, 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/raxa-akh/reactapp1
- Repository: https://github.com/raxa-akh/reactapp1

## Overview

##### Project Type and Purpose
- This is a full-stack web application (a coursework “Курсовая работа”) that implements a shopping-list management system.
- Frontend: React + TypeScript SPA (Vite).
- Backend: ASP.NET Core Web API with Entity Framework Core, SignalR for real-time updates, JWT-based authentication.

##### File Structure Analysis
- Top-level solution (`ReactApp1.sln`) with two projects:
a. ReactApp1.Server (ASP.NET Core Web API)
- Controllers – REST endpoints (Auth, User, ShoppingList, ListItem, Product, ProductCategory, SharedAccess).
- Models – EF entities + DTOs (separate folders for Auth DTOs & Data DTOs).
- Data – DbSeeder, DbContext (AppDBContext + factory).
- Migrations – EF Core schema snapshots & migrations.
- Services – TokenService (JWT issuance).
- Hubs – ShoppingListHub (SignalR real-time).
- Configuration – appsettings.json, launchSettings.json.
b. reactapp1.client (React + TS)
- src/api – client wrappers for REST calls (`ListEditorPageApi.ts`).
- src/pages – page components (Home, ListEditor, MyLists, SharedLists, Login, Register).
- src/components – UI primitives (Button, Input, Header, Footer, Navigation, PrivateRoute).
- src/store – Redux Toolkit slices (authSlice) and store setup.
- src/layout – global Layout component.
- vite.config.ts, tsconfig‘s – build/configuration.
- This clear separation indicates an API-driven SPA architecture with a real-time channel for list updates.

a. Main Components
- Client: Browser running React SPA (pages, components, state management).
- API Layer: ASP.NET Core Web API Controllers.
- Real-Time Layer: SignalR Hub (ShoppingListHub) for publish/subscribe updates.
- Business Logic/Services: TokenService, DbSeeder.
- Data Access Layer: EF Core DbContext (AppDbContext) + Migrations.
- Database: Relational DB (e.g., SQL Server or SQLite configured in appsettings).
- External Dependencies: JWT Authentication provider (built-in ASP.NET), third-party NPM packages (React, Redux, Axios/fetch).

b. Relationships and Interactions
1) User → Browser SPA
- Initializes, routes to pages, displays data.
2) SPA → REST API (Controllers)
- Login/Register via AuthController → receives JWT.
- CRUD operations on ShoppingList, ListItem, Product, Category via respective controllers.
3) SPA ↔ SignalR Hub
- Connects to `/hubs/shoppingList` endpoint passing JWT for real-time list updates.
4) API → Services → DbContext → Database
- Controllers inject TokenService and DbContext.
- TokenService issues JWTs.
- DbContext performs CRUD, migrations apply schema.
5) SharedAccess flows: Users share lists via SharedAccessController, stored in DB.

c. Architectural Patterns & Principles
- Layered Architecture: Presentation (React), API (Controllers), Business (Services), Data (EF Core).
- DTO Pattern: Separate DTOs in Models/Dtos for API contracts.
- CQRS-style separation: Controllers orchestrate, DbContext handles data.
- Real-Time Event-Driven via SignalR.
- Authentication/Authorization via JWT Bearer.

d. Key Technologies & Frameworks
- Frontend: React, TypeScript, Redux Toolkit, Vite.
- Backend: ASP.NET Core 7+, EF Core, SignalR, JWT Authentication.
- Database: SQL Server / SQLite (configurable).
- Build/Config: dotnet CLI, migrations, NPM/Yarn.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Lane
    subgraph "Client (React SPA)"
        direction TB
        subgraph "Pages" 
            direction TB
            HomePage["Home Page"]:::frontend
            ListEditorPage["List Editor Page"]:::frontend
            MyListsPage["My Lists Page"]:::frontend
            SharedListsPage["Shared Lists Page"]:::frontend
            LoginPage["Login Page"]:::frontend
            RegisterPage["Register Page"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            PrivateRoute["PrivateRoute"]:::frontend
            Button["Button"]:::frontend
            Input["Input"]:::frontend
            Header["Header"]:::frontend
            Footer["Footer"]:::frontend
            Navigation["Navigation"]:::frontend
        end
        subgraph "State Management"
            direction TB
            Store["Store Setup"]:::frontend
            AuthSlice["Auth Slice"]:::frontend
        end
        APIClient["API Layer (ListEditorPageApi)"]:::frontend
        Layout["Layout"]:::frontend
        ConfigClient["Vite & TS Config"]:::frontend
    end

    %% Server Lane
    subgraph "Server (ASP.NET Core API)"
        direction TB
        subgraph "Controllers"
            direction TB
            AuthController["AuthController"]:::backend
            UserController["UserController"]:::backend
            ShoppingListController["ShoppingListController"]:::backend
            ListItemController["ListItemController"]:::backend
            ProductController["ProductController"]:::backend
            ProductCategoryController["ProductCategoryController"]:::backend
            SharedAccessController["SharedAccessController"]:::backend
        end
        ShoppingListHub["ShoppingListHub"]:::realtime
        subgraph "Services"
            direction TB
            TokenService["TokenService"]:::backend
            DbSeeder["DbSeeder"]:::backend
        end
        subgraph "Data Access"
            direction TB
            DbContext["AppDBContext"]:::backend
            DbContextFactory["AppDbContextFactory"]:::backend
            Migrations["EF Core Migrations"]:::backend
        end
        Database[(Database)]:::database
        subgraph "Models / DTOs"
            direction TB
            Entities["Entities"]:::backend
            AuthDTOs["Auth DTOs"]:::backend
            DataDTOs["Data DTOs"]:::backend
        end
        subgraph "Configuration"
            direction TB
            AppSettings["appsettings.json"]:::backend
            LaunchSettings["launchSettings.json"]:::backend
            Program["Program.cs"]:::backend
        end
    end

    %% External User
    User["User"]:::external

    %% Connections
    User -->|"interacts with"| HomePage
    User -->|"navigates"| ListEditorPage
    User -->|"navigates"| MyListsPage
    User -->|"navigates"| SharedListsPage
    User -->|"logs in/out"| LoginPage
    User -->|"registers"| RegisterPage

    HomePage -->|renders| Header
    HomePage -->|renders| Footer
    HomePage -->|uses| Navigation
    ListEditorPage -->|uses| APIClient
    MyListsPage -->|uses| APIClient
    SharedListsPage -->|uses| APIClient
    LoginPage -->|uses| APIClient
    RegisterPage -->|uses| APIClient

    APIClient -->|"HTTP/HTTPS JSON"| AuthController
    APIClient -->|"HTTP/HTTPS JSON"| ShoppingListController
    APIClient -->|"HTTP/HTTPS JSON"| ListItemController
    APIClient -->|"HTTP/HTTPS JSON"| ProductController
    APIClient -->|"HTTP/HTTPS JSON"| ProductCategoryController
    APIClient -->|"HTTP/HTTPS JSON"| SharedAccessController

    ListEditorPage -.->|"WebSocket SignalR"| ShoppingListHub
    ShoppingListHub -->|push updates| ListEditorPage

    AuthController -->|issues via| TokenService
    AuthController -->|"CRUD"| DbContext
    ShoppingListController -->|"CRUD"| DbContext
    ListItemController -->|"CRUD"| DbContext
    ProductController -->|"CRUD"| DbContext
    ProductCategoryController -->|"CRUD"| DbContext
    SharedAccessController -->|"CRUD"| DbContext

    TokenService -->|JWT| User
    DbContext -->|migrations| Migrations
    DbContext -->|reads/writes| Database
    DbSeeder -->|seeds| Database

    %% Click Events - Client
    click HomePage "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/pages/HomePage.tsx"
    click ListEditorPage "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/pages/ListEditorPage.tsx"
    click MyListsPage "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/pages/MyListsPage.tsx"
    click SharedListsPage "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/pages/SharedListsPage.tsx"
    click LoginPage "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/pages/LoginPage.tsx"
    click RegisterPage "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/pages/RegisterPage.tsx"
    click PrivateRoute "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/components/PrivateRoute.tsx"
    click Button "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/components/button/Button.tsx"
    click Input "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/components/input/Input.tsx"
    click Header "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/components/header/Header.tsx"
    click Footer "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/components/footer/Footer.tsx"
    click Navigation "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/components/navigation/Navigation.tsx"
    click Store "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/store/index.ts"
    click AuthSlice "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/store/slices/authSlice.ts"
    click APIClient "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/api/ListEditorPageApi.ts"
    click Layout "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/src/layout/Layout.tsx"
    click ConfigClient "https://github.com/raxa-akh/reactapp1/blob/master/reactapp1.client/vite.config.ts"

    %% Click Events - Server
    click AuthController "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.Server/Controllers/AuthController.cs"
    click UserController "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.Server/Controllers/UserController.cs"
    click ShoppingListController "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.Server/Controllers/ShoppingListController.cs"
    click ListItemController "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.Server/Controllers/ListItemController.cs"
    click ProductController "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.Server/Controllers/ProductController.cs"
    click ProductCategoryController "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.Server/Controllers/ProductCategoryController.cs"
    click SharedAccessController "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.Server/Controllers/SharedAccessController.cs"
    click ShoppingListHub "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.Server/Hubs/ShoppingListHub.cs"
    click TokenService "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.Server/Services/TokenService.cs"
    click DbSeeder "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.Server/Data/DbSeeder.cs"
    click DbContext "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.Server/AppDBContext.cs"
    click DbContextFactory "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.Server/AppDbContextFactory.cs"
    click Migrations "https://github.com/raxa-akh/reactapp1/tree/master/ReactApp1.Server/Migrations/"
    click AppSettings "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.Server/appsettings.json"
    click LaunchSettings "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.Server/Properties/launchSettings.json"
    click Program "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.Server/Program.cs"
    click User "https://github.com/raxa-akh/reactapp1/blob/master/ReactApp1.sln"

    %% Styling
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef backend fill:#d4edda,stroke:#155724,color:#155724
    classDef realtime fill:#fff3cd,stroke:#856404,color:#856404
    classDef database fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef external fill:#f8d7da,stroke:#721c24,color:#721c24
```
