How nhathuy157/student_app works
Project Type and Purpose
• This is a full-stack, cross-platform Flutter application (“student_app”) targeting mobile (Android, iOS), desktop (Windows, macOS, Linux) and web.
• Purpose: a multi-feature student portal combining hotel search/booking, job listings, campus mapping, in-app shop, and user authentication—backed by Firebase services.
File Structure
• Top-level “android”, “ios”, “web”, “windows”, “macos”, “linux” folders: Flutter build targets.
• “lib/” directory: core Flutter code, subdivided into:
• config (routes, themes, strings)
• constants (app-wide constants)
• controller (state management/controllers)
• model (data classes modeling hotel, job, map, shop, user, etc.)
• modules (UI screens and widgets by feature: home, hotel, job, map, shop, admin, auth)
• service (service layer handling authentication, Firebase CRUD, local JSON, fake data)
• widgets (shared stateless/stateful components)
• “assets/”: static JSON data, fonts, images partitioned by feature.
• “firebase/”: backend configuration for Firestore, Realtime Database, Storage rules, Cloud Functions.
• “pubspec.yaml/lock”: dependency declarations.
README
• A default Flutter README; no architecture details. We’ll infer architecture from file structure and common Flutter + Firebase patterns.
a. Main Components
• Flutter Frontend
• UI Modules (screens & widgets by feature)
• State Controllers (GetX/BLoC/MVVM – here likely GetX given “controller” naming)
• Models (hotel, job, map, shop, user, etc.)
• Service Layer (auth_service, action services, JSON manager)
• Local Assets (JSON, images, fonts)
• Backend Services (Firebase)
• Authentication (Firebase Auth)
• Firestore (real-time data storage for jobs, hotels, shop listings)
• Realtime Database (if used—check database.rules.json)
• Cloud Storage (images, map assets)
• Cloud Functions (server-side logic in firebase/functions)
• External Services
• Google Maps API (for map rendering, directions)
• Optional third-party job/hotel APIs if extended later
b. Relationships and Interactions
• UI → Controller: user gestures trigger controller methods
• Controller → Service Layer: controllers call auth_service, action services, JSON manager
• Service Layer → Firebase SDK: service invokes Firebase Auth, Firestore, Realtime DB, Cloud Storage, or local JSON
• Service Layer → Cloud Functions: for complex backend operations (e.g., data aggregation)
• Flutter Frontend → Google Maps SDK: map widgets import and display tiles/directions
• Firebase → Cloud Functions: triggered by database writes or HTTP calls
c. Architectural Patterns / Design Principles
• Separation of Concerns: UI layer (modules/widgets) vs. business logic (controllers) vs. data access (services)
• MVVM-like or GetX pattern: controllers manage state, models encapsulate data, views bind to controllers
• Feature-based modularization: each major feature resides in its own module folder
• Backend as a Service (BaaS): Firebase handles auth, data, storage, functions
d. Key Technologies
• Flutter & Dart
• Firebase SDKs (auth, firestore, database, storage, functions)
• Google Maps Flutter plugin
• JSON local assets for offline/fallback data
• Cloud Functions (Node.js / JavaScript)
Detailed Breakdown of Essential Architectural Elements
• Authentication Flow: Sign-In page → AuthController → AuthService → Firebase Auth → returns AuthUser → Controller updates UI.
• Data Flow for Feature (e.g., Job Listings): JobPage UI → JobController → JobActionService → Firestore/jobs → returns List<JobModel> → UI renders via JobWidget.
• Map Feature: MapPage → MapController → BuildingAction, RoomAction → local JSON / Firestore → Google Maps SDK for rendering.
• Shop Feature: ShopPage → ShopController → ProductActionService → Firestore/shop_products → Cloud Storage for product images.
• Admin Actions: Admin UI → AdminController → Cloud Functions / Firestore writes.
Summary
• Feature-specific components together to improve readability.
• Platform-specific builds (Android / iOS / web runners) if the deployment pipeline is relevant.