Skip to content

Mars Fitness is a gym that uses a subscription based membership.

Notifications You must be signed in to change notification settings

shinchri/Mars-Fitness

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mars-Fitness

Mars Fitness is a gym that uses a subscription based membership.

The Flask Stripe Subscriptions tutorial by Nik Tomazic was used as a guide to integrate Stripe Payment in this application.

Github Repository

Installing Dependencies

  1. Python 3.9 - Follow instruction to install the lates version of python for your platform in the python docs.
  2. Virtual Environment - Creating a virtual environment for the python project is recommended. Refer to the python docs.
  3. PIP Dependencies - After you set up the virtual enviornment setup and have it running, install dependencies by running the below command within the /Mars-Fitness folder.
$ pip install -r requirements.txt
  1. Key Dependencies
    • Flask is a lightweight backend microservices framework. Flask is required to handle requests and responses.
    • SQLAlchemy is the Python SQL toolkit and ORM we'll use to handle the postgres database.
    • Psycopg2-binary is a PostgreSQL database adapter for the Python.
    • Stripe is a suite of payment APIs that powers commerce for online businesses of all sizes.

Environment Variables

Add following environemental variables must be set:

  • Stripe test secret key
  • test publishable key
  • endpoint secret
  • price API ID
$ export STRIPE_PUBLISHABLE_KEY=<YOUR_STRIPE_PUBLISHABLE_KEY>
$ export STRIPE_SECRET_KEY=<YOUR_STRIPE_SECRET_KEY>
$ export STRIPE_PRICE_ID=<YOUR_PRICE_API_ID>
$ export STRIPE_ENDPOINT_SECRET=<YOUR_ENDPOINT_SECRET_KEY>

Database Setup

For this project, Postgres is used as our database. Make sure to download the Postgres here.

Create a database

$ createdb gym -U postgres

Config Setting

You may need to provide different postgres database url in config.py if you used different users, password, or database name.

SQLALCHEMY_DATABASE_URI = 'postgres://<USER_NAME>:<PASSWORD>@localhost:<PORT>/<DATABASE_NAME>'

Running the server

From within the ./Mars-Fitness directory, first ensure that you are working using your created virtual environmentl.

To run the server, first set Flask Environment variables:

$ export FLASK_APP=app.py
$ export FLASK_ENV=development

and excute:

$ flask run --reload

The --reload flag will detect file changes and restart the server automatically.

The application will be running on port 5000.

Future Improvements to be made

  • Implement endpoint to fetch subscription data
    • modify template to display the current plan to subscribed users
  • Implement user authentication and restrict some routes
  • Create a database that holds user subscriptions
  • Allow users to manage/cancel their current plan
  • Handle future payment failures
  • Deploy to Heroku and register webhook endpoints on Stripe

About

Mars Fitness is a gym that uses a subscription based membership.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published