How nhat-tien/bus_online_new works
Project type and purpose
• This is a multi‐platform Flutter client app named “bus_online.”
• It targets Android, iOS, web, Linux, macOS and Windows.
• Its goal is a bus-booking/tracking application with registration, login, route lookup, ticket management, scanner, and driver/customer panels.
High-level structure from file tree
• Platform folders (android/, ios/, web/, linux/, macos/, windows/) each contain the native embedding and build configuration.
• lib/ holds the Dart code, subdivided into:
• components/ – reusable UI widgets
• pages/ – screen widgets by feature
• controllers/ – state managers (business logic)
• services/ – API clients (auth, customer, driver, route)
• models/ – data classes transported to/from services
• storage/ – local persistence (user session)
• utils/ – formatting and helpers
• Supporting files: pubspec.yaml, migration.sql (DB schema?), CI in .github/workflows, analysis_options.yaml.
Architectural pattern
• Layered/MVVM (View → Controller/ViewModel → Service → External API).
• Componentized widget library for consistent UI.
• Controllers orchestrate calls to services and update Views; Services wrap HTTP/JSON to remote REST endpoints; Storage handles caching or token storage.
Main components
A. Platform Runners:
• Android (Gradle → MainActivity.kt)
• iOS (AppDelegate.swift)
• Web, Linux, macOS, Windows runners
B. Flutter Core:
1) UI Layer
– Widget Components (lib/components)
– Pages (lib/pages)
2) Controller Layer (lib/controllers)
3) Service Layer (lib/services)
4) Local Storage (lib/storage)
5) Utility Layer (lib/utils)
C. External Services/API:
– Auth API
– Customer API
– Driver API
– Route/Ticket API
Relationships and data flow
• UI Widgets ←→ Pages (compose widgets into screens)
• Pages ↔ Controllers (state and user events)
• Controllers ↔ Services (REST calls)
• Services ↔ External API endpoints (HTTP/JSON)
• Controllers ↔ Storage (read/write session or cached data)
• Utils are called by Controllers or UI for formatting/parsing
Important design principles
• Separation of concerns: UI vs business logic vs data access
• Reusability: place shared widgets in components/
• Scalability: isolate each service for potential micro-frontend splits