How sabbirahmedfahim/campusride works
1. Overall shape
CampusRide is a Flutter client application with a Supabase-backed backend. The repo is mostly the cross-platform app (lib/) plus generated platform hosts for Android, iOS, web, macOS, Linux, and Windows. In practice, the architecture is centered on the Flutter client talking directly to Supabase services.
2. Client presentation layer
The UI is organized in lib/pages/ as screen-level routes: authentication, dashboard, ride offer/request flows, ride detail/history, leaderboard, chat inbox/chat room, notifications, profile, and a separate admin shell with admin screens. home_shell.dart and admin_shell.dart define the two main navigation containers, with the user-facing app using persistent bottom tabs.
3. State management boundary
lib/providers/ contains the app’s runtime state layer, using Provider to coordinate auth, rides, chat, notifications, leaderboard/admin state, and refresh logic. Screens read from providers; providers in turn call the API layer and subscribe to real-time updates. This is the main boundary between UI and backend access.
4. Backend/API access layer
lib/api/ is the repository’s service boundary. It groups all Supabase operations by domain: auth, rides, chat, notifications, leaderboard, and admin. This separation reflects the backend data model and keeps screen code from calling Supabase directly.
5. Data model layer
lib/entities/ defines the app’s core domain objects: users, rides, ride requests, conversations, chat messages, and notifications. These models sit between the API responses and UI widgets, and they make the repository’s domain boundaries explicit for diagramming.
6. Supabase as the system backend
The backend is not a custom server; it is Supabase Postgres plus Supabase Auth and Realtime. lib/config/supabase_config.dart holds the client configuration. The README indicates that the database also contains triggers, row-level security, scheduled jobs, and leaderboard logic, so a lot of business behavior lives in Postgres rather than in Dart.
7. Authentication and access control flow
Users register and log in through Supabase Auth, with university-email restriction enforced both client-side and in the database. The app supports email/password plus OTP verification on signup. After sign-in, the auth provider determines whether the user is banned or is an admin and routes them either into the main shell or the admin shell.
8. Ride and request workflow
Ride offers and ride requests are created from dedicated screens, stored in Supabase, and rendered in the dashboard and history views. The ride provider manages lifecycle actions such as posting, booking, canceling, and refreshing lists. The README shows that ride state transitions and cooldown/expiry behavior are driven by database rules and cron jobs, not just client logic.
9. Real-time collaboration features
Ride feeds, request summaries, notifications, and chat all update through Supabase Realtime subscriptions. The app therefore has a push-like data flow: database changes trigger updates, which providers receive and fan out into screen refreshes. This is the key mechanism behind the “live” dashboard, inboxes, and chat.
10. Chat and notification subsystems
Chat is a separate domain with conversation and message entities, an inbox screen, and a one-to-one chat screen. Notifications have their own inbox and unread-count behavior. Both are event-driven features backed by database records and synced to the client via realtime updates.
11. Leaderboard and scoring
The leaderboard is a read-optimized view of users ranked by score. The app has a dedicated leaderboard screen and row widget, while the actual score changes are triggered by ride lifecycle events in the database. This keeps scoring logic on the backend and presentation logic on the client.
12. Admin boundary
Admin functionality is isolated in its own shell and screens for dashboard metrics, user management, rides, and requests. Access is gated by is_admin, and the README notes that admin policies are enforced in Supabase/Postgres as well as in the UI. This is a separate trust boundary from the standard student workflow.
13. Supporting UI components and assets
lib/widgets/ contains reusable visual components such as ride cards, request cards, leaderboard rows, conversation tiles, and map thumbnails. assets/ provides branding and app icons, while the docs/ folder contains the project documentation and database setup material. These are supportive, not core runtime subsystems.
14. External services and device capabilities
The app depends on device GPS via geolocator for pickup location capture, and it uses Google Maps only as a read-only external preview/open action rather than embedding a full map workflow. The architecture intentionally avoids manual map pinning and relies on the device location as an input constraint.
Main entry points: pages Screens · supabase_config.dart Supabase config · entities Domain models · main.dart Main
Components 19
App entry
Flutter entrypoint and navigation roots.
- Main · Bootstraps Flutter and wires app services.
lib/main.dart
Client layers
UI, state, domain models, and reusable widgets.
- Home shell · Primary user navigation container with tabs.
lib/pages/home_shell.dart - Admin shell · Separate navigation container for admin workflows.
lib/pages/admin_shell.dart - Auth state · Tracks sign-in, role, and access routing.
lib/providers/auth_provider.dart - Ride state · Coordinates ride posting, booking, refresh, and lifecycle updates.
lib/providers/ride_provider.dart - Chat state · Manages conversations, messages, and chat refresh.
lib/providers/chat_provider.dart - Notification state · Handles notification inbox and unread counts.
lib/providers/notification_provider.dart - Admin state · Supports admin metrics and moderation workflows.
lib/providers/admin_provider.dart - Domain models · Users, rides, requests, conversations, messages, and notifications.
lib/entities - Screens · Auth, dashboard, ride, chat, notification, profile, and admin screens.
lib/pages - Shared widgets · Reusable cards, rows, tiles, and map thumbnail UI.
lib/widgets
Supabase backend
Supabase configuration and server-side data boundaries.
- Auth API · Supabase auth operations and access checks.
lib/api/auth_api.dart - Ride API · Ride and ride-request data access.
lib/api/ride_api.dart - Chat API · Conversation and message persistence.
lib/api/chat_api.dart - Notification API · Notification persistence and read-state updates.
lib/api/notification_api.dart - Leaderboard API · Score and ranking reads used by the leaderboard view.
lib/api/leaderboard_api.dart - Admin API · Admin-facing user, ride, and request operations.
lib/api/admin_api.dart - Supabase config · Client initialization and backend connection settings.
lib/config/supabase_config.dart
Platform hosts
Generated native and desktop/web wrappers.
- Native hosts · Android, iOS, macOS, Linux, Windows, and web launchers.
Connections 31
- Main → Supabase config: initializes · App startup depends on Supabase client setup.
- Main → Auth state: wires · Root app provides auth state for routing.
- Main → Home shell: opens · Authenticated users enter the main shell.
- Main → Admin shell: opens · Admin users can be routed to the admin shell.
- Auth state → Auth API: calls · Auth state delegates sign-in and role checks.
- Auth state → Home shell: routes to · Controls entry into the student experience.
- Auth state → Admin shell: routes to · Controls entry into the admin experience.
- Ride state → Ride API: calls · Ride state reads and mutates ride data.
- Chat state → Chat API: calls · Chat state fetches and syncs conversations.
- Notification state → Notification API: calls · Notification state loads and updates inbox items.
- Admin state → Admin API: calls · Admin state drives moderation and reporting actions.
- Screens → Home shell: contains · User-facing screens are hosted by the main shell.
- Screens → Admin shell: contains · Admin screens are hosted by the admin shell.
- Screens → Auth state: reads · Screens consume auth state for routing and gating.
- Screens → Ride state: reads · Ride screens react to ride state.
- Screens → Chat state: reads · Chat screens react to conversation state.
- Screens → Notification state: reads · Notification screens react to inbox state.
- Screens → Admin state: reads · Admin screens consume admin state.
- Ride API → Domain models: maps to · Ride responses are shaped into domain models.
- Chat API → Domain models: maps to · Conversation and message data use shared models.
- Notification API → Domain models: maps to · Notification data uses shared models.
- Leaderboard API → Domain models: maps to · Leaderboard reads are projected from user and ride models.
- Admin API → Domain models: maps to · Admin operations work over the core domain objects.
- Shared widgets → Domain models: renders · Shared UI components present core domain data.
- Shared widgets → Screens: used by · Screens compose reusable visual pieces.
- Supabase config → Ride API: backs · All domain APIs rely on the configured Supabase client.
- Supabase config → Chat API: backs · Chat access is powered by the same backend client.
- Supabase config → Notification API: backs · Notification access is powered by the same backend client.
- Supabase config → Leaderboard API: backs · Leaderboard access is powered by the same backend client.
- Supabase config → Admin API: backs · Admin access is powered by the same backend client.
- Native hosts → Main: launches · Platform wrappers start the Flutter app.