Single-vendor computer & gaming e-commerce, Bangladesh. One Laravel application, two faces: the storefront and the admin panel. Flows are in flowchart.html.
Who and what talks to the system. Customers never see branches.
flowchart LR CUS["Customers<br/>guest and registered<br/>phone-first browser / installed web app"] STF["Staff<br/>Super Admin, managers, support,<br/>branch staff"] BOT["Search engines and<br/>social previews"] SYS["E-commerce system<br/>storefront + admin panel<br/>+ back end"] PAY["SSLCommerz<br/>cards, net banking, EMI"] WAL["bKash and Nagad"] COU["Couriers<br/>Pathao, Steadfast, RedX, more"] SMS["SMS gateway<br/>OTP and order SMS"] MAIL["Email service"] GOO["Google sign-in"] ADS["Analytics and ads<br/>GA, Search Console,<br/>Meta and TikTok pixels"] CUS -->|browse, buy, track| SYS STF -->|manage catalogue, stock, orders| SYS BOT -->|crawl SSR pages, sitemap, feeds| SYS SYS <-->|payments, refunds, IPN| PAY SYS <-->|payments, refunds, callbacks| WAL SYS <-->|book parcels, tracking webhooks| COU SYS -->|send| SMS SYS -->|send| MAIL SYS <-->|OAuth| GOO SYS -->|events, product feed| ADS
One codebase, one deployment. The storefront is server-rendered for SEO; the admin panel renders in the browser.
flowchart TB
U["Browsers and bots"] --> CDN["CDN<br/>images, JS, CSS, cached pages"]
CDN --> NG["Nginx<br/>HTTPS, compression, rate limits"]
subgraph APP["Application server - VPS or cloud"]
NG --> FPM["Laravel 12 on PHP-FPM<br/>storefront, admin, webhooks"]
FPM <-->|render page| SSR["Inertia SSR<br/>Node process, storefront only"]
HZ["Queue workers<br/>Laravel Horizon"]
SCH["Scheduler<br/>every minute"]
end
subgraph DATA["Data services"]
PG[("PostgreSQL<br/>all business data")]
RD[("Redis<br/>cache, sessions, queues, locks")]
MS[("Meilisearch<br/>product search and facets")]
OS[("Object storage<br/>images, invoices, exports")]
end
FPM --> PG
FPM --> RD
FPM --> MS
FPM --> OS
HZ --> PG
HZ --> RD
HZ --> MS
HZ --> OS
SCH --> RD
OS --> CDN
HZ -->|API calls| EXT["Payment, courier, SMS,<br/>email providers"]
EXT -->|callbacks and webhooks| NG
BK["Daily backups<br/>off-server, restore tested"] --- PG
Thin controllers; every business operation is an Action running in one database transaction.
flowchart TB
subgraph UI["Presentation - Vue 3 + Inertia"]
SP["Storefront pages<br/>ShopLayout, SSR, Tailwind, dark mode, bn/en"]
AP["Admin pages<br/>AdminLayout, shared DataTable"]
end
subgraph HTTP["HTTP"]
RT["Routes: storefront, admin, webhooks"]
MW["Middleware: auth, 2-step sign-in, permission,<br/>branch scope, rate limit, idempotency, locale"]
CT["Controllers - thin"]
FR["Form requests - all validation"]
PL["Policies - permission + branch checks"]
end
subgraph DOMAIN["Business logic"]
AC["Actions<br/>PlaceOrder, AssignBranch, ReserveStock,<br/>RecordPayment, AllocatePreOrders,<br/>GenerateSku, ProcessRefund"]
SV["Services<br/>Pricing, Inventory, Checkout, PreOrder,<br/>Warranty, Compatibility, Search"]
CN["Connectors<br/>Payment, Courier, SMS, Email"]
end
subgraph INFRA["Data and async"]
MD["Eloquent models<br/>decimal money, soft deletes"]
JB["Jobs and notifications - queued"]
EV["Events, e.g. product changed, order shipped"]
end
SP --> RT
AP --> RT
RT --> MW --> CT
CT --> FR
CT --> PL
CT --> AC
AC --> SV
AC --> CN
AC --> MD
SV --> MD
AC --> EV --> JB
JB --> CN
Arrows show which module depends on which.
flowchart LR ACC["Access<br/>users, roles, permissions,<br/>branches scope, audit"] CAT["Catalogue<br/>categories, spec templates, brands,<br/>attributes, products, variants, SKU"] INV["Inventory<br/>branches, stock ledger, reservations,<br/>serials, purchases, transfers"] PRC["Pricing and promotions<br/>price resolver, coupons, flash deals,<br/>offers, collections, loyalty"] CUS["Customers<br/>accounts, OTP, addresses,<br/>COD risk, wishlist, alerts"] CHK["Cart and checkout<br/>cart, PlaceOrder, branch choice"] PAY["Payments<br/>gateways, COD, EMI,<br/>refunds, reconciliation"] ORD["Orders<br/>lifecycle, edits, invoices,<br/>pre-orders"] DLV["Delivery<br/>zones, rates, couriers,<br/>shipments, COD settlement"] AFT["After-sale<br/>returns, warranty claims,<br/>reviews, questions"] PCB["PC Builder<br/>slots, compatibility rules,<br/>saved builds"] CMS["Content and SEO<br/>pages, banners, blog,<br/>sitemap, feeds"] NOT["Notifications<br/>templates, SMS, email, push"] REP["Reports and dashboard"] CAT --> INV CAT --> PRC CAT --> PCB INV --> CHK PRC --> CHK CUS --> CHK CHK --> ORD CHK --> PAY ORD --> DLV ORD --> AFT PAY --> AFT ORD --> NOT AFT --> NOT DLV --> NOT ORD --> REP INV --> REP PAY --> REP ACC --> CAT ACC --> INV ACC --> ORD CAT --> CMS
How a product page reaches a phone or Google fast, as complete HTML.
sequenceDiagram
autonumber
participant B as Browser or Googlebot
participant C as CDN
participant L as Laravel
participant R as Redis cache
participant D as PostgreSQL
participant N as SSR Node
B->>C: GET /product/lenovo-legion-5
alt Page cached at the CDN
C-->>B: HTML
else Not cached
C->>L: Forward request
L->>R: Product data cached?
alt Cache hit
R-->>L: Product, variants, total stock
else Cache miss
L->>D: Load product, variants, specs, total stock
L->>R: Store until the product changes
end
L->>N: Render page with this data
N-->>L: HTML with meta tags and structured data
L-->>C: HTML
C-->>B: HTML
end
Note over B: Vue takes over in the browser, later pages load as JSON
Order, branch choice, stock reservation and payment record are created together, or not at all.
sequenceDiagram autonumber participant B as Customer participant L as Laravel participant D as PostgreSQL participant G as Gateway participant Q as Queue B->>L: Place order L->>D: BEGIN transaction L->>L: Recalculate totals with the price resolver L->>D: Choose branch, lock stock rows, check availability L->>D: Create order, lines, reservation, payment record L->>D: COMMIT L-->>B: Redirect to gateway B->>G: Pay G->>L: Callback L->>G: Validate server to server L->>D: Payment paid, order confirmed - once per transaction id L->>Q: Order confirmed event Q->>Q: SMS, email, search stock update, staff alert
sequenceDiagram autonumber participant S as Staff participant L as Laravel participant K as Courier API participant D as PostgreSQL participant Q as Queue S->>L: Book parcel for a packed order L->>K: Create shipment with the branch's pickup account K-->>L: Tracking number and label L->>D: Shipment saved, order shipped, stock leaves on-hand K->>L: Webhook - delivered or failed L->>L: Verify signature, ignore repeats L->>D: Update shipment and order status L->>Q: Notify customer, add points or count COD refusal Note over L,K: Scheduled polling covers missed webhooks
| When | Job |
|---|---|
| Every minute | Release expired 15-minute payment holds and cancel those orders |
| Every few minutes | Poll courier tracking for open shipments; start and end flash deals |
| On change | Update the search index; clear page caches; resize uploaded images; send notifications; storefront change events |
| Hourly | Pre-order balance reminders and deadlines; stock and price-drop alerts; abandoned-cart reminders |
| Daily | Gateway settlement reconciliation; sitemap and product feeds; loyalty point expiry; database backup; stock ledger check |
| On request | Excel and PDF exports; bulk product imports with a validation report |
Main table groups and how they connect. Full list in spec.md section 20.
erDiagram
CATEGORY ||--o{ PRODUCT : contains
BRAND ||--o{ PRODUCT : makes
PRODUCT ||--|{ VARIANT : has
VARIANT ||--o{ PRODUCT_STOCK : "stocked at"
BRANCH ||--o{ PRODUCT_STOCK : holds
VARIANT ||--o{ STOCK_MOVEMENT : "moved by"
BRANCH ||--o{ STOCK_MOVEMENT : records
VARIANT ||--o{ SERIAL : "tracked as"
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ ORDER_ITEM : contains
VARIANT ||--o{ ORDER_ITEM : "sold as"
BRANCH ||--o{ ORDER : fulfils
ORDER ||--o{ PAYMENT : "paid by"
ORDER ||--o{ SHIPMENT : "shipped in"
ORDER ||--o{ RETURN : "returned in"
SERIAL ||--o{ WARRANTY_CLAIM : "claimed in"
USER }o--o{ ROLE : has
USER }o--o{ BRANCH : "assigned to"
ROLE }o--o{ PERMISSION : grants
| Layer | Choice | Why |
|---|---|---|
| Back end | Laravel 12, PHP 8.3 | Same stack as the reference ERP; mature queues, auth and validation |
| Front end | Inertia v2 + Vue 3, Tailwind CSS | One codebase for storefront and admin; modern UI and dark mode |
| SEO | Inertia SSR (Node) for storefront routes | Complete HTML for Google; structured data, sitemap, clean URLs |
| Database | PostgreSQL | Reliable transactions and row locks for stock and money |
| Cache, sessions, queues | Redis + Horizon | Speed under flash-sale load; visible queue monitoring |
| Search | Meilisearch via Laravel Scout | Instant, typo-tolerant search with spec filters |
| Files | Object storage + CDN, WebP/AVIF | Fast images on phones |
| PDF / Excel | DomPDF, Laravel Excel (queued) | Invoices, quotations, reports |
| Hosting | VPS or cloud server | Must run PHP and a Node process for SSR |
| Area | Rule |
|---|---|
| Money | Exact decimals in BDT, never floating point; prices VAT-inclusive |
| Stock | Append-only ledger; row locks on every change; available = on hand minus reserved |
| Transactions | Order, reservation and payment record written together |
| Payments | Paid only after server-to-server validation; callbacks and webhooks are idempotent; no card data stored |
| Totals | Always recalculated on the server; browser prices are ignored |
| Access | Every admin route behind a policy; branch scope on branch-owned data; 2-step sign-in for powerful roles |
| Privacy | Storefront never exposes branch data, cost prices or staff details |
| Abuse | Rate limits on sign-in, OTP and checkout; HTTPS everywhere; protection against common web attacks |
| Audit | Price, stock, refund, role, settings and SKU-setting changes logged with old and new values |
| Recovery | Daily off-server backups with tested restores |