# gopikapamisetty/mini-ecommerce architecture

> Architecture diagram of the GitHub repository gopikapamisetty/mini-ecommerce, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gopikapamisetty/mini-ecommerce
- Repository: https://github.com/gopikapamisetty/mini-ecommerce

## Overview

##### Project type and purpose
- This is a full-stack “Mini Commerce” web application.
- Frontend: React + Vite + Tailwind (components, Redux store).
- Backend: Express.js REST API + PostgreSQL (via a .env-configured connection).
- Purpose: Allow users to view, create, and edit products.

##### File structure
- Top-level “Backend” and “Frontend” directories indicate a clear separation of concerns.
- Backend:
- server.js: entry point, sets up Express, middleware, routes.
- controllers/: business logic for products.
- models/: product schema and ORM/mapping.
- db/index.js: database connection setup.
- routes/: URL endpoints mapping to controllers.
- .env: holds DB credentials and port.
- Frontend:
- src/: React app source.
- components/: UI components (ProductList, ProductForm, EditProduct, Navbar, etc.).
- components/ui/: design system primitives (button, input, table, etc.).
- redux/store.js: global state management, API slice.
- public/dist & Vite config: build output and bundler settings.
- .env: holds REACT_APP_API_URL.

##### README for additional insights
- Express server runs on port 5000 by default.
- Frontend dev server runs on port 3000 (default Vite) and proxies to the backend via REACT_APP_API_URL.
- No extra microservices or external integrations—just one Postgres instance.

##### Detail
- Environment variables feeding into each side.
- Data flow for key use cases (e.g., Add Product, Edit Product, List Products).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        Browser["Browser (React SPA)"]:::frontend
        MainJSX["main.jsx"]:::frontend
        AppJSX["App.jsx"]:::frontend
        UIComponents["UI Components"]:::frontend
        ReduxStore["Redux Store (store.js)"]:::frontend
        ConfigFiles["Config & Env"]:::config
        Browser -->|loads| MainJSX
        MainJSX -->|renders| AppJSX
        AppJSX -->|uses| UIComponents
        AppJSX -->|connects to| ReduxStore
        ConfigFiles -->|provides| MainJSX
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        Server["server.js"]:::backend
        Routes["productRoutes.js"]:::backend
        Controllers["productController.js"]:::backend
        Models["productModel.js"]:::backend
        DBClient["db/index.js"]:::backend
        EnvBackend[".env"]:::config
        Server -->|uses| Routes
        Routes -->|calls| Controllers
        Controllers -->|queries| Models
        Models -->|connects via| DBClient
        EnvBackend -->|provides| DBClient
    end

    %% Database
    PostgreSQL["PostgreSQL Database"]:::database

    %% Interactions
    Browser -->|HTTP Requests| Server
    Server -->|SQL Queries| PostgreSQL
    PostgreSQL -->|Results| Server
    Server -->|HTTP Responses| Browser

    %% Click Events Frontend
    click Browser "https://github.com/gopikapamisetty/mini-ecommerce/tree/main/Frontend/src"
    click MainJSX "https://github.com/gopikapamisetty/mini-ecommerce/blob/main/Frontend/src/main.jsx"
    click AppJSX "https://github.com/gopikapamisetty/mini-ecommerce/blob/main/Frontend/src/App.jsx"
    click UIComponents "https://github.com/gopikapamisetty/mini-ecommerce/tree/main/Frontend/src/components"
    click ReduxStore "https://github.com/gopikapamisetty/mini-ecommerce/blob/main/Frontend/src/redux/store.js"
    click ConfigFiles "https://github.com/gopikapamisetty/mini-ecommerce/blob/main/Frontend/.env"
    click ConfigFiles "https://github.com/gopikapamisetty/mini-ecommerce/blob/main/Frontend/tailwind.config.js"
    click ConfigFiles "https://github.com/gopikapamisetty/mini-ecommerce/blob/main/Frontend/postcss.config.js"
    click ConfigFiles "https://github.com/gopikapamisetty/mini-ecommerce/blob/main/Frontend/vite.config.js"

    %% Click Events UI primitives directory
    click UIComponents "https://github.com/gopikapamisetty/mini-ecommerce/tree/main/Frontend/src/components/ui"

    %% Click Events Backend
    click Server "https://github.com/gopikapamisetty/mini-ecommerce/blob/main/Backend/server.js"
    click Routes "https://github.com/gopikapamisetty/mini-ecommerce/blob/main/Backend/routes/productRoutes.js"
    click Controllers "https://github.com/gopikapamisetty/mini-ecommerce/blob/main/Backend/controllers/productController.js"
    click Models "https://github.com/gopikapamisetty/mini-ecommerce/blob/main/Backend/models/productModel.js"
    click DBClient "https://github.com/gopikapamisetty/mini-ecommerce/blob/main/Backend/db/index.js"
    click EnvBackend "https://github.com/gopikapamisetty/mini-ecommerce/blob/main/Backend/.env"

    %% Styles
    classDef frontend fill:#D6E9FF,stroke:#3B82F6,color:#1E40AF,stroke-width:1px;
    classDef backend fill:#D1FAE5,stroke:#10B981,color:#065F46,stroke-width:1px;
    classDef database fill:#FFEDD5,stroke:#F97316,color:#C2410C,stroke-width:1px;
    classDef config fill:#F3F4F6,stroke:#6B7280,color:#374151,stroke-width:1px;
```
