# santosh-shetty/productordermanager architecture

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

- Interactive diagram: https://gitdiagram.com/santosh-shetty/productordermanager
- Repository: https://github.com/santosh-shetty/productordermanager

## Overview

##### Project Overview
- The project is a full-stack Purchase Order Management System.
- The backend is built in ASP.NET Core with Entity Framework Core interacting with a MySQL database.
- The frontend is built using React.js with a state management solution (Redux slices) and Axios for API calls.
- JWT authentication is used for securing the API endpoints, and Swagger is available for API documentation.

##### Main Components
a. Frontend:
- User Interface Layer: Contains pages (e.g., Dashboard, Login, Users, Suppliers, Purchase Orders, Audit Logs, Payments) and components (Layout, Modal).
- State Management: Located in the store (authSlice, purchaseOrdersSlice, suppliersSlice) to manage application state.
- API Service Layer: Axios-based API calls (found in frontend/src/lib/api.ts and axios.ts) to interact with the backend’s endpoints.

b. Backend:
- Controllers: One each for handling users, suppliers, purchase orders, PO items, payments, and audit logs.
- Models: Represent the data objects (User, Supplier, PurchaseOrder, PoItem, Payment, AuditLog) mapped to the database.
- Data Layer: ApplicationDbContext and EF Core migrations that manage MySQL database interactions.
- Authentication: JWT authentication mechanisms, possibly managed as middleware to secure API endpoints.
- Configuration: Appsettings files (appsettings.json and appsettings.Development.json) for configuring connection strings and other settings.
- API Documentation: Swagger endpoints for exposing API specs.

c. Database (External Component):
- MySQL database is used as the persistent data store.

##### Relationships & Interactions
- JWT authentication plays a key interlocking role, so illustrate how the Authentication Service (likely integrated in middleware) secures communication between the frontend and the backend.
- Swagger is provided for API documentation, so you could add an external “Swagger UI” component that interacts with the backend’s API endpoints.

##### Important Architectural Patterns
- MVC Pattern is observable in the backend (Controllers, Models, and the Data Context).
- The frontend leverages component-based design using React.js and uses Redux (store slices) for managing state.
- RESTful API principles are used to enable separation between frontend and backend.
- JWT Authentication is a significant pattern for secure API access.

##### Diagramming Details
- UI components (perhaps rectangles with blue backgrounds),
- Business logic/backend components (rectangles in green),

