Week 5: API Endpoints

March 7, 2025

Thoughts of the week

This week, I solidified my thoughts on which DB architecture I wanted to use. I will be sticking with MongoDB as I have used it before and am currently using it on a project I am working on. I was advised to do some testing when going through this process such as making sure the compsci server can communicate with MongoDB and have data be sent back successfully. This test was successful and confirmed my go-ahead to continue with MongoDB.

API Endpoints Overview

Beacon Endpoints

GET/api/beacons

Retrieves all beacon devices in the database. This will be used in the admin interface to manage beacon devices.

GET/api/beacons/:id

Retrieves a specific beacon by ID, including its RSSI threshold settings and location information.

POST/api/beacons

Creates a new beacon in the system. Requires authentication as this is an admin function.

PUT/api/beacons/:id

Updates an existing beacon's information (name, RSSI threshold, etc.).

DELETE/api/beacons/:id

Removes a beacon from the system.

POST/api/beacons/nearby

The key endpoint for the iOS app - accepts RSSI readings and returns nearby beacons with their associated workout stations. This is what enables the proximity-based workout recommendations.

Station Endpoints

GET/api/stations

Retrieves all workout stations with their associated beacons and workouts.

GET/api/stations/:id

Retrieves detailed information about a specific workout station.

POST/api/stations

Creates a new workout station and links it to a beacon and workout program.

PUT/api/stations/:id

Updates an existing station's details or changes its associated workout.

DELETE/api/stations/:id

Removes a station from the system.

GET/api/stations/beacon/:beaconId

Retrieves all stations associated with a specific beacon, allowing for multiple workout options at the same physical location.

Workout Endpoints

GET/api/workouts

Retrieves all workout programs in the database.

GET/api/workouts/:id

Retrieves a specific workout with its exercise list, sets, reps, and other parameters.

POST/api/workouts

Creates a new workout program with specified exercises.

PUT/api/workouts/:id

Updates an existing workout's parameters or exercise list.

DELETE/api/workouts/:id

Removes a workout from the system.

Exercise Endpoints

GET/api/exercises

Retrieves all exercises in the database.

GET/api/exercises/:id

Retrieves details about a specific exercise including instructions and recommended sets/reps.

POST/api/exercises

Adds a new exercise to the library.

PUT/api/exercises/:id

Updates an existing exercise's details or instructions.

DELETE/api/exercises/:id

Removes an exercise from the system.

User Endpoints

POST/api/users

Registers a new user in the system.

POST/api/users/login

Authenticates a user (In future: returns a JWT token for protected endpoints.)

GET/api/users/profile

Retrieves the current user's profile information.

PUT/api/users/profile

Updates the current user's profile information.

Workout History Endpoints

GET/api/history

Retrieves workout history for admin use.

GET/api/history/:id

Retrieves a specific workout history entry.

POST/api/history

Creates a new workout history entry when a user completes a workout.

GET/api/history/user

Retrieves all workout history for the current user.

GET/api/history/user/stats

Retrieves workout statistics and trends for the current user.

Next Steps

My immediate next steps are to implement these API endpoints and test them thoroughly. I'll start with:

  • Setting up the Node.js/Express server infrastructure
  • Implementing the MongoDB models for each data entity
  • Building and testing the Beacon and Station endpoints first, as these are core to the proximity functionality
  • Possibly in future: Implementing user authentication with JWT
  • Creating a simple test client to verify the RSSI-based proximity detection

Once these are working reliably, I'll continue with implementing the workout and exercise endpoints, followed by the user workout history tracking. I expect to have the core API functionality working within the next week, which will allow me to focus on integrating it with the iOS app in the final weeks of the project.