# mehul-anand/vinylstore architecture

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

- Interactive diagram: https://gitdiagram.com/mehul-anand/vinylstore
- Repository: https://github.com/mehul-anand/vinylstore

## Overview

##### Project type and purpose
- This is a full-stack e-commerce single-page application (“Vinyl Store”) built with React on the front end and a Node/Express server on the back end.
- It provides product browsing, filtering, cart and wishlist management, user authentication, and payment integration via Razorpay.

##### File structure
- Top-level split:
– public/ – static assets and HTML shell
– src/ – client and server code
–   src/backend/ – Express controllers, in-memory JSON “db” and auth utilities
–   src/Components, Pages, Context, Reducer, Utils – React UI modules, state management, API helpers
– server.js – Express app bootstrap, routes wired to controllers
- Patterns:
– Front-end uses React Context + Reducer (flux-style) for global state
– Back-end follows MVC-style controllers accessing JSON data files
– No external database; JSON files simulate persistence
- Build & deployment: single monorepo, likely two processes (webpack dev server or create-react-app and Node server)

##### README for additional insights
- Features: login/signup/logout, product filters, cart/wishlist flows, Razorpay payment
- Technical stack: React, Context API, Node, Express, Razorpay API

a. Main components
- User’s Web Browser / SPA (React App)
- Front-End Modules:
– UI Components (Pages, Components folder)
– State Management (Context + Reducers)
– API Utility Layer (Utils files calling REST endpoints)
- API Layer: Express Server (server.js + routes)
- Business Logic: Controllers (AuthController, ProductController, CartController, etc.)
- Data Layer: JSON “db” files under src/backend/db
- External Services: Razorpay payment gateway
b. Relationships & data flow
1. User interacts with UI → triggers React event handler
2. React dispatches to Context/Reducer → updates in-memory client state
3. For data fetch/mutation → front end HTTP calls to Express routes
4. Express route → calls appropriate Controller → reads/writes JSON db → returns JSON response
5. Payment checkout flow → front end initializes Razorpay widget → server calls Razorpay API via authUtils → confirm transaction
c. Architectural patterns / design principles
- SPA architecture: clear separation between view, client state, and API calls
- MVC in back end: thin routing layer, controller per resource
- Layered approach: UI → state → API → business logic → data
- Monolithic repo but logically decoupled front end and back end
d. Key technologies/frameworks
- React with Context API + CSS modules
- Node.js + Express.js
- Razorpay SDK (payment integration)
- JSON files as pseudo-database

##### Detailed guidance
- React sub-components at a high level (UI vs state vs API helpers)
- JSON files directory as a logical database layer

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client (Web Browser / SPA)" 
        direction TB
        Browser["User’s Web Browser / SPA"]:::frontend
        Entry["Front-End Entry Point<br/>src/index.js"]:::frontend
        App["App Bootstrap<br/>src/App.js"]:::frontend
        UIComps["UI Components<br/>src/Components/"]:::frontend
        UIPages["UI Pages<br/>src/Pages/"]:::frontend
        State["State Management<br/>(Context Providers + Reducers)"]:::frontend
        UtilsFE["API Utility Layer<br/>src/Utils/"]:::frontend
    end

    %% Server Layer
    subgraph "Server (Node/Express API)" 
        direction TB
        Server["Express Server<br/>src/server.js"]:::backend
        Controllers["Controllers<br/>src/backend/controllers/"]:::backend
        AuthUtils["Backend Utilities<br/>authUtils.js"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer (JSON Database)"
        direction TB
        DB["JSON DB Files<br/>src/backend/db/"]:::datastore
    end

    %% External Service
    Razorpay["Razorpay Payment Gateway"]:::external

    %% Client Flow
    Browser --> Entry
    Entry --> App
    App --> UIComps
    App --> UIPages
    App --> State
    State --> UtilsFE
    UtilsFE -->|HTTP Requests| Server

    %% Server Flow
    Server --> Controllers
    Controllers --> DB
    Controllers --> AuthUtils
    AuthUtils --> Razorpay

    %% Styles
    classDef frontend fill:#D6EFFF,stroke:#333,stroke-width:1px
    classDef backend fill:#D6FFD6,stroke:#333,stroke-width:1px
    classDef datastore fill:#FFE6A7,stroke:#333,stroke-width:1px
    classDef external fill:#E6D6FF,stroke:#333,stroke-width:1px

    %% Click Events
    click Browser "https://github.com/mehul-anand/vinylstore/blob/main/public/index.html"
    click Entry "https://github.com/mehul-anand/vinylstore/blob/main/src/index.js"
    click App "https://github.com/mehul-anand/vinylstore/blob/main/src/App.js"
    click UIComps "https://github.com/mehul-anand/vinylstore/tree/main/src/Components/"
    click UIPages "https://github.com/mehul-anand/vinylstore/tree/main/src/Pages/"
    click State "https://github.com/mehul-anand/vinylstore/tree/main/src/Context/"
    click UtilsFE "https://github.com/mehul-anand/vinylstore/tree/main/src/Utils/"
    click Server "https://github.com/mehul-anand/vinylstore/blob/main/src/server.js"
    click Controllers "https://github.com/mehul-anand/vinylstore/tree/main/src/backend/controllers/"
    click DB "https://github.com/mehul-anand/vinylstore/tree/main/src/backend/db/"
    click AuthUtils "https://github.com/mehul-anand/vinylstore/blob/main/src/backend/utils/authUtils.js"
```
