How abhisar-else/4thsem_project works
1. Repository shape
- This repo is documented as a two-tier product: a Flutter mobile client plus a Node.js/Express backend.
- The actual file tree shown only contains README.md and .gitignore, so the architecture below is based on the README’s intended design rather than implemented code.
2. Primary clients
- The main user-facing component is the mobile app for Android/iOS field workers.
- A second user role, admin, manages surveys, assigns work, and reviews responses through the same system, likely via an admin screen or dashboard in the Flutter app.
3. Offline-first edge layer
- The mobile app is designed to work without connectivity.
- Survey definitions are downloaded from the backend, then response data is stored locally in SQLite on the device until sync is possible.
- This local database is the critical boundary between the UI and unreliable network conditions.
4. Sync and network boundary
- The app uses network detection (connectivity_plus per README) to decide when to push queued submissions.
- Sync is asynchronous and automatic: collected responses remain local until the app detects internet, then they are sent to the server.
- This makes the mobile client the “edge collector” and the backend the “system of record.”
5. Backend service
- The server is a REST API built with Node.js + Express.
- It exposes endpoints for authentication, survey retrieval/creation, response submission, and export.
- This backend is the integration boundary for the mobile app and any third-party consumers.
6. Identity and access control
- The architecture uses JWT-based authentication.
- Role-based access separates admin capabilities from field_worker capabilities.
- Middleware in the backend likely enforces authorization on survey management and response reporting endpoints.
7. Core domain data flow
- Admin creates surveys and questions → backend persists survey metadata.
- Field workers fetch assigned surveys → mobile app renders forms.
- Workers submit answers, GPS coordinates, and optionally images → stored locally first, then posted to /api/responses.
- The backend stores central response records and makes them available for dashboard/reporting.
8. Data storage layers
- SQLite is the device-level offline store.
- The central database is described inconsistently in the README: the tech stack says MySQL, while the schema and .env examples reference PostgreSQL (DB_PORT=5432, JSONB, SERIAL).
- For diagramming, treat this as a single central warehouse database, but note the implementation ambiguity.
9. Data warehouse responsibilities
- The central database holds users, surveys, and responses.
- Response records include metadata such as timestamps, device ID, and GPS coordinates.
- The warehouse is intended to support admin analytics, reporting, and CSV/Excel exports.
10. Mobile app internal boundaries
- The README’s Flutter structure suggests these logical layers:
- screens for UI,
- services for API/sync operations,
- database for SQLite access,
- models for domain objects,
- config for backend URL and constants.
- This indicates a clean separation between presentation, local persistence, and remote communication.
11. Location and form enrichment
- The app can capture GPS data through geolocator.
- Survey answers may include text, dropdowns, images, and positional metadata.
- These enrichments are attached to each response before storage/sync.
12. Operational concerns
- The system expects field devices to be intermittently connected and possibly multiple submissions may arrive late or duplicated.
- The backend design includes conflict resolution for duplicate submissions and timestamps for reconciliation.
- Sync status is an important user-visible state on the mobile side.
13. External interface surface
- The public API surface is small and explicit: login, surveys, responses, and export.
- That makes the backend the central integration point for future clients such as reporting tools or third-party data consumers.
14. Key architecture takeaway
- This is an offline-first distributed data collection system with a mobile edge, central REST API, and warehouse database.
- The most important diagram boundaries are: Flutter app ↔ local SQLite, Flutter app ↔ Node/Express API, and API ↔ central DB.
Components 16
Flutter app
Offline-first mobile client for field workers and admins.
- Screens · Field worker and admin interfaces for surveys, responses, and sync status.
- Services · API calls, sync orchestration, connectivity checks, and submission queueing.
- SQLite store · On-device persistence for surveys, responses, and queued uploads.
- Models · Survey, response, user, and sync state objects used by the app.
- Config · Backend URL, constants, and environment-specific settings.
- GPS capture · Geolocation enrichment attached to collected responses.
- Network check · Detects internet availability before pushing queued submissions.
Node backend
REST API, auth, survey handling, response ingestion, and exports.
- REST API · Public HTTP boundary for authentication, surveys, responses, and exports.
- Auth guard · Validates tokens and enforces admin versus field_worker permissions.
- Survey API · Creates, assigns, and retrieves survey definitions and questions.
- Response API · Accepts submitted answers, metadata, and duplicate-aware response writes.
- Export API · Produces CSV or Excel outputs for admin reporting and analysis.
- Admin flows · Survey management, assignment, and response review behavior exposed to admins.
Data stores
Local and central persistence layers.
- Warehouse DB · System of record for users, surveys, responses, and analytics data.
- Queued sync · Local-first submission path that stores data until connectivity returns.
- Analytics data · Centralized response history used for admin dashboards and exports.
Connections 21
- Screens → Services: uses · Screens request survey loading, submission, and sync actions.
- Screens → SQLite store: reads/writes · UI reflects locally stored surveys, responses, and sync state.
- Services → Config: reads · Service layer uses configured backend settings.
- Services → Network check: checks · Connectivity detection gates background submission.
- Services → GPS capture: enriches · Collected responses may include location metadata.
- Services → Queued sync: queues · Responses are staged locally before network submission.
- Queued sync → SQLite store: persists · Offline queue and cached survey data live in SQLite.
- Queued sync → REST API: syncs · Queued submissions are pushed when connectivity is available.
- Services → REST API: calls · Mobile app fetches surveys and posts responses through REST.
- Models → Screens: shapes · Domain objects feed forms, lists, and sync status display.
- REST API → Auth guard: protects · Endpoints are guarded by token validation and role checks.
- Auth guard → Survey API: allows · Authorized users can manage survey definitions and assignments.
- Auth guard → Response API: allows · Authorized users can submit and review responses.
- Auth guard → Export API: allows · Admin-only access for reporting and exports.
- Survey API → Warehouse DB: stores · Survey metadata and questions are persisted centrally.
- Response API → Warehouse DB: stores · Submitted response records are written to the warehouse database.
- Response API → Analytics data: feeds · Response history supports reporting and analytics views.
- Export API → Analytics data: reads · Exports are generated from centralized reporting data.
- Admin flows → Survey API: uses · Admin operations create and assign surveys.
- Admin flows → Response API: reviews · Admin workflows inspect received responses.
- Warehouse DB → Analytics data: supports · Core warehouse data is reused for analytics and exports.