Skip to content

Latest commit

 

History

55 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Flask Backend Setup

This guide walks you through setting up and running the Flask backend server, connecting to your own MySQL database, and migrating the database.

These instructions were written for Windows in mind. Commands may vary slightly between Windows and Mac.

Requirements

  • Python 3.9+
  • MySQL 8.0+
  • pip 24.3.1+

Setup Instructions

1. Clone the Repository

First, clone the repository to your local machine:

git clone <repository-url>
cd <repository-directory>
cd backend

2. Install Dependencies

Use pip to install the required dependencies. It is recommended to create a virtual environment before installing:

# Create and activate a virtual environment
py -m venv venv
source venv/Scripts/activate

# Install dependencies
pip install -r requirements.txt

3. Set Up the .env File

Create a .env file in the backend directory.

Template for the .env file:

# .env

SECRET_KEY=your_secret_key_here
JWT_SECRET_KEY=your_jwt_secret_key_here
DEV_DATABASE_URI=mysql+pymysql://<username>:<password>@localhost/<database_name>
ROOT_URL=root_url_of_frontend # When testing locally: http://localhost:3000

# If you are attempting to run without sendgrid, please put any placeholder values and you will simply lose resetting password capabilities
SENDGRID_EMAIL=your_sendgrid_email_address
SENDGRID_API_KEY=your_sendgrid_api_key

Generating a SECRET_KEY key: In any terminal

python
import secrets
secrets.token_hex(12)
quit()

Copy the result (without quotation marks) in place of your_secret_key_here

Generating a JWT_SECRET_KEY In any terminal

python
import secrets
secrets.token_urlsafe(64)
quit()

Copy the result (without quotation marks) in place of your_jwt_secret_key_here

4. Set Up Your MySQL Database

Make sure you have MySQL running and create a database:

# Login to MySQL
mysql -u <your-username> -p

# Create a database for the project
CREATE DATABASE <database_name>;

5. Run Database Migrations

To set up the database structure, you'll need to run the migrations. Flask-Migrate is used for managing database migrations.

# Run the migration commands to initialize the database
cd <repository-directory>/backend # Unless you are currently in the backend directory already
flask db upgrade  # Apply migrations scripts

6. Running the Development Server

Now, you can start the Flask development server:

cd <repository-directory>/backend # Unless you are currently in the backend directory already
py run.py

The backend server should now be running at http://127.0.0.1:5000/.

7. API Documentation

The API documentation is automatically generated and can be accessed at:

http://127.0.0.1:5000/api/v1/docs

8. Common Issues

  • MySQL client installation: Make sure the MySQL client is installed on your machine. You can install it via your package manager:

    • On Ubuntu: sudo apt-get install mysql-client
    • On MacOS (using Homebrew): brew install mysql
    • On Windows: Download and install MySQL client from here.
  • Virtual Environment Issues: If you encounter problems with the virtual environment, ensure you have activated it (source venv/bin/activate or venv\Scripts\activate on Windows).

React Frontend Setup

Requirements

  • Node.js (version 14 or higher)
  • npm (Node package manager)

Setup Instructions

cd <repository-directory>/frontend
npm install
npm start

About

Web-IntelliGenes: A reproducible, replicable, and transparent application of artificial intelligence and machine learning for predictive medicine. Medical Applications of Artificial Intelligence. 2nd Edition. (Taylor & Francis Group). 2026.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages