Dev Reference
Bloomify โ€” Dev Reference
Architecture, DB schema, API routes, theme colours

Architecture

Browser
  โ””โ”€โ”€ Cloudflare Pages (bloomify-portal)
        Static React SPA (React 18 + TypeScript + Vite)
        โ””โ”€โ”€ API calls โ†’ Cloudflare Worker (bloomify-api)
                         โ””โ”€โ”€ D1 Database (bloomify_db)

The frontend is a fully static SPA deployed to Cloudflare Pages. All data operations go through the Cloudflare Worker which owns the D1 database. CORS is locked to https://bloomifyofficial.sonandigital.com via the ALLOWED_ORIGIN env variable in wrangler.toml.

Theme Colours

TokenHexUse
Pale pink bg#FDF0F3Page background
Pink#E8A0B0Accents, borders
Pink dark#C4758BButtons, highlights
Pink darker#A05870Dark button states, headings
Hero gradientlinear-gradient(135deg, #A05870 0%, #C4758B 60%, #E8A0B0 100%)Hero section

Currency Pattern

All monetary values are stored as integer paisa (PKR ร— 100) in the database. Display format:

// Convert cents/paisa to display string
const display = `Rs. ${Math.round(value_cents / 100).toLocaleString()}`;
// Example: 150000 paisa โ†’ "Rs. 1,500"

DB Schema

TableKey Columns
admin_usersid, email, password_hash, full_name, created_at
clientsid, name, email, phone, instagram, address, notes, created_at
productsid, name, description, category, base_price_cents, base_cost_cents, is_active, sort_order, created_at
ordersid, client_id, product_id, occasion, custom_notes, colors, quantity, price_cents, cost_cents, status, order_date, delivery_date, created_at
order_notesid, order_id, content, created_at
invoicesid, order_id, client_id, amount_cents, status, issued_date, paid_date, notes, created_at
inquiriesid, name, email, phone, instagram, occasion, colors, message, status, created_at
settingskey, value

API Routes

MethodRouteAuthPurpose
POST/api/auth/loginPublicAdmin login โ€” returns JWT
GET/api/configPublicBusiness config for public site
GET/POST/api/clientsAdminList / create clients
GET/PUT/DELETE/api/clients/:idAdminGet / update / delete client
GET/POST/api/productsAdminList / create products
GET/PUT/DELETE/api/products/:idAdminGet / update / delete product
GET/POST/api/ordersAdminList / create orders
GET/PUT/DELETE/api/orders/:idAdminGet order (with notes) / update / delete
POST/api/notesAdminAdd note to an order
GET/POST/api/invoicesAdminList / create invoices
GET/PUT/DELETE/api/invoices/:idAdminGet / update / delete invoice
GET/POST/api/inquiriesMixedGET admin, POST public form submission
GET/PUT/DELETE/api/inquiries/:idAdminGet / update status / delete inquiry
GET/api/reports/summaryAdminRevenue/cost/profit summary; ?period=week|month|quarter|all
GET/PUT/api/settingsMixedGET public, PUT admin
POST/api/admin/passwordAdminChange admin password

File Structure (repo root)

bloomify-portal/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/        # Shared UI components
โ”‚   โ”œโ”€โ”€ pages/
โ”‚   โ”‚   โ”œโ”€โ”€ public/        # Public-facing pages (Home, Products, Inquiry)
โ”‚   โ”‚   โ””โ”€โ”€ admin/         # Admin portal pages (Dashboard, Orders, โ€ฆ)
โ”‚   โ”œโ”€โ”€ lib/               # API client, auth helpers
โ”‚   โ””โ”€โ”€ main.tsx
โ”œโ”€โ”€ worker/
โ”‚   โ”œโ”€โ”€ index.ts           # Cloudflare Worker entry
โ”‚   โ”œโ”€โ”€ routes/            # Route handlers per resource
โ”‚   โ”œโ”€โ”€ db/
โ”‚   โ”‚   โ””โ”€โ”€ schema.sql     # D1 migrations
โ”‚   โ””โ”€โ”€ auth.ts            # JWT auth middleware
โ”œโ”€โ”€ wrangler.toml
โ”œโ”€โ”€ vite.config.ts
โ””โ”€โ”€ package.json