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 timezonewarehousesβ Warehouse locations per countrystaff_groupsβ Staff groupings per warehouse (Inbound/Outbound/Value-added)employeesβ Employee master datausersβ Login credentials and roles
Configurationβ
pph_threshold_configβ PPH performance level thresholdsviolation_type_configβ Violation type definitions with penalty pointsviolation_level_configβ Penalty accumulation β severity mappingbonus_type_configβ Bonus categoriesskill_coursesβ Training courses for recoverycourse_violation_linksβ Auto-assignment of courses to violation typeswork_hour_standard_configβ Standard hours per countrybenefit_rule_configβ Benefit eligibility conditionscompensation_support_configβ Company support percentagespph_multiplier_configβ PPH level multipliers for bonuses
Operationalβ
pph_daily_rawβ Daily PPH data from WMSviolation_recordsβ Individual violation instancesbonus_recordsβ Bonus point recordsrecovery_recordsβ Recovery/training recordsemployee_period_scoresβ Aggregated period scoresapproval_requestsβ Approval workflow queueconfig_audit_logβ Audit trail for config changes