Spaces:
Sleeping
Sleeping
Flutter Integration Guide
Goal
Connect Flutter app to Ain El Aql backend to produce a complete parking product:
- camera-based ANPR detection
- parking session and payment lifecycle
- occupancy and location-aware pricing dashboards
Responsibility Split
Backend + AI team (already implemented)
- AI inference pipeline
- Session/event persistence in Supabase
- Dynamic pricing and capacity logic
- Gate decision logic
- Payment endpoints (Paymob + manual cash)
- Role-aware history/feed APIs
Flutter team
- Backend auth screens and token management
- API client layer and request retries
- UI for user/admin/security experiences
- Detection screens and result rendering
- Payment/gate operation UI flow
- Dashboard and reporting screens
Integration Steps
- Configure API base URL in Flutter.
- Register/Login through backend auth endpoints and keep access token.
- Send token as
Authorization: Bearer ...to protected endpoints. - Use
POST /predictfor main camera action. - Use
/parking/locationsand/parking/occupancyfor location cards and dashboard. - Use feeds/history endpoints for timeline and operational views.
Current Cloud Base URL
https://pant0x-ealpr-ocr.hf.space
Sanity checks:
GET /GET /healthGET /supabase/health
Current deployment mode is SUPABASE_ENFORCE_AUTH=false to unblock integration.
Before production launch, switch to true and ensure token headers are sent on protected calls.
Recommended Flutter Screens
- Auth (login/register/reset)
- Home/scan screen
- Detection result screen
- Inside/entered/left monitoring screens
- Parking history screen
- Location pricing + occupancy screen
- Payment and gate validation screen
- Admin/security operations panel
Request/Response Mapping
POST /auth/register
Flutter sends:
first_name(recommended)last_name(recommended)username(required)phone(required)password(required)email(optional)nid(optional)- optional vehicle payload:
plate_letters_ar,plate_numbers_arplate_letters_en,plate_numbers_encar_model,car_color
Flutter reads:
user.roleanduser.is_staffsession.access_tokenvehicle(if provided during registration)
POST /auth/login
Flutter sends:
identifier(username OR phone OR email OR nid)password
Flutter reads:
user.roleanduser.is_staffsession.access_tokensession.refresh_token
POST /predict
Flutter sends:
- image file
- event_type (
entry/exit/ocr_scan) - parking_location (named value like
OPERA)
Flutter reads:
plate_info/platepricingpayment_statusgate_decisionuser_page.split_image_base64admin_page.annotated_image_base64
Occupancy dashboards
Use:
GET /parking/locationsGET /parking/occupancy
Render:
garage.display(X/total)- each location pricing mode/rates
- each location occupancy display and left capacity
Role-based UI Recommendations
user- own history/feeds
- pricing and availability
admin- all-user operations, analytics, payment controls
security- gate operations and live occupancy monitoring
Role source is backend user.role from the profiles table.
End-to-End Product Pipeline
- Driver arrives and selects location in app.
- Camera scan sends image to
/predictwithevent_type=entry. - Backend detects plate, creates/updates session, calculates pricing context.
- Driver views status and fee preview.
- On exit, app sends
/predictwithevent_type=exit. - Backend validates payment state and returns gate decision.
- Staff can use payment endpoints when required.
- Dashboards reflect occupancy in near-real-time from open sessions.
Launch Checklist
- Cloud host
/,/health, and/supabase/healthpass. - Supabase tables/buckets configured and secure.
- Auth enforced in production (
SUPABASE_ENFORCE_AUTH=true). - Pricing/capacity env values loaded in deployment.
- Flutter role routing and token flow tested.
- Entry/exit/manual payment QA completed.
- Security key rotation completed for exposed secrets.