Datzu712 / flask-fullstack-template

A full stack application with flask, mysql, nginx, webpack, redis and more.
MIT License
4 stars 1 forks source link

For Life, S.A Full Stack Application

Application preview

Table of contents

  1. Tech Stack
  2. Installation
    1. Local setup
    2. Docker setup
  3. webpack
  4. Author

Tech Stack

Web Application

Installation

  1. Clone the repository

    git clone https://github.com/Datzu712/For_Life_S.A.git
  2. Setup the environment variables Rename the .flaskenv.example file to .flaskenv and set the values for the environment variables

    
    FLASK_APP=wsgi
    FLASK_DEBUG=True
    FLASK_ENV=development
    FLASK_RUN_PORT=8080
    FLASK_RUN_HOST=0.0.0.0

MYSQL_URL=mysql+pymysql://admin:root@mysql:3306/uni

Mysql conf for docker (you can leave it blank if you are not using docker)

MYSQL_USERNAME=admin MYSQL_PASSWORD=root MYSQL_HOST=mysql MYSQL_PORT=3306 # redirect port of docker, mysql inside docker always would be 3306 MYSQL_DATABASE=uni

REDIS_URL=redis://admin:root@redis:6379/0

Redis conf for docker (you can leave it blank if you are not using docker)

REDIS_USERNAME=admin REDIS_PASSWORD=root REDIS_PORT=6379

SECRET_KEY=secret # secret key for the JWT token and flask sessions (we recommend to use different secrets for both)

SMTP_SERVER=smtp.example.com SMTP_PORT=587 SMTP_USERNAME=your_username SMTP_PASSWORD=password_token # you must use a token instead of your password SMTP_FROM_EMAIL=your_email@example.com SMTP_TO_EMAIL=recipient@example.com

APP_URL=http://localhost:5000

SENTRY_DSN=your_sentry_dsn


### Local setup (Keep in mind that you need to have MySQL and Redis installed)

3. Create a virtual environment
```bash
python3 -m venv .venv
  1. Activate the virtual environment (Linux)
    source .venv/bin/activate

4.1 Activate the virtual environment (Windows)

.venv\Scripts\activate
  1. Install the dependencies

    pip install -r requirements.txt
  2. Run the application

    flask run

Docker setup

  1. Generate the certificates for the Nginx server

    openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout nginx/ssl/cert.key -out nginx/ssl/cert.crt
  2. Run the docker compose command

    docker compose --env-file .flaskenv up
  3. Access the application on https://localhost:443

To stop the application run

docker compose --env-file .flaskenv down

Webpack

The application is built with webpack and typescript, to compile the files run the following command

# production build
npm run build:prod

# development build
npm run build:dev

# watch mode
npm run watch

I recommend to see the webpack.config.mjs file to see how the files are compiled and how entry points are defined (because it's like a custom configuration). Probably you should change the way that entries are loaded, it's up to you.

Author