> ## Documentation Index
> Fetch the complete documentation index at: https://poolerz.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Storage Design

> The data storage design of Poolerz.

The figures below illustrate our **data storage design** for two primary collections: **Users** and **Carpools**. Since our system uses **MongoDB** instead of SQL, we adopted a **document-database model**, making it easier to structure and query our data efficiently. Each **box represents a document** with its respective attributes, while **arrows denote relationships** between documents.

### **Figures:**

* **Figure 2.1** - Data Storage Diagram
  <img src="https://mintcdn.com/poolerz/QJ_9o0D7RJnmN_4g/images/fig3.png?fit=max&auto=format&n=QJ_9o0D7RJnmN_4g&q=85&s=e03651d377eb4021769c7dd62015a104" alt="Data Storage Diagram" width="552" height="562" data-path="images/fig3.png" />
* **Figure 2.2** - User JSON Document
  <img src="https://mintcdn.com/poolerz/QJ_9o0D7RJnmN_4g/images/fig6.png?fit=max&auto=format&n=QJ_9o0D7RJnmN_4g&q=85&s=767c43ce3a945b71fe9779a37b55dddc" alt="User JSON Document" width="342" height="391" data-path="images/fig6.png" />
* **Figure 2.3** - Carpool JSON Document
  <img src="https://mintcdn.com/poolerz/QJ_9o0D7RJnmN_4g/images/fig7.png?fit=max&auto=format&n=QJ_9o0D7RJnmN_4g&q=85&s=0130feee199ce6ebcf00cc9a3de17922" alt="Carpool JSON Document" width="357" height="487" data-path="images/fig7.png" />
* **Figure 2.4** - User Carpool Data JSON Document
  <img src="https://mintcdn.com/poolerz/QJ_9o0D7RJnmN_4g/images/fig8.png?fit=max&auto=format&n=QJ_9o0D7RJnmN_4g&q=85&s=fb695946d5268cf365cf3c62e37db1df" alt="User Carpool Data JSON Document" width="493" height="549" data-path="images/fig8.png" />

## **Collections & Data Structure**

### **Users Collection**

The **User document** stores **profile-related and static information** about each user.

* Includes a **unique user ID**.
* Contains an **object with user details** such as:
  * **Children’s information**
  * **Location**
  * **Registration form completion status**
* **Editable attributes** include address changes and adding children to the profile.

### **Carpools Collection**

The **Carpool document** contains **all details related to a carpool organization**.

* Includes a **unique carpool ID**.
* Stores **metadata** such as:
  * **Carpool organization creator’s name & ID**
  * **Location & schedule (time/days)**
  * **List of members (user IDs stored in an array)**
* The **members array** is updated as users join the carpool.

### **User Carpool Data Collection**

The **User Carpool Data document** links a user to their associated carpools.

* Contains the **user ID and location**.
* Stores an **array of carpool objects**, each containing:
  * **Carpool ID**
  * **Rider information**
  * **Driving availability**
  * **Notes regarding the carpool**
* Updates dynamically when a user **joins or creates** a carpool.

***

# **Protocols & Security**

### **Data Exchange & Encryption**

* The application does **not handle file storage** but uses **JSON** for **data exchange** between the **client and server**.
* **MongoDB’s built-in encryption** ensures **secure storage** of sensitive information.
* All data exchange is secured using **HTTPS**, encrypting communication between users and the server.

### **User Authentication & Access Control**

* **Google OAuth 2.0** is used for authentication, leveraging **Google’s high-security infrastructure**.
* No **passwords** are stored in the application.
* User **email addresses and names** are **non-editable** to maintain integrity.
* **Location data** is only accessible to **authorized carpool members** and is not stored beyond its **necessary usage period**.

### **Role-Based Access Control (RBAC)**

* **Access to Personally Identifiable Information (PII)** is restricted using **RBAC**, ensuring that only **authorized users** can view their respective data.
* The **main PII stored** includes:
  * **Email addresses**
  * **Location details** (restricted visibility)
* The application **does not process or store financial information**, significantly reducing potential security vulnerabilities.

By implementing **MongoDB encryption, OAuth authentication, and HTTPS**, our system ensures **data integrity, privacy, and security** while maintaining **efficient and scalable storage**.
