# rawanmohameedd/collecting-data architecture

> Architecture diagram of the GitHub repository rawanmohameedd/collecting-data, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rawanmohameedd/collecting-data
- Repository: https://github.com/rawanmohameedd/collecting-data

## Overview

##### Project type and purpose
- This is a full-stack, mobile data-collection application.
- Frontend: React Native app (Android + iOS).
- Backend: Node.js + Express server that receives Wi-Fi strength readings and persists them to CSV files.
- Purpose: collect labeled Wi-Fi RSSI data by room, to train an AI model for indoor localization.

##### File structure
- Top-level “Frontend” directory: React Native, native platform folders (android/, ios/), JavaScript entry points (App.js, index.js), utility modules (BSSIDs.js, netInfo.js), tests.
- Top-level “Backend” directory: Node.js service with index.js (Express app), package.json, data/ (raw CSV), dataParsers/ (post-processing scripts), append.js (appends new data points).
- Project root also contains Postman collection for testing and top-level package.json (probably workspace or root deps).

##### README
- Describes exactly: the mobile app reads Wi-Fi strength every 2s, sends an object {timestamp, BSSID, RSSI, roomId…} to the Express server; server appends to CSV.
- Data used later for ML model training.

##### Main components and their interactions
a. Mobile Frontend
- UI Layer: “Start”/“Stop” buttons in App.js
- Wi-Fi Scanner Module: netInfo.js + BSSIDs.js (identifies current BSSID and RSSI)
- Networking Layer: fetch or axios POST → Express endpoint
b. Backend Server
- API Layer: index.js defines POST /append or similar route
- Business Logic: append.js enriches incoming payload (timestamp, room info)
- Data Parsers: dataParsers/*.js (post-processing per room)
- Storage Layer: data/*.csv (room0.csv, room1.csv, out.csv…)
c. External Tools
- Postman collection for manual or automated testing

##### Architectural patterns and design principles
- Client-Server (REST) architecture
- Single-responsibility backend modules: routers, append logic, per-room parsers
- Separation of concerns: UI vs. data collection vs. networking
- File-based persistence (CSV) instead of a database for simplicity

##### Final advice
- Be exhaustive: break Backend into Router, Append Service, Parsers, Storage
- Clearly demarcate the 2s sampling interval loop in the mobile module
- With relevant file paths or entry-point filenames (e.g., App.js, index.js) for traceability

## Diagram (Mermaid)

```mermaid
graph TB
    %% Mobile App Layer
    subgraph "Mobile App (React Native)"
        direction TB
        Entry["Entry Point (index.js)"]:::mobile
        UI["UI Layer (App.js)"]:::mobile
        Scanner["Wi-Fi Scanner (netInfo.js)"]:::mobile
        BSSID["BSSID Utils (BSSIDs.js)"]:::mobile
        APIClient["API Client"]:::mobile
        Android["Android Project"]:::mobile
        iOS["iOS Project"]:::mobile
        Config["Config & Build Scripts"]:::mobile
    end

    %% Backend Server Layer
    subgraph "Backend Server (Node.js + Express)"
        direction TB
        Router["HTTP Router (index.js)"]:::server
        Append["Append Service (append.js)"]:::server
        subgraph "Data Parsers"
            direction TB
            Parser1["room1.js"]:::server
            Parser2["room2.js"]:::server
            Parser3["room3.js"]:::server
            ParserOut["out.js"]:::server
        end
        ConfigB["Config & Dependencies (package.json)"]:::server
    end

    %% Storage Layer
    subgraph "Storage"
        direction TB
        StorageCSV[(CSV Files)]:::storage
    end

    %% External Tools
    Postman["Postman Collection"]:::external

    %% Connections
    Entry --> UI
    UI -->|Start/Stop| Scanner:::mobile
    Scanner -->|reads RSSI| BSSID
    BSSID --> APIClient
    APIClient -->|"POST /append"| Router
    Postman -->|"HTTP POST"| Router
    Router --> Append
    Append --> StorageCSV
    StorageCSV -->|batch read| Parser1
    StorageCSV -->|batch read| Parser2
    StorageCSV -->|batch read| Parser3
    StorageCSV -->|batch read| ParserOut

    %% Click Events
    click Entry "https://github.com/rawanmohameedd/collecting-data/blob/main/Frontend/index.js"
    click UI "https://github.com/rawanmohameedd/collecting-data/blob/main/Frontend/App.js"
    click Scanner "https://github.com/rawanmohameedd/collecting-data/blob/main/Frontend/netInfo.js"
    click BSSID "https://github.com/rawanmohameedd/collecting-data/blob/main/Frontend/BSSIDs.js"
    click Android "https://github.com/rawanmohameedd/collecting-data/tree/main/Frontend/android/"
    click iOS "https://github.com/rawanmohameedd/collecting-data/tree/main/Frontend/ios/"
    click Config "https://github.com/rawanmohameedd/collecting-data/blob/main/Frontend/package.json"
    click Router "https://github.com/rawanmohameedd/collecting-data/blob/main/Backend/index.js"
    click Append "https://github.com/rawanmohameedd/collecting-data/blob/main/Backend/append.js"
    click Parser1 "https://github.com/rawanmohameedd/collecting-data/blob/main/Backend/dataParsers/room1.js"
    click Parser2 "https://github.com/rawanmohameedd/collecting-data/blob/main/Backend/dataParsers/room2.js"
    click Parser3 "https://github.com/rawanmohameedd/collecting-data/blob/main/Backend/dataParsers/room3.js"
    click ParserOut "https://github.com/rawanmohameedd/collecting-data/blob/main/Backend/dataParsers/out.js"
    click StorageCSV "https://github.com/rawanmohameedd/collecting-data/tree/main/Backend/data/"
    click ConfigB "https://github.com/rawanmohameedd/collecting-data/blob/main/Backend/package.json"
    click Postman "https://github.com/rawanmohameedd/collecting-data/blob/main/Collecting Data.postman_collection.json"

    %% Styles
    classDef mobile fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef server fill:#d4edda,stroke:#333,stroke-width:1px
    classDef storage fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef external fill:#e2e3e5,stroke:#333,stroke-width:1px
```
