# steffenwaldvogel/ishop architecture

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

- Interactive diagram: https://gitdiagram.com/steffenwaldvogel/ishop
- Repository: https://github.com/steffenwaldvogel/ishop

## Overview

##### Project Type and Purpose
- This is a full-stack distributed e-commerce prototype called “iShop.”
- It comprises a static single‐page frontend, a RESTful Node.js/Express backend, Redis for session/cart caching, and PostgreSQL for persistent storage.

##### File Structure Analysis
- Top-level directories:
- backend/ – Node.js service with config/, routes/, server.js
- frontend/ – Static assets (HTML/CSS/JS) and app code
- Key backend patterns: configuration modules (db.js, redisClient.js, paypalClient.js), modular Express routes (products, cart, checkout, orders, shipping, paypal).
- Frontend is organized around pages and widgets (shopfront, cart, checkout, order confirmation) with a single app.js entry.

##### README Insights
- Service-oriented architecture: clear separation of concerns.
- Technologies: HTML/CSS/JS frontend, Express backend, PostgreSQL (normalized schema), Redis caching, mock PayPal.
- Features: product catalog, session-based cart, checkout flows, future order-confirmation UI.

a. Main Components
- Frontend (Browser)
- API Gateway / Express Backend
- PostgreSQL Database
- Redis Cache
- External/MOCK PayPal Service
b. Relationships & Data Flow
1. Browser ↔ REST endpoints on Express
2. Express → PostgreSQL for CRUD on orders, products, shipping/payment methods
3. Express → Redis for session cart persistence
4. Express → Mock PayPal for payment simulation
c. Architectural Patterns
- Layered: Presentation (frontend), API layer (Express routes/controllers), Data layer (Postgres + Redis)
- Service-oriented: each route group (cart, checkout, products…) acts as a mini-service module
d. Key Technologies
- Frontend: HTML, CSS, vanilla JS
- Backend: Node.js, Express
- Data: PostgreSQL (ER-modeled schema)
- Cache: Redis
- Payments: custom mock PayPal client module

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph "Client (Browser)" 
        AppJS["app.js"]:::frontend
        IndexHTML["index.html"]:::frontend
        CheckoutHTML["checkout.html"]:::frontend
        OrderHTML["order-confirmation.html"]:::frontend
        StyleCSS["style.css"]:::frontend
    end

    %% Server Layers
    subgraph "Server"
        Gateway["server.js\n(API Gateway)"]:::gateway

        subgraph "API Layer"
            Prod["/products"]:::api
            Cart["/cart"]:::api
            Checkout["/checkout"]:::api
            Orders["/orders"]:::api
            Shipping["/shipping"]:::api
            PayPalRoute["/paypal"]:::api
        end

        subgraph "Config/Clients"
            DBClient["db.js"]:::config
            RedisClient["redisClient.js"]:::config
            PayPalClient["paypalClient.js"]:::config
        end

        subgraph "Data Layer"
            Postgres["PostgreSQL"]:::db
            Redis["Redis Cache"]:::cache
        end

        subgraph "External Services"
            PayPalExtern["Mock PayPal"]:::external
        end
    end

    %% Flows
    AppJS -->|AJAX requests| Prod
    AppJS -->|AJAX requests| Cart
    AppJS -->|AJAX requests| Checkout
    AppJS -->|AJAX requests| Orders
    AppJS -->|AJAX requests| Shipping

    Prod -->|uses| DBClient
    Cart -->|uses| RedisClient
    Checkout -->|uses| DBClient
    Checkout -->|initiates payment| PayPalRoute
    Orders -->|uses| DBClient
    Shipping -->|uses| DBClient
    PayPalRoute -->|uses| PayPalClient

    DBClient -->|connects to| Postgres
    RedisClient -->|connects to| Redis
    PayPalClient -->|calls| PayPalExtern

    %% Click Events
    click AppJS "https://github.com/steffenwaldvogel/ishop/blob/main/frontend/app.js"
    click IndexHTML "https://github.com/steffenwaldvogel/ishop/blob/main/frontend/html/index.html"
    click CheckoutHTML "https://github.com/steffenwaldvogel/ishop/blob/main/frontend/html/checkout.html"
    click OrderHTML "https://github.com/steffenwaldvogel/ishop/blob/main/frontend/html/order-confirmation.html"
    click StyleCSS "https://github.com/steffenwaldvogel/ishop/blob/main/frontend/style.css"
    click Gateway "https://github.com/steffenwaldvogel/ishop/blob/main/backend/server.js"
    click Prod "https://github.com/steffenwaldvogel/ishop/blob/main/backend/routes/products.js"
    click Cart "https://github.com/steffenwaldvogel/ishop/blob/main/backend/routes/cart.js"
    click Checkout "https://github.com/steffenwaldvogel/ishop/blob/main/backend/routes/checkout.js"
    click Orders "https://github.com/steffenwaldvogel/ishop/blob/main/backend/routes/orders.js"
    click Shipping "https://github.com/steffenwaldvogel/ishop/blob/main/backend/routes/shipping.js"
    click PayPalRoute "https://github.com/steffenwaldvogel/ishop/blob/main/backend/routes/paypal.js"
    click DBClient "https://github.com/steffenwaldvogel/ishop/blob/main/backend/config/db.js"
    click RedisClient "https://github.com/steffenwaldvogel/ishop/blob/main/backend/config/redisClient.js"
    click PayPalClient "https://github.com/steffenwaldvogel/ishop/blob/main/backend/config/paypalClient.js"

    %% Styles
    classDef frontend fill:#1E3A8A,stroke:#FFFFFF,color:#FFFFFF
    classDef gateway fill:#0D9488,stroke:#FFFFFF,color:#FFFFFF
    classDef api fill:#14B8A6,stroke:#FFFFFF,color:#FFFFFF
    classDef config fill:#334155,stroke:#FFFFFF,color:#FFFFFF
    classDef cache fill:#F97316,stroke:#FFFFFF,color:#FFFFFF
    classDef db fill:#10B981,stroke:#FFFFFF,color:#FFFFFF
    classDef external fill:#8B5CF6,stroke:#FFFFFF,color:#FFFFFF
```
