# riyaz510/cartify architecture

> Architecture diagram of the GitHub repository riyaz510/cartify, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/riyaz510/cartify
- Repository: https://github.com/riyaz510/cartify

## Overview

This is an Express storefront with an admin product catalog, a shopping cart, and placeholder checkout/orders pages. The main workflow routes browser requests through controllers to product/cart data access, then renders EJS pages. Product persistence is configured through Sequelize/MySQL; cart persistence uses a JSON file. Sampled cart-controller calls reference product methods not present in the sampled Sequelize model, so those paths may not work as written. The README is empty, and unsampled view details are represented only by their paths.

Main entry points: [`app.js`](https://github.com/riyaz510/cartify/blob/main/app.js) (Express app), [`controllers/shop.js`](https://github.com/riyaz510/cartify/blob/main/controllers/shop.js) (Shop controller), [`controllers/admin.js`](https://github.com/riyaz510/cartify/blob/main/controllers/admin.js) (Admin controller), [`models/product.js`](https://github.com/riyaz510/cartify/blob/main/models/product.js) (Product model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web routing"]
  node_app["Express app<br/>[app.js]"]
  node_shop_routes["Shop routes<br/>[shop.js]"]
  node_admin_routes["Admin routes<br/>[admin.js]"]
  node_error_controller["404 handler<br/>[error.js]"]
end

subgraph group_catalog["Product catalog"]
  node_admin_controller["Admin controller<br/>[admin.js]"]
  node_product_model["Product model<br/>[product.js]"]
end

subgraph group_shopping["Shopping flow"]
  node_shop_controller["Shop controller<br/>[shop.js]"]
  node_cart_model["Cart model<br/>[cart.js]"]
end

subgraph group_persistence["Persistence and views"]
  node_sequelize["Sequelize config<br/>[db.js]"]
  node_mysql[("MySQL database")]
  node_cart_file[("Cart file<br/>[cart.json]")]
  node_shop_views["Shop pages"]
  node_admin_views["Admin pages"]
  node_error_view["404 page<br/>[404.ejs]"]
end

node_visitor(("Shop visitor"))

node_visitor -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_shop_routes
node_app -->|"mounts routes"| node_admin_routes
node_app -->|"handles unmatched"| node_error_controller
node_app -->|"syncs models"| node_sequelize
node_shop_routes -->|"dispatches"| node_shop_controller
node_admin_routes -->|"dispatches"| node_admin_controller
node_shop_controller -->|"queries products"| node_product_model
node_admin_controller -->|"manages products"| node_product_model
node_product_model -->|"defines model"| node_sequelize
node_sequelize -->|"reads and writes"| node_mysql
node_shop_controller -->|"updates and reads cart"| node_cart_model
node_cart_model -->|"reads and writes"| node_cart_file
node_shop_controller -->|"renders pages"| node_shop_views
node_admin_controller -->|"renders pages"| node_admin_views
node_error_controller -->|"renders page"| node_error_view

click node_app "https://github.com/riyaz510/cartify/blob/main/app.js"
click node_shop_routes "https://github.com/riyaz510/cartify/blob/main/routes/shop.js"
click node_admin_routes "https://github.com/riyaz510/cartify/blob/main/routes/admin.js"
click node_error_controller "https://github.com/riyaz510/cartify/blob/main/controllers/error.js"
click node_shop_controller "https://github.com/riyaz510/cartify/blob/main/controllers/shop.js"
click node_admin_controller "https://github.com/riyaz510/cartify/blob/main/controllers/admin.js"
click node_product_model "https://github.com/riyaz510/cartify/blob/main/models/product.js"
click node_cart_model "https://github.com/riyaz510/cartify/blob/main/models/cart.js"
click node_sequelize "https://github.com/riyaz510/cartify/blob/main/util/db.js"
click node_cart_file "https://github.com/riyaz510/cartify/blob/main/data/cart.json"
click node_shop_views "https://github.com/riyaz510/cartify/tree/main/views/shop"
click node_admin_views "https://github.com/riyaz510/cartify/tree/main/views/admin"
click node_error_view "https://github.com/riyaz510/cartify/blob/main/views/404.ejs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_shop_routes,node_admin_routes,node_error_controller toneBlue
class node_admin_controller,node_product_model toneAmber
class node_shop_controller,node_cart_model toneMint
class node_sequelize,node_mysql,node_cart_file,node_shop_views,node_admin_views,node_error_view toneRose
class node_visitor toneIndigo
```

## Components

### Web routing

- [Express app](https://github.com/riyaz510/cartify/blob/main/app.js): `app.js`
- [Shop routes](https://github.com/riyaz510/cartify/blob/main/routes/shop.js): `routes/shop.js`
- [Admin routes](https://github.com/riyaz510/cartify/blob/main/routes/admin.js): `routes/admin.js`
- [404 handler](https://github.com/riyaz510/cartify/blob/main/controllers/error.js): `controllers/error.js`

### Product catalog

- [Admin controller](https://github.com/riyaz510/cartify/blob/main/controllers/admin.js): `controllers/admin.js`
- [Product model](https://github.com/riyaz510/cartify/blob/main/models/product.js): `models/product.js`

### Shopping flow

- [Shop controller](https://github.com/riyaz510/cartify/blob/main/controllers/shop.js): `controllers/shop.js`
- [Cart model](https://github.com/riyaz510/cartify/blob/main/models/cart.js): `models/cart.js`

### Persistence and views

- [Sequelize config](https://github.com/riyaz510/cartify/blob/main/util/db.js): `util/db.js`
- **MySQL database**
- [Cart file](https://github.com/riyaz510/cartify/blob/main/data/cart.json): `data/cart.json`
- [Shop pages](https://github.com/riyaz510/cartify/tree/main/views/shop): `views/shop`
- [Admin pages](https://github.com/riyaz510/cartify/tree/main/views/admin): `views/admin`
- [404 page](https://github.com/riyaz510/cartify/blob/main/views/404.ejs): `views/404.ejs`

### Other components

- **Shop visitor**

## Connections

- Shop visitor → Express app: sends requests
- Express app → Shop routes: mounts routes
- Express app → Admin routes: mounts routes
- Express app → 404 handler: handles unmatched
- Express app → Sequelize config: syncs models
- Shop routes → Shop controller: dispatches
- Admin routes → Admin controller: dispatches
- Shop controller → Product model: queries products
- Admin controller → Product model: manages products
- Product model → Sequelize config: defines model
- Sequelize config → MySQL database: reads and writes
- Shop controller → Cart model: updates and reads cart
- Cart model → Cart file: reads and writes
- Shop controller → Shop pages: renders pages
- Admin controller → Admin pages: renders pages
- 404 handler → 404 page: renders page
