Installation
A quick start guide to our SafeStep project up and running on your local machine.
This is just a quick start guide to get the SafeStep project up and running on your local machine.
If you want a more comprehensive breakdown of a certain component for the project, click on the pages in the sidebar to the left. (e.g. Architecture, Flask Server, etc.
Prerequisites
Software Requirements:
All software needed to run the SafeStep project is listed below:
Android Studio
- for the mobile appFlask
- for the web server backendMongoDB
- for the database
Hardware Requirements:
- A computer (of course)
- An Android device or emulator to run the mobile app
- A Pi Pico W (which is what we used) or any other microcontroller to run the firmware that has Bluetooth capabilities
Step-by-Step Guide
-
Clone the repository
git clone https://github.com/SafeStepCSU/SafeStep.git
-
Set up the web server backend
-
In that same repository under the same directory, open the
SafeStep/App_Prototype/Server
folder in a new terminal. -
Install the required packages using
pip
:pip install -r requirements.txt
-
Setup the environment variables:
-
You can create a
.env
file in theServer
directory and add the following:MONGO_URI=https://safestep.onrender.com/
SECRET_KEY=your_secret_key
-
-
https://safestep.onrender.com/
is the URL to the public Flask server running on Render. You can replace this with your own MongoDB URI if you want to use your own database.
However, if you are using an emulator, you will need to replace the MONGO_URI
with YOUR OWN LOCAL URL. This is because the emulator cannot access the public server running on Render.
Use http://10.0.0.2:5000
as the URL in the Helper
class if you are running the Flask Server locally when running on an emulator (PLEASE BE AWARE THE EMULATOR DOES NOT SUPPORT BLUETOOTH).
-
Run the Flask server:
python app.py
-
The server should now be running on
http://localhost:5000
.
-
Set up the database
- Install MongoDB on your local machine.
- Create a new database called
SafeStep
. - Create a collection called
users
. - Create a time-series collection called
data
.
-
Chaquopy
Chaquopy is a plugin that allows you to run Python code in an Android app. It is used in the SafeStep project to run the Python code to generate graphs using matplotlib
in the mobile app.
- Navigate to the
SafeStep/App_Prototype/App
and underGradle Scripts
, look for thebuild.gradle.kts
file (Module: app). - Look for:
buildPython("C:/Users/.../AppData/Local/Programs/Python/Python310/python.exe")
- You will need to replace the path with the path to your Python executable on your machine.
-
Set up the mobile app
- Open the project in Android Studio (
SafeStep/App_Prototype/App
) - this is the mobile app, open theApp
folder in Android Studio. - Build with Gradle and run the app on an emulator or physical device.
- Open the project in Android Studio (
Docker Setup
We also provide a Docker setup for easy deployment. This will automatically set up the web server backend and database without the need for manual configuration.
If you manually set up the backend and database, you can skip this section, this is an alternative setup method.
Download the needed files from the here
-
Install Docker
-
Follow the instructions on the official Docker website to install Docker on your machine.
-
Make sure Docker is running.
-
You can verify this by running:
docker --version
-
-
Install Docker Compose
- Follow the instructions on the official Docker Compose website to install Docker Compose on your machine.
- You can verify this by running:
docker-compose --version
-
Set up the environment variables
-
Create a
.env
file in the project directory and add the following:MONGO_URI=your_mongodb://mongo:27017/safestep
SECRET_KEY=your_secret_key -
This will allow the Flask server to connect to the MongoDB database running in the Docker container.
-
-
Build the Docker images
- In the project directory, run:
docker-compose build
-
Run the Docker containers
- Run the following command to start the Docker containers:
docker-compose up
- The server should now be running on
http://localhost:5000
.
Additional Notes
- The mobile app is currently set up to connect to the Flask server running on
http://localhost:5000
. This will need to be updated if you are running the server on a different address or production server.