# nemliprog/rental-tracking-front architecture

> Architecture diagram of the GitHub repository nemliprog/rental-tracking-front, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nemliprog/rental-tracking-front
- Repository: https://github.com/nemliprog/rental-tracking-front

## Overview

##### Project type and purpose
- This is a single-page application (SPA) built with React, TypeScript and Vite.
- It implements a dashboard for managing customers, products and rentals, with reusable UI components and state management.
- It consumes a backend REST API (via axios) to fetch and mutate data.

##### File structure
- Top-level files: configuration (`vite.config.ts`, `.env`, ESLint), `index.html`, `package.json`.
- `src/main.tsx` bootstraps the React app and injects it into `index.html`.
- `src/app/` holds global application setup: the router (`routes.tsx`), Redux-style store (`store.ts`), and typed hooks.
- `src/common/` contains shared UI components (buttons, tables, inputs, layout containers), layout wrappers (`DashboardLayout`, `MainLayout`), and type definitions.
- `src/features/` is organized by domain: `customers/`, `products/`, `rental/`, `dashboard/`. Each feature folder has:
· React components (e.g. add/edit forms, cards, charts)
· Data-access logic (queries, hooks that wrap axios calls)
· Local types and validation logic
- `src/pages/` maps each feature to a URL route component.
- Assets (SVGs, fonts) under `src/assets/`.

##### README
- Confirms React+TS+Vite template with HMR and ESLint.

##### Main components
a. Client Browser
– Runs the compiled SPA, served by a static web host or dev server (Vite).
b. React Application
– Entry Point (`main.tsx` → `App.tsx`)
– Routing Layer (`routes.tsx`)
– State Management (`store.ts` + hooks.ts)
– Common UI Library (`common/components`, `common/layouts`)
– Feature Modules (`features/customers`, `features/products`, `features/rental`, `features/dashboard`)
c. External REST API
– Base URL configured in `src/config/axios.config.ts`
– `customersQueries`, `productsQueries`, `rentalQueries`, `dashboardQueries` define endpoints
d. Build & Tooling
– Vite dev server / build pipeline (`vite.config.ts`)
– ESLint config (`eslint.config.js`)
– TypeScript config files (`tsconfig.json`, etc.)

##### Relationships and interactions
- Browser requests `index.html` and loads the SPA.
- `main.tsx` initializes the store and router, then renders `<App />`.
- User navigates → `routes.tsx` selects a page in `src/pages/`.
- Page composes feature components (e.g. `<CustomersPage />` uses `useCustomers()` hook).
- Hooks dispatch actions to the store and call axios via `config/axios.config.ts`.
- Axios sends HTTP requests to the external API and returns data.
- Feature components read state from the store, render UI via common components.

##### Architectural patterns and design principles
- Modular “feature-folder” pattern for domain separation
- Centralized state (Redux style) with typed hooks (`useAppDispatch`, `useAppSelector`)
- Container/Presentation split: queries and business logic in hooks + separate UI⁄layout components
- Reusable common library for consistency (tables, forms, layouts)
- Vite’s plugin system for fast refresh and minimal build config

