# th3unmatchedk1yo/stock-management-website architecture

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

- Interactive diagram: https://gitdiagram.com/th3unmatchedk1yo/stock-management-website
- Repository: https://github.com/th3unmatchedk1yo/stock-management-website

## Overview

##### Main Components
- Frontend (Client):
– Built with Next.js, located in the “client” directory.
– Contains a rich set of UI components organized under “src/app” (e.g., dashboard, expenses, inventory, products, settings, users).
– Uses Redux (see file “client/src/app/redux.tsx”) for state management and Tailwind CSS (configured in “tailwind.config.ts”) for styling.
– Relies on public assets stored under “client/public/assets.”

- Backend (Server):
– Built with Express.js, found in the “server” directory.
– Implements RESTful API endpoints with separate controllers (e.g., dashboardController, expenseController, productController, userController) and route definitions under “server/src/routes.”
– Utilizes Prisma as an ORM; the “server/prisma” folder hosts the database schema, migrations, and seed data.

- Database:
– Although not explicitly defined in the file tree, the Prisma configuration (schema.prisma, migrations, and seed data files) implies a relational database backend.

##### Detail the Relationships and Interactions
- The Next.js frontend sends HTTP requests (or uses API routes) to Express backend endpoints.
- The Express server receives these API requests and processes them via specific controllers.
- Controllers delegate data operations to Prisma, which communicates with the underlying database.
– From the Client UI to the Backend API.
– From the Backend API to the Database via Prisma.
– From the Database back to the Backend and then to the Client.

##### Architectural Patterns and Technologies
- Separation of Concerns: The architecture clearly separates the presentation layer (Next.js client) from the business logic/API layer (Express controllers and routes) and the data access layer (Prisma ORM).
- RESTful API Design: The backend routes are organized for different domain modules such as dashboard, expenses, products, and users.
- Full-stack Integration: The client and server are decoupled but integrated through clearly defined API endpoints.
- Use of Modern Frontend Technologies: The client leverages Next.js file-based routing, reusable components (Header, Navbar, Sidebar, etc.), and state management with Redux.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph
    subgraph "Frontend (Next.js Client)"
        direction TB
        FE0["Next.js Client"]:::frontend
        FE1["UI Components (Dashboard,Expenses,Inventory,Products,Settings,Users)"]:::frontend
        FE2["State Management (Redux)"]:::frontend
        FE3["Styling (Tailwind CSS)"]:::frontend
        FE4["Public Assets"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend (Express.js API)"
        direction TB
        BE0["Express Server"]:::backend
        BE1["API Routes (Dashboard,Expenses,Product,User)"]:::backend
        BE2["API Controllers (Dashboard,Expense,Product,User)"]:::backend
    end

    %% Database Node
    DB["Database (Relational)"]:::database

    %% Frontend -> Backend Communication
    FE0 -->|"API_Calls/HTTP_Requests"| BE0
    BE0 -->|"Prisma_ORM_Queries"| DB
    DB -->|"Database_Response"| BE0
    BE0 -->|"HTTP_Responses"| FE0

    %% Internal Backend Flow
    BE1 -->|"delegates_to"| BE2

    %% Click Events for Frontend
    click FE0 "https://github.com/th3unmatchedk1yo/stock-management-website/tree/main/client"
    click FE1 "https://github.com/th3unmatchedk1yo/stock-management-website/tree/main/client/src/app"
    click FE2 "https://github.com/th3unmatchedk1yo/stock-management-website/blob/main/client/src/app/redux.tsx"
    click FE3 "https://github.com/th3unmatchedk1yo/stock-management-website/blob/main/client/tailwind.config.ts"
    click FE4 "https://github.com/th3unmatchedk1yo/stock-management-website/tree/main/client/public/assets"

    %% Click Events for Backend
    click BE0 "https://github.com/th3unmatchedk1yo/stock-management-website/tree/main/server"
    click BE1 "https://github.com/th3unmatchedk1yo/stock-management-website/tree/main/server/src/routes"
    click BE2 "https://github.com/th3unmatchedk1yo/stock-management-website/tree/main/server/src/controllers"

    %% Click Event for Database (Prisma)
    click DB "https://github.com/th3unmatchedk1yo/stock-management-website/tree/main/server/prisma"

    %% Styling Classes
    classDef frontend fill:#BEE3F8,stroke:#2C5282,color:#2C5282;
    classDef backend fill:#C6F6D5,stroke:#2F855A,color:#2F855A;
    classDef database fill:#FBD38D,stroke:#DD6B20,color:#DD6B20;
```