##### Putting It All Together
- Left Block: “Frontend (React)” – with its subcomponents (pages, components, store, API service).
- Right Block: “Backend (ASP.NET Core)” – containing Controllers, Models/Data, Authentication, and configuration files.
Inside the backend block, also add a connector to “MySQL Database” showing the Entity Framework Core data flow.
- JWT token handling between the frontend’s API calls and the backend’s secured endpoints.
- API documentation (Swagger) as an external component tied to the backend.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Block
    subgraph "Frontend (React)"
        %% UI Layer
        subgraph "UI Layer"
            A1["AuditLogs Page"]:::frontend
            A2["Dashboard Page"]:::frontend
            A3["Login Page"]:::frontend
            A4["Payments Page"]:::frontend
            A5["PurchaseOrders Page"]:::frontend
            A6["Register Page"]:::frontend
            A7["Suppliers Page"]:::frontend
            A8["Users Page"]:::frontend
            B1["Layout Component"]:::frontend
            B2["Modal Component"]:::frontend
        end
        %% State Management
        subgraph "State Management"
            SM1["authSlice"]:::frontend
            SM2["purchaseOrdersSlice"]:::frontend
            SM3["suppliersSlice"]:::frontend
        end
        %% API Service Layer
        subgraph "API Service Layer"
            API1["api.ts"]:::frontend
            API2["axios.ts"]:::frontend
        end
    end

    %% Backend Block
    subgraph "Backend (ASP.NET Core)"
        %% Controllers
        subgraph "Controllers"
            C1["UsersController"]:::backend
            C2["SuppliersController"]:::backend
            C3["PurchaseOrdersController"]:::backend
            C4["PoItemsController"]:::backend
            C5["PaymentsController"]:::backend
            C6["AuditLogsController"]:::backend
            C7["DashboardController"]:::backend
        end
        %% Data Access
        subgraph "Data Access"
            DA1["ApplicationDbContext"]:::backend
            DA2["Migrations"]:::backend
        end
        %% Models
        subgraph "Models"
            M1["User Model"]:::backend
            M2["Supplier Model"]:::backend
            M3["PurchaseOrder Model"]:::backend
            M4["PoItem Model"]:::backend
            M5["Payment Model"]:::backend
            M6["AuditLog Model"]:::backend
        end
        %% Configuration & Authentication
        subgraph "Configuration & Auth"
            CA1["appsettings.json"]:::backend
            CA2["appsettings.Development.json"]:::backend
            CA3["Program.cs"]:::backend
            CA4["api.txt"]:::backend
            CA5["Swagger UI"]:::backend
        end
    end

    %% External Database
    DB["MySQL Database"]:::database

    %% Relationships
    %% Frontend interactions
    A3 -->|"DispatchesLogin"| SM1
    SM1 -->|"TriggersAPI"| API1
    SM2 -->|"TriggersAPI"| API1
    SM3 -->|"TriggersAPI"| API1

    %% Frontend API calls to Backend Controllers (REST API calls)
    API1 -->|"REST_API"| C1
    API1 -->|"REST_API"| C2
    API1 -->|"REST_API"| C3
    API1 -->|"REST_API"| C4
    API1 -->|"REST_API"| C5
    API1 -->|"REST_API"| C6
    API1 -->|"REST_API"| C7

    %% Authentication flow using JWT (integrated via Program.cs)
    API1 -->|"JWT_Auth"| CA3
    CA3 -->|"Secures"| C1
    CA3 -->|"Secures"| C2
    CA3 -->|"Secures"| C3
    CA3 -->|"Secures"| C4
    CA3 -->|"Secures"| C5
    CA3 -->|"Secures"| C6
    CA3 -->|"Secures"| C7

    %% Controllers interact with Data Access (EF Core)
    C1 -->|"CRUD"| DA1
    C2 -->|"CRUD"| DA1
    C3 -->|"CRUD"| DA1
    C4 -->|"CRUD"| DA1
    C5 -->|"CRUD"| DA1
    C6 -->|"CRUD"| DA1
    C7 -->|"CRUD"| DA1

    %% Data Access communicates with the MySQL Database
    DA1 -->|"EF_Core"| DB

    %% Controllers use Models for data representation
    C1 ---|"Uses"| M1
    C2 ---|"Uses"| M2
    C3 ---|"Uses"| M3
    C4 ---|"Uses"| M4
    C5 ---|"Uses"| M5
    C6 ---|"Uses"| M6
    C7 ---|"Uses"| M1

    %% Swagger UI provides API documentation for Controllers
    CA5 -->|"API_Docs"| C1
    CA5 -->|"API_Docs"| C2
    CA5 -->|"API_Docs"| C3
    CA5 -->|"API_Docs"| C4
    CA5 -->|"API_Docs"| C5
    CA5 -->|"API_Docs"| C6
    CA5 -->|"API_Docs"| C7

    %% Click Events for Frontend UI Layer
    click A1 "https://github.com/santosh-shetty/productordermanager/blob/main/frontend/src/pages/AuditLogs.tsx"
    click A2 "https://github.com/santosh-shetty/productordermanager/blob/main/frontend/src/pages/Dashboard.tsx"
    click A3 "https://github.com/santosh-shetty/productordermanager/blob/main/frontend/src/pages/Login.tsx"
    click A4 "https://github.com/santosh-shetty/productordermanager/blob/main/frontend/src/pages/Payments.tsx"
    click A5 "https://github.com/santosh-shetty/productordermanager/blob/main/frontend/src/pages/PurchaseOrders.tsx"
    click A6 "https://github.com/santosh-shetty/productordermanager/blob/main/frontend/src/pages/Register.tsx"
    click A7 "https://github.com/santosh-shetty/productordermanager/blob/main/frontend/src/pages/Suppliers.tsx"
    click A8 "https://github.com/santosh-shetty/productordermanager/blob/main/frontend/src/pages/Users.tsx"
    click B1 "https://github.com/santosh-shetty/productordermanager/blob/main/frontend/src/components/Layout.tsx"
    click B2 "https://github.com/santosh-shetty/productordermanager/blob/main/frontend/src/components/Modal.tsx"

    %% Click Events for Frontend State Management
    click SM1 "https://github.com/santosh-shetty/productordermanager/blob/main/frontend/src/store/slices/authSlice.ts"
    click SM2 "https://github.com/santosh-shetty/productordermanager/blob/main/frontend/src/store/slices/purchaseOrdersSlice.ts"
    click SM3 "https://github.com/santosh-shetty/productordermanager/blob/main/frontend/src/store/slices/suppliersSlice.ts"

    %% Click Events for Frontend API Service Layer
    click API1 "https://github.com/santosh-shetty/productordermanager/blob/main/frontend/src/lib/api.ts"
    click API2 "https://github.com/santosh-shetty/productordermanager/blob/main/frontend/src/lib/axios.ts"

    %% Click Events for Backend Controllers
    click C1 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/Controllers/UsersController.cs"
    click C2 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/Controllers/SuppliersController.cs"
    click C3 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/Controllers/PurchaseOrdersController.cs"
    click C4 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/Controllers/PoItemsController.cs"
    click C5 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/Controllers/PaymentsController.cs"
    click C6 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/Controllers/AuditLogsController.cs"
    click C7 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/Controllers/DashboardController.cs"

    %% Click Events for Backend Data Access Layer
    click DA1 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/Data/ApplicationDbContext.cs"
    click DA2 "https://github.com/santosh-shetty/productordermanager/tree/main/backend/Migrations"

    %% Click Events for Backend Models
    click M1 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/Models/User.cs"
    click M2 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/Models/Supplier.cs"
    click M3 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/Models/PurchaseOrder.cs"
    click M4 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/Models/PoItem.cs"
    click M5 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/Models/Payment.cs"
    click M6 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/Models/AuditLog.cs"

    %% Click Events for Backend Configuration & Auth
    click CA1 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/appsettings.json"
    click CA2 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/appsettings.Development.json"
    click CA3 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/Program.cs"
    click CA4 "https://github.com/santosh-shetty/productordermanager/blob/main/backend/api.txt"

    %% Styling
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef database fill:#FFD700,stroke:#000,stroke-width:1px;
```
