Device-as-a-Service (DaaS) rental platform for Bangladesh: rent laptops, phones, cameras, and consoles on monthly terms with bKash tokenized billing and AI e-KYC (NID OCR + face match).
| Layer | Tech | Location |
|---|---|---|
| Client | Flutter (Android primary, web optional) | app/ |
| Database & payments | Supabase Postgres + Edge Functions | Cloud (awaken project) |
| KYC gateway | FastAPI JWT proxy | Vercel (kycservice.vercel.app) |
| KYC ML engine | EasyOCR + DeepFace | Local PC (:8000) via ngrok |
GadgetChai/
├── app/ # Flutter client (Android + optional web)
├── kyc_service/ # ML worker (main.py) + Vercel gateway (api/gateway.py)
├── supabase/
│ ├── migrations/ # Schema + RLS (run in order)
│ ├── functions/ # bkash-webhook, charge-rentals
│ └── seed.sql # Catalog / promos seed data
├── scripts/ # wire-production, sync-ngrok, health-check, seed
├── docs/ # Detailed production & auth guides
├── .env.example # Root secrets template (copy → .env)
└── package.json # Node automation scripts
Install before cloning:
| Tool | Version | Purpose |
|---|---|---|
| Flutter | Stable 3.22+ | Android app |
| Android Studio | Latest | SDK, emulator, device deploy |
| Node.js | 18+ | Seed, wire-production, health-check |
| Python | 3.11 (not 3.14) | KYC ML worker |
| ngrok | Free tier OK | Expose ML worker to Vercel |
| Supabase CLI | Optional | Migrations / function deploy |
Accounts you need access to:
- Supabase project
fsdfqcnjcjtdmdjshrvu(or your own fork) - Vercel project for
kyc_service(gateway already deployed atkycservice.vercel.app)
git clone <repo-url> GadgetChai
cd GadgetChai
npm install
cd app && flutter pub get && cd ..# Root — used by scripts, ML worker, wire-production
cp .env.example .env
# Flutter — injected at build time
cp app/.env.example app/.envEdit both files with your Supabase URL and anon/publishable keys from Dashboard → Settings → API.
Add to root .env (not committed):
SUPABASE_SERVICE_ROLE_KEY— fornpm run seedand edge wiringNGROK_API_KEY— from ngrok dashboardCRON_SECRET—openssl rand -hex 32(protects charge-rentals cron)
For Android, keep CLIENT_APP_URL=gadgetchai:// in both .env and app/.env.
Run migrations in filename order in the SQL Editor:
supabase/migrations/20260706120000_gadget_chai_schema.sqlsupabase/migrations/20260707120000_security_hardening.sqlsupabase/migrations/20260707130000_charge_rentals_cron.sqlsupabase/migrations/20260707140000_cron_settings_table.sqlsupabase/migrations/20260707150000_service_role_grants.sqlsupabase/migrations/20260707160000_fix_is_admin_rls_execute.sql
Then seed catalog data:
npm run seed(setup-all.sql is a legacy one-file bundle; prefer the ordered migrations above.)
Configure the dashboard once — full checklist in docs/SUPABASE_AUTH_SETUP.md:
- Enable Email provider, Confirm email ON
- Redirect URLs:
gadgetchai://**(andhttp://localhost:3000/**for web) - Disable phone OTP for now
- Enable leaked-password protection
From repo root (requires SUPABASE_SERVICE_ROLE_KEY in .env):
npm run wire-productionThis syncs bKash sandbox credentials, CLIENT_APP_URL, KYC URLs, and cron secret to Supabase Edge Function secrets and Vercel.
Terminal 1 — ML worker (first time: see KYC setup below)
scripts\start-ml-worker.batTerminal 2 — ngrok (after ML worker is up)
scripts\start-ngrok.batTerminal 3 — sync ngrok URL to Vercel (run after every ngrok restart)
npm run sync-ngrok -- --deployTerminal 4 — Flutter
cd app
flutter run --dart-define-from-file=.envConnect a physical device or an emulator with camera support.
More Android details: app/README.md
cd app
flutter run -d chrome --web-port 3000 \
--dart-define-from-file=.env \
--dart-define=CLIENT_APP_URL=http://localhost:3000The Flutter app calls the Vercel gateway (KYC_SERVICE_URL). The gateway validates the Supabase JWT and proxies to your local ML worker via ML_WORKER_URL (ngrok public URL).
flowchart LR
App[Flutter app] --> Gateway[kycservice.vercel.app]
Gateway --> Ngrok[ngrok tunnel]
Ngrok --> ML[main.py :8000]
ML --> Supabase[(Supabase Storage + DB)]
cd kyc_service
python3.11 -m venv .venv
# Windows
.\.venv\Scripts\pip install -r requirements.txt
.\.venv\Scripts\pip install tf-keras "websockets>=13,<16" "supabase>=2.10"Root .env must include SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, SUPABASE_ANON_KEY, and KYC_ALLOW_MOCK=false.
Start the worker:
# From repo root
scripts\start-ml-worker.batHealth check: http://127.0.0.1:8000/health
- Start ML worker on port
8000 - Run
scripts\start-ngrok.bat(orngrok http 8000) - Run
npm run sync-ngrok -- --deployto updateML_WORKER_URLon Vercel
Full KYC docs: kyc_service/README.md and docs/PRODUCTION_SETUP.md
Note: EasyOCR + DeepFace are large (~2–7 GB). First verification request downloads models. Use
KYC_ALLOW_MOCK=trueonly for UI testing without ML.
Sandbox credentials are in .env.example. Test wallet: 01770618575 (PIN 12121, OTP 123456).
Flow: agreement (mode 0000) → initial payment (mode 0001) → redirect to gadgetchai:///checkout/status.
Details: docs/PRODUCTION_SETUP.md
# All services (KYC gateway, ML/ngrok, optional web, charge-rentals)
npm run health-check
# Static analysis
cd app && flutter analyze| Script | Description |
|---|---|
npm run seed |
Load catalog/promos via service role |
npm run wire-production |
Push secrets to Supabase + Vercel |
npm run sync-ngrok |
Read ngrok API → update ML_WORKER_URL |
npm run sync-ngrok -- --deploy |
Also redeploy kyc_service to Vercel |
npm run health-check |
Smoke-test endpoints |
npm run charge-rentals |
Manually invoke recurring billing edge fn |
| Doc | Contents |
|---|---|
| docs/PRODUCTION_SETUP.md | Full sandbox/production wiring |
| docs/SUPABASE_AUTH_SETUP.md | Email auth dashboard steps |
| docs/PRODUCTION_WIRING.md | Secret sync checklist |
| docs/PHASE_C_PRODUCTION.md | Live bKash, VPS ML, go-live |
| app/README.md | Android deep links, permissions |
| kyc_service/README.md | KYC API reference |
- Never commit
.envorapp/.env(use.env.exampletemplates). - Rotate any keys that were ever committed or shared in chat.
SUPABASE_SERVICE_ROLE_KEYis server-side only (scripts, ML worker, edge functions).
When you have a bKash merchant account and a VPS for the ML worker, follow docs/PHASE_C_PRODUCTION.md.