How lahsineyounes/collecteterrain works
Project type and purpose
• This is a native Android mobile application (“CollecteTerrainApp”) targeting two user roles: field representatives and multi‐site managers.
• Purpose: allow field reps to collect geolocated data (photos, amounts, comments) and sync it in real time; allow managers to monitor teams on an embedded Google Map dashboard.
File structure
• Top‐level “app” module (Gradle Kotlin DSL) containing:
• src/main/java/com/example/collecteterrainapp
– Activities & Fragments divided by feature: auth (LoginFragment, RegisterFragment), shared (ProfileFragment), representative (AddCollecteFragment, CollecteFragment, etc.), manager (ManagerDashboardActivity, MapFragment, TeamStatsFragment, RepresentativeDetailFragment), plus MainActivity which hosts the Navigation component.
– adapter packages under both representative and manager.
– services (FirebaseService, LocationService)
– database helper (DatabaseHelper for SQLite local storage)
– models (Collection, Site, User)
– utils (AuthUtils, SessionManager, DateUtils)
• Navigation graphs in res/navigation
• Resource hierarchies for layouts, drawables, menus
• Build & deployment files: Gradle wrapper, build.gradle.kts, proguard, Google services JSON (Firebase), backup/data extraction XMLs.
• Tests: instrumented tests under androidTest, unit tests under test.
README for insights
• Real‐time sync via Firebase (or fallback to SQLite).
• Google Maps integration for live tracking.
• Roles: Rep vs Manager, each with tailored dashboard.
• Mentions optional web-scraping with Jsoup (extensibility point but not core).
Main components & interactions (to include
A. Mobile App (Android APK)
1. UI Layer
• Activities & Fragments
• Login/Register
• Representative dashboard & collection forms
• Manager dashboard & map view / team stats
• Navigation Component (mobile_navigation.xml, manager_navigation.xml)
2. Service Layer
• AuthUtils & SessionManager (manages tokens/user sessions)
• LocationService (foreground service providing GPS updates)
• FirebaseService (wraps Firebase SDK calls: Realtime Database, Authentication, Cloud Storage for photos)
3. Data Layer
• SQLite via DatabaseHelper (local cache, offline mode)
• Data models (Collection, Site, User)
4. External Libraries
• Google Maps SDK
• Firebase SDK (Auth, Realtime Database, Cloud Storage)
• Jsoup (optional web-scraping extension)
B. Remote Backend & Cloud Services
• Firebase Authentication
• Firebase Realtime Database
• Firebase Cloud Storage
• (Optional) External Web Scraping Targets when implemented
C. External Dependencies
• Google Maps Platform (Map tiles, routing)
• Internet / mobile network
Relationships & data flow
• User interacts with UI → UI calls Service Layer
• Service Layer
• AuthUtils invokes Firebase Auth for login/register
• LocationService pushes GPS updates to UI & optionally to Firebase
• FirebaseService reads/writes models to Realtime Database & Cloud Storage
• Data Layer
• DatabaseHelper persists data locally for offline access
• Sync logic reconciles local SQLite with Firebase when network available
• Manager App Screens subscribe to Firebase real‐time updates to plot representative positions on the map
• Optional web-scraping module can fetch external data, feed into local DB or directly into Firebase via a background job
Architectural patterns & design principles
• Layered architecture: UI → Service → Data
• Single Responsibility: separate packages for auth, manager, representative, shared
• Offline-first with local SQLite caching and sync service
• Real-time communication via Firebase pub/sub model
• Android Navigation Graph for decoupled screen flows
Final focus
• Be comprehensive: capture every major package and service
• Both horizontal layering (UI → Services → Data) and vertical feature slices (Auth, Representative, Manager)
• Real-time sync and offline-cache paths are clearly differentiated