# jjhelloo/rf_tracker_backend architecture

> Architecture diagram of the GitHub repository jjhelloo/rf_tracker_backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jjhelloo/rf_tracker_backend
- Repository: https://github.com/jjhelloo/rf_tracker_backend

## Overview

This Node.js backend accepts Android-app and web-interface requests for authentication, users, RF devices, location updates, and geofence boundaries, persists and queries data in MySQL, and returns JSON responses. The main flow is HTTP entry and route dispatch, followed by controllers, SQL access, and database operations. Authentication helpers and token-based device lookup form an internal service layer. The README also describes sending stored data to the web interface; the sampled code shows query endpoints and responses, but not a separate push or delivery mechanism. hold.js is a core-indexed module whose behavior was not sampled.

Main entry points: [`index.js`](https://github.com/jjhelloo/rf_tracker_backend/blob/main/index.js) (Express Server), [`middleware/executeSQL.js`](https://github.com/jjhelloo/rf_tracker_backend/blob/main/middleware/executeSQL.js) (SQL Executor), [`controllers/authController.js`](https://github.com/jjhelloo/rf_tracker_backend/blob/main/controllers/authController.js) (Login and Tokens), [`controllers/deviceController.js`](https://github.com/jjhelloo/rf_tracker_backend/blob/main/controllers/deviceController.js) (RF Devices and Location)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP and Routing"]
  node_server["Express Server<br/>[index.js]"]
  node_auth_routes["Auth Routes<br/>[authRoutes.js]"]
  node_device_routes["Device Routes<br/>[deviceRoutes.js]"]
  node_user_routes["User Routes<br/>[userRoutes.js]"]
  node_geofence_routes["Geofence Routes<br/>[geofenceRoutes.js]"]
end

subgraph group_domain["Product Operations"]
  node_auth["Login and Tokens<br/>[authController.js]"]
  node_devices["RF Devices and Location"]
  node_users["User Management<br/>[userController.js]"]
  node_geofences["Geofence Boundaries"]
end

subgraph group_services["Internal Services"]
  node_sql["SQL Executor<br/>[executeSQL.js]"]
  node_helpers["Credential and Token Helpers<br/>[utils.js]"]
  node_hold["Additional Core Logic<br/>[hold.js]"]
end

subgraph group_storage["Persistence"]
  node_dbpool["MySQL Pool<br/>[dbPool.js]"]
  node_dbconfig["Database Config Pool<br/>[databaseConfig.js]"]
end

node_android(("Android App"))
node_web(("Web Interface"))
node_mysql[("MySQL Database")]

node_android -->|"sends requests"| node_server
node_web -->|"sends requests"| node_server
node_server -->|"mounts"| node_auth_routes
node_server -->|"mounts"| node_device_routes
node_server -->|"mounts"| node_user_routes
node_server -->|"mounts"| node_geofence_routes
node_auth_routes -->|"dispatches"| node_auth
node_device_routes -->|"dispatches"| node_devices
node_user_routes -->|"dispatches"| node_users
node_geofence_routes -->|"dispatches"| node_geofences
node_auth -->|"queries"| node_sql
node_devices -->|"queries"| node_sql
node_users -->|"queries"| node_sql
node_geofences -->|"writes boundary"| node_sql
node_auth -->|"checks credentials"| node_helpers
node_devices -->|"resolves device"| node_helpers
node_helpers -->|"queries"| node_sql
node_sql -->|"runs queries"| node_dbpool
node_dbpool -->|"connects"| node_mysql
node_dbconfig -->|"creates pool"| node_mysql
node_helpers -->|"imports pool"| node_dbconfig
node_auth -->|"returns auth result"| node_android
node_auth -->|"returns auth result"| node_web
node_devices -->|"returns response"| node_android
node_devices -->|"returns device data"| node_web
node_users -->|"returns response"| node_web
node_geofences -->|"returns response"| node_web

click node_server "https://github.com/jjhelloo/rf_tracker_backend/blob/main/index.js"
click node_auth_routes "https://github.com/jjhelloo/rf_tracker_backend/blob/main/routes/authRoutes.js"
click node_device_routes "https://github.com/jjhelloo/rf_tracker_backend/blob/main/routes/deviceRoutes.js"
click node_user_routes "https://github.com/jjhelloo/rf_tracker_backend/blob/main/routes/userRoutes.js"
click node_geofence_routes "https://github.com/jjhelloo/rf_tracker_backend/blob/main/routes/geofenceRoutes.js"
click node_auth "https://github.com/jjhelloo/rf_tracker_backend/blob/main/controllers/authController.js"
click node_devices "https://github.com/jjhelloo/rf_tracker_backend/blob/main/controllers/deviceController.js"
click node_users "https://github.com/jjhelloo/rf_tracker_backend/blob/main/controllers/userController.js"
click node_geofences "https://github.com/jjhelloo/rf_tracker_backend/blob/main/controllers/geofenceController.js"
click node_sql "https://github.com/jjhelloo/rf_tracker_backend/blob/main/middleware/executeSQL.js"
click node_helpers "https://github.com/jjhelloo/rf_tracker_backend/blob/main/utils/utils.js"
click node_hold "https://github.com/jjhelloo/rf_tracker_backend/blob/main/hold.js"
click node_dbpool "https://github.com/jjhelloo/rf_tracker_backend/blob/main/dbPool.js"
click node_dbconfig "https://github.com/jjhelloo/rf_tracker_backend/blob/main/config/databaseConfig.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_auth_routes,node_device_routes,node_user_routes,node_geofence_routes toneBlue
class node_auth,node_devices,node_users,node_geofences,node_mysql toneAmber
class node_sql,node_helpers,node_hold toneMint
class node_dbpool,node_dbconfig toneRose
class node_android,node_web toneIndigo
```

## Components

### HTTP and Routing

- [Express Server](https://github.com/jjhelloo/rf_tracker_backend/blob/main/index.js): `index.js`
- [Auth Routes](https://github.com/jjhelloo/rf_tracker_backend/blob/main/routes/authRoutes.js): `routes/authRoutes.js`
- [Device Routes](https://github.com/jjhelloo/rf_tracker_backend/blob/main/routes/deviceRoutes.js): `routes/deviceRoutes.js`
- [User Routes](https://github.com/jjhelloo/rf_tracker_backend/blob/main/routes/userRoutes.js): `routes/userRoutes.js`
- [Geofence Routes](https://github.com/jjhelloo/rf_tracker_backend/blob/main/routes/geofenceRoutes.js): `routes/geofenceRoutes.js`

### Product Operations

- [Login and Tokens](https://github.com/jjhelloo/rf_tracker_backend/blob/main/controllers/authController.js): `controllers/authController.js`
- [RF Devices and Location](https://github.com/jjhelloo/rf_tracker_backend/blob/main/controllers/deviceController.js): `controllers/deviceController.js`
- [User Management](https://github.com/jjhelloo/rf_tracker_backend/blob/main/controllers/userController.js): `controllers/userController.js`
- [Geofence Boundaries](https://github.com/jjhelloo/rf_tracker_backend/blob/main/controllers/geofenceController.js): `controllers/geofenceController.js`

### Internal Services

- [SQL Executor](https://github.com/jjhelloo/rf_tracker_backend/blob/main/middleware/executeSQL.js): `middleware/executeSQL.js`
- [Credential and Token Helpers](https://github.com/jjhelloo/rf_tracker_backend/blob/main/utils/utils.js): `utils/utils.js`
- [Additional Core Logic](https://github.com/jjhelloo/rf_tracker_backend/blob/main/hold.js): `hold.js`

### Persistence

- [MySQL Pool](https://github.com/jjhelloo/rf_tracker_backend/blob/main/dbPool.js): `dbPool.js`
- [Database Config Pool](https://github.com/jjhelloo/rf_tracker_backend/blob/main/config/databaseConfig.js): `config/databaseConfig.js`

### Other components

- **Android App**
- **Web Interface**
- **MySQL Database**

## Connections

- Android App → Express Server: sends requests (evidence: `index.js`)
- Web Interface → Express Server: sends requests (evidence: `index.js`)
- Express Server → Auth Routes: mounts (evidence: `index.js`)
- Express Server → Device Routes: mounts (evidence: `index.js`)
- Express Server → User Routes: mounts (evidence: `index.js`)
- Express Server → Geofence Routes: mounts (evidence: `index.js`)
- Auth Routes → Login and Tokens: dispatches (evidence: `routes/authRoutes.js`)
- Device Routes → RF Devices and Location: dispatches (evidence: `routes/deviceRoutes.js`)
- User Routes → User Management: dispatches (evidence: `routes/userRoutes.js`)
- Geofence Routes → Geofence Boundaries: dispatches (evidence: `routes/geofenceRoutes.js`)
- Login and Tokens → SQL Executor: queries (evidence: `controllers/authController.js`)
- RF Devices and Location → SQL Executor: queries (evidence: `controllers/deviceController.js`)
- User Management → SQL Executor: queries (evidence: `controllers/userController.js`)
- Geofence Boundaries → SQL Executor: writes boundary (evidence: `controllers/geofenceController.js`)
- Login and Tokens → Credential and Token Helpers: checks credentials (evidence: `controllers/authController.js`)
- RF Devices and Location → Credential and Token Helpers: resolves device (evidence: `controllers/deviceController.js`)
- Credential and Token Helpers → SQL Executor: queries (evidence: `utils/utils.js`)
- SQL Executor → MySQL Pool: runs queries (evidence: `middleware/executeSQL.js`)
- MySQL Pool → MySQL Database: connects (evidence: `dbPool.js`)
- Database Config Pool → MySQL Database: creates pool (evidence: `config/databaseConfig.js`)
- Credential and Token Helpers → Database Config Pool: imports pool (evidence: `utils/utils.js`)
- Login and Tokens → Android App: returns auth result (evidence: `controllers/authController.js`)
- Login and Tokens → Web Interface: returns auth result (evidence: `controllers/authController.js`)
- RF Devices and Location → Android App: returns response (evidence: `controllers/deviceController.js`)
- RF Devices and Location → Web Interface: returns device data (evidence: `controllers/deviceController.js`)
- User Management → Web Interface: returns response (evidence: `controllers/userController.js`)
- Geofence Boundaries → Web Interface: returns response (evidence: `controllers/geofenceController.js`)