##### Elements
· User → Routing
· Routing → Pages → Feature Components → Hooks → API
· API → Hooks → Store → Components
· Blue for UI components
· Green for state & hooks
· Orange for data-access
· Gray for external API
- Annotations for major config files:
· `vite.config.ts` (build)
· `eslint.config.js` (lint)
· `tsconfig*.json` (type system)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Browser
    User["User"]:::external --> Browser["Browser (runs SPA)"]:::external

    %% SPA Entry Point
    subgraph "SPA"
        direction TB
        subgraph "Entry Point" 
            direction TB
            Main["main.tsx"]:::config
            App["App.tsx"]:::ui
        end

        %% Routing
        subgraph "Routing Layer"
            direction TB
            Routes["routes.tsx"]:::state
        end

        %% Pages
        subgraph "Pages (Route Components)"
            direction TB
            CustomersPage["CustomersPage.tsx"]:::ui
            ProductsPage["ProductsPage.tsx"]:::ui
            RentalPage["RentalPage.tsx"]:::ui
            DashboardPage["DashboardPage.tsx"]:::ui
        end

        %% Feature Modules
        subgraph "Feature Modules"
            direction TB
            CustomersModule["Feature: Customers"]:::ui
            ProductsModule["Feature: Products"]:::ui
            RentalModule["Feature: Rental"]:::ui
            DashboardModule["Feature: Dashboard"]:::ui
        end

        %% Common UI Library
        subgraph "Common UI Library"
            direction TB
            CommonComponents["common/components"]:::ui
            DashboardLayout["DashboardLayout.tsx"]:::ui
            MainLayout["MainLayout.tsx"]:::ui
            CommonTypes["types/index.ts"]:::state
        end

        %% State Management & Hooks
        subgraph "State Management & Hooks"
            direction TB
            Store["store.ts"]:::state
            Hooks["hooks.ts"]:::state
        end

        %% Data Access
        subgraph "Data Access"
            direction TB
            AxiosConfig["axios.config.ts"]:::data
        end

        %% Build & Tooling
        subgraph "Build & Tooling"
            direction TB
            ViteConfig["vite.config.ts"]:::config
            ESLintConfig["eslint.config.js"]:::config
            TSConfig["tsconfig*.json"]:::config
        end
    end

    %% External API
    ExternalAPI["External REST API"]:::external

    %% Data Flows
    Browser --> Main --> App --> Routes
    Routes --> CustomersPage
    Routes --> ProductsPage
    Routes --> RentalPage
    Routes --> DashboardPage

    CustomersPage --> CustomersModule
    ProductsPage --> ProductsModule
    RentalPage --> RentalModule
    DashboardPage --> DashboardModule

    CustomersModule --> Hooks
    ProductsModule --> Hooks
    RentalModule --> Hooks
    DashboardModule --> Hooks

    Hooks --> Store
    Hooks --> AxiosConfig
    AxiosConfig --> ExternalAPI
    ExternalAPI --> AxiosConfig

    %% Click Events
    click Main "https://github.com/nemliprog/rental-tracking-front/blob/master/src/main.tsx"
    click App "https://github.com/nemliprog/rental-tracking-front/blob/master/src/App.tsx"
    click Routes "https://github.com/nemliprog/rental-tracking-front/blob/master/src/app/routes.tsx"
    click Store "https://github.com/nemliprog/rental-tracking-front/blob/master/src/app/store.ts"
    click Hooks "https://github.com/nemliprog/rental-tracking-front/blob/master/src/app/hooks.ts"
    click CommonComponents "https://github.com/nemliprog/rental-tracking-front/tree/master/src/common/components"
    click DashboardLayout "https://github.com/nemliprog/rental-tracking-front/blob/master/src/common/layouts/DashboardLayout.tsx"
    click MainLayout "https://github.com/nemliprog/rental-tracking-front/blob/master/src/common/layouts/MainLayout.tsx"
    click CommonTypes "https://github.com/nemliprog/rental-tracking-front/blob/master/src/common/types/index.ts"
    click CustomersModule "https://github.com/nemliprog/rental-tracking-front/blob/master/src/features/customers/index.tsx"
    click ProductsModule "https://github.com/nemliprog/rental-tracking-front/blob/master/src/features/products/index.tsx"
    click RentalModule "https://github.com/nemliprog/rental-tracking-front/blob/master/src/features/rental/index.tsx"
    click DashboardModule "https://github.com/nemliprog/rental-tracking-front/blob/master/src/features/dashboard/index.tsx"
    click CustomersPage "https://github.com/nemliprog/rental-tracking-front/blob/master/src/pages/CustomersPage.tsx"
    click ProductsPage "https://github.com/nemliprog/rental-tracking-front/blob/master/src/pages/ProductsPage.tsx"
    click RentalPage "https://github.com/nemliprog/rental-tracking-front/blob/master/src/pages/RentalPage.tsx"
    click DashboardPage "https://github.com/nemliprog/rental-tracking-front/blob/master/src/pages/DashboardPage.tsx"
    click AxiosConfig "https://github.com/nemliprog/rental-tracking-front/blob/master/src/config/axios.config.ts"
    click ViteConfig "https://github.com/nemliprog/rental-tracking-front/blob/master/vite.config.ts"
    click ESLintConfig "https://github.com/nemliprog/rental-tracking-front/blob/master/eslint.config.js"
    click TSConfig "https://github.com/nemliprog/rental-tracking-front/blob/master/tsconfig.json"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef state fill:#E6FFEA,stroke:#28a745,color:#28a745
    classDef data fill:#FFF4E5,stroke:#e36209,color:#e36209
    classDef config fill:#F0F0F0,stroke:#6a737d,color:#6a737d
    classDef external fill:#F5F5F5,stroke:#444444,color:#444444
```
