Skip to main content

System Architecture

Overview​

Boxme Levelling runs as a Cloudflare Workers edge application using the Hono framework. Static assets are served via CDN, and the backend connects to Supabase (PostgreSQL).

Architecture Diagram​

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Cloudflare Edge Network β”‚
β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Cloudflare Pages / Workers β”‚ β”‚
β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚
β”‚ β”‚ β”‚ Static Filesβ”‚ β”‚ Hono Backend (Worker) β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ /static/* β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ app.js β”‚ β”‚ /api/auth/* β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ styles.css β”‚ β”‚ /api/dashboard/* β”‚ β”‚ β”‚
β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ /api/employees/* β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ /api/violations/* β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ /api/recovery/* β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ /api/bonuses/* β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ /api/scores/* β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ /api/benefits/* β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ /api/config/* β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ /api/export/* β”‚ β”‚ β”‚
β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
β”‚ └──────────────────────────────────────┼───────────────── β”‚ β”‚
β”‚ β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Supabase (PG) β”‚ β”‚
β”‚ β”‚ PostgreSQL DB β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Request Flow​

Browser β†’ Cloudflare CDN β†’ Pages Worker (Hono)
↓
Route matching:
/api/* β†’ API handler β†’ Supabase DB
/* β†’ HTML shell (SPA)
/static/* β†’ Static files

Project Structure​

boxme_levelling/
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ index.tsx # Main entry, CORS, static, SPA shell
β”‚ β”œβ”€β”€ routes/
β”‚ β”‚ └── api.ts # All 80+ API routes
β”‚ └── types/
β”‚ └── index.ts # TypeScript Bindings type
β”œβ”€β”€ public/
β”‚ └── static/
β”‚ β”œβ”€β”€ app.js # SPA (~5,000 lines)
β”‚ β”œβ”€β”€ styles.css # Custom CSS
β”‚ └── swagger.yaml # OpenAPI spec
β”œβ”€β”€ migrations/
β”‚ β”œβ”€β”€ 0001_initial_schema.sql
β”‚ β”œβ”€β”€ 0002_seed_data.sql
β”‚ β”œβ”€β”€ 0003_policy_update_2026.sql
β”‚ β”œβ”€β”€ 0004_recovery_enhanced.sql
β”‚ └── 0005_skill_courses.sql
β”œβ”€β”€ docs-site/ # ← This documentation site
β”œβ”€β”€ wrangler.jsonc
β”œβ”€β”€ vite.config.ts
└── package.json

Database Tables​

Organization​

  • countries β€” Country registry with timezone
  • warehouses β€” Warehouse locations per country
  • staff_groups β€” Staff groupings per warehouse (Inbound/Outbound/Value-added)
  • employees β€” Employee master data
  • users β€” Login credentials and roles

Configuration​

  • pph_threshold_config β€” PPH performance level thresholds
  • violation_type_config β€” Violation type definitions with penalty points
  • violation_level_config β€” Penalty accumulation β†’ severity mapping
  • bonus_type_config β€” Bonus categories
  • skill_courses β€” Training courses for recovery
  • course_violation_links β€” Auto-assignment of courses to violation types
  • work_hour_standard_config β€” Standard hours per country
  • benefit_rule_config β€” Benefit eligibility conditions
  • compensation_support_config β€” Company support percentages
  • pph_multiplier_config β€” PPH level multipliers for bonuses

Operational​

  • pph_daily_raw β€” Daily PPH data from WMS
  • violation_records β€” Individual violation instances
  • bonus_records β€” Bonus point records
  • recovery_records β€” Recovery/training records
  • employee_period_scores β€” Aggregated period scores
  • approval_requests β€” Approval workflow queue
  • config_audit_log β€” Audit trail for config changes