Skip to content
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 33 additions & 6 deletions docs/source/diagrams.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,56 @@ The Diagrams are drawn using [draw.io](https://.wwww.draw.io). You can download
---

**Deployment Diagram:**
![Deployment Diagram](/_static/img/deployment_diagram.png)
![Deployment Diagram](_static/img/deployment_diagram.png)

---

**Proposed Data Structure Project Type 1 - Firebase:**
![Data Structure - Firebase](/_static/img/data_structure-firebase-1.svg)
![Data Structure - Firebase](_static/img/data_structure-firebase-1.svg)

---

**Proposed Data Structure Project Type 2 - Firebase:**
![Data Structure - Firebase](/_static/img/data_structure-firebase-2.svg)
![Data Structure - Firebase](_static/img/data_structure-firebase-2.svg)

---

**Database Scheme - Postgres:**
![Database Schema - Postgres](/_static/img/database_schema-postgres.png)
![Database Schema - Postgres](_static/img/database_schema-postgres.png)

---

**Entity Relationship Diagram - Postgres:**
![Entity Relationship Diagram- Postgres](/_static/img/entity_relationship_diagram-postgres.png)
![Entity Relationship Diagram- Postgres](_static/img/entity_relationship_diagram-postgres.png)

---

**Database Schema - Analytics:**
![Database Schema - Analytics](/_static/img/database_schema-analytics.png)
![Database Schema - Analytics](_static/img/database_schema-analytics.png)

---

**Mapping Sessions - Time Calculation**

The diagram below is a visual representation of how time is calculated in MapSwipe.

Step 1: User Mapping Session **sends data** to Firebase
- When a user completes a mapping session in the mobile/web app, the session payload (including start/end timestamps, user ID, session metadata, etc.) is sent in real time to Firebase.

Step 2: Cron job **fetches data** from the firebase
- Every 3 minutes, a cron job syncs data for any new session records and pulls them into the backend.

Step 3: Cron job **saves raw data** to Postgres database
- The cron job sends new session data to the Postgres database.

Step 4: Cron job **reads raw data** from Postgres database
- Another cron job reads the raw data from Postgres database.

Step 5: Cron job **saves aggregates** to Postgres database
- The cron job aggregates previous 24 hours data (end date - start date), sends back, and saves processed aggregated data to the Postgres database.

Step 6: Community dashboard **queries aggregate data** from Postgres database
- The Community dashboard pulls the processed data from the Postgres database and updates the dashbaord with up-to-date stats.


![MapSwipe Time Calculation](_static/img/mapswipe-time-calculation.png)
Loading