# premiumdealhubofficial-hue/-codelibrary architecture

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

- Interactive diagram: https://gitdiagram.com/premiumdealhubofficial-hue/-codelibrary
- Repository: https://github.com/premiumdealhubofficial-hue/-codelibrary

## Overview

CodeLibrary is a programming eBook storefront with guest checkout, payment verification, and protected digital delivery, plus an admin control panel. The main journey is browsing the catalog, creating and verifying a payment, then accessing a token-authorized download and invoice. Management capabilities include catalog and bundle administration, orders and revenue analytics, coupons, 2FA, audit logs, settings, support, and database backups. Source excerpts show server mounting and key database operations; some frontend-to-API and gateway interactions are documented but not directly shown, so those links are dashed.

Main entry points: [`server/index.js`](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/index.js) (HTTP Server), [`server/db/schema.js`](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/db/schema.js) (SQLite Database), [`server/routes/download.js`](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/download.js) (Protected Downloads), [`server/routes/admin.js`](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/admin.js) (Admin Management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_webapp["Storefront UI<br/>[app.js]"]
  node_adminui["Admin UI<br/>[admin.js]"]
  node_catalog["Catalog and Bundles<br/>[books.js]"]
  node_reviews["Categories and Reviews<br/>[index.js]"]
  node_contact["Contact Support<br/>[contact.js]"]
end

subgraph group_commerce["Commerce and Delivery"]
  node_accounts["Customer Accounts<br/>[auth.js]"]
  node_checkout["Guest Checkout<br/>[payment.js]"]
  node_payment["Payment Verification<br/>[payment.js]"]
  node_orders["Orders and Invoices<br/>[orders.js]"]
  node_delivery["Protected Downloads<br/>[download.js]"]
  node_ebooks["eBook Files"]
end

subgraph group_operations["Admin Operations"]
  node_admin["Admin Management<br/>[admin.js]"]
  node_settings["Store Settings<br/>[settings.js]"]
  node_backup["Database Backups<br/>[backup.js]"]
end

subgraph group_platform["Platform Services"]
  node_server["HTTP Server<br/>[index.js]"]
  node_authmw["Token Authentication<br/>[auth.js]"]
  node_database[("SQLite Database<br/>[schema.js]")]
  node_seed["Catalog Initialization<br/>[seed.js]"]
  node_security["Security Middleware<br/>[security.js]"]
  node_limits["Rate Limits<br/>[rateLimiter.js]"]
end

node_shopper(("Shopper"))
node_razorpay["Razorpay"]
node_drive["Google Drive"]

node_shopper -.->|"browses and buys"| node_webapp
node_webapp -.->|"requests APIs"| node_server
node_server -->|"mounts routes"| node_catalog
node_server -->|"mounts routes"| node_accounts
node_server -->|"mounts routes"| node_checkout
node_server -->|"mounts routes"| node_orders
node_server -->|"mounts routes"| node_delivery
node_server -->|"mounts routes"| node_admin
node_server -->|"mounts routes"| node_settings
node_server -->|"mounts routes"| node_contact
node_server -->|"serves queries"| node_reviews
node_server -->|"applies security"| node_security
node_accounts -->|"uses authentication"| node_authmw
node_catalog -->|"reads catalog"| node_database
node_reviews -->|"reads reviews"| node_database
node_accounts -->|"reads and writes"| node_database
node_checkout -->|"creates orders"| node_database
node_checkout -.->|"creates payment"| node_razorpay
node_payment -->|"verifies and updates"| node_database
node_payment -->|"verifies signature"| node_razorpay
node_orders -->|"reads order data"| node_database
node_orders -->|"delegates download"| node_delivery
node_delivery -->|"checks access"| node_database
node_delivery -->|"streams local files"| node_ebooks
node_delivery -.->|"retrieves protected files"| node_drive
node_adminui -.->|"manages store"| node_admin
node_admin -->|"manages records"| node_database
node_admin -.->|"creates backups"| node_backup
node_admin -->|"checks admin access"| node_authmw
node_settings -->|"reads and writes"| node_database
node_contact -->|"stores messages"| node_database
node_database -->|"initializes catalog"| node_seed
node_backup -->|"backs up database"| node_database
node_server -->|"configures API limits"| node_limits

click node_webapp "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/public/js/app.js"
click node_adminui "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/public/js/admin.js"
click node_server "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/index.js"
click node_catalog "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/books.js"
click node_reviews "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/index.js"
click node_accounts "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/auth.js"
click node_authmw "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/middleware/auth.js"
click node_checkout "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/payment.js"
click node_payment "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/payment.js"
click node_orders "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/orders.js"
click node_delivery "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/download.js"
click node_ebooks "https://github.com/premiumdealhubofficial-hue/-codelibrary/tree/main/ebooks"
click node_admin "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/admin.js"
click node_settings "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/settings.js"
click node_contact "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/contact.js"
click node_database "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/db/schema.js"
click node_seed "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/db/seed.js"
click node_backup "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/utils/backup.js"
click node_security "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/middleware/security.js"
click node_limits "https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/middleware/rateLimiter.js"

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_webapp,node_adminui,node_catalog,node_reviews,node_contact toneBlue
class node_accounts,node_checkout,node_payment,node_orders,node_delivery,node_ebooks toneAmber
class node_admin,node_settings,node_backup toneMint
class node_server,node_authmw,node_database,node_seed,node_security,node_limits toneRose
class node_shopper,node_razorpay,node_drive toneIndigo
```

## Components

### Storefront

- [Storefront UI](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/public/js/app.js): `public/js/app.js`
- [Admin UI](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/public/js/admin.js): `public/js/admin.js`
- [Catalog and Bundles](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/books.js): `server/routes/books.js`
- [Categories and Reviews](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/index.js): `server/index.js`
- [Contact Support](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/contact.js): `server/routes/contact.js`

### Commerce and Delivery

- [Customer Accounts](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/auth.js): `server/routes/auth.js`
- [Guest Checkout](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/payment.js): `server/routes/payment.js`
- [Payment Verification](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/payment.js): `server/routes/payment.js`
- [Orders and Invoices](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/orders.js): `server/routes/orders.js`
- [Protected Downloads](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/download.js): `server/routes/download.js`
- [eBook Files](https://github.com/premiumdealhubofficial-hue/-codelibrary/tree/main/ebooks): `ebooks`

### Admin Operations

- [Admin Management](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/admin.js): `server/routes/admin.js`
- [Store Settings](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/routes/settings.js): `server/routes/settings.js`
- [Database Backups](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/utils/backup.js): `server/utils/backup.js`

### Platform Services

- [HTTP Server](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/index.js): `server/index.js`
- [Token Authentication](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/middleware/auth.js): `server/middleware/auth.js`
- [SQLite Database](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/db/schema.js): `server/db/schema.js`
- [Catalog Initialization](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/db/seed.js): `server/db/seed.js`
- [Security Middleware](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/middleware/security.js): `server/middleware/security.js`
- [Rate Limits](https://github.com/premiumdealhubofficial-hue/-codelibrary/blob/main/server/middleware/rateLimiter.js): `server/middleware/rateLimiter.js`

### Other components

- **Shopper**
- **Razorpay**
- **Google Drive**

## Connections

- Shopper → Storefront UI: browses and buys (evidence: `README.md`)
- Storefront UI → HTTP Server: requests APIs
- HTTP Server → Catalog and Bundles: mounts routes (evidence: `server/index.js`)
- HTTP Server → Customer Accounts: mounts routes (evidence: `server/index.js`)
- HTTP Server → Guest Checkout: mounts routes (evidence: `server/index.js`)
- HTTP Server → Orders and Invoices: mounts routes (evidence: `server/index.js`)
- HTTP Server → Protected Downloads: mounts routes (evidence: `server/index.js`)
- HTTP Server → Admin Management: mounts routes (evidence: `server/index.js`)
- HTTP Server → Store Settings: mounts routes (evidence: `server/index.js`)
- HTTP Server → Contact Support: mounts routes (evidence: `server/index.js`)
- HTTP Server → Categories and Reviews: serves queries (evidence: `server/index.js`)
- HTTP Server → Security Middleware: applies security (evidence: `server/index.js`)
- Customer Accounts → Token Authentication: uses authentication (evidence: `server/routes/auth.js`)
- Catalog and Bundles → SQLite Database: reads catalog (evidence: `server/routes/books.js`)
- Categories and Reviews → SQLite Database: reads reviews (evidence: `server/index.js`)
- Customer Accounts → SQLite Database: reads and writes (evidence: `server/routes/auth.js`)
- Guest Checkout → SQLite Database: creates orders (evidence: `server/routes/payment.js`)
- Guest Checkout → Razorpay: creates payment (evidence: `README.md`)
- Payment Verification → SQLite Database: verifies and updates (evidence: `server/routes/payment.js`)
- Payment Verification → Razorpay: verifies signature (evidence: `README.md`)
- Orders and Invoices → SQLite Database: reads order data (evidence: `server/routes/orders.js`)
- Orders and Invoices → Protected Downloads: delegates download (evidence: `server/routes/orders.js`)
- Protected Downloads → SQLite Database: checks access (evidence: `server/routes/download.js`)
- Protected Downloads → eBook Files: streams local files (evidence: `server/routes/download.js`)
- Protected Downloads → Google Drive: retrieves protected files (evidence: `README.md`)
- Admin UI → Admin Management: manages store (evidence: `README.md`)
- Admin Management → SQLite Database: manages records (evidence: `server/routes/admin.js`)
- Admin Management → Database Backups: creates backups (evidence: `server/routes/admin.js`)
- Admin Management → Token Authentication: checks admin access (evidence: `server/routes/admin.js`)
- Store Settings → SQLite Database: reads and writes (evidence: `server/routes/settings.js`)
- Contact Support → SQLite Database: stores messages (evidence: `server/routes/contact.js`)
- SQLite Database → Catalog Initialization: initializes catalog (evidence: `server/db/schema.js`)
- Database Backups → SQLite Database: backs up database (evidence: `server/utils/backup.js`)
- HTTP Server → Rate Limits: configures API limits (evidence: `server/index.js`)
