Giter Club home page Giter Club logo

saas-api's Introduction

Python SaaS application boilerplate (asynchronous)

This project simplifies the creation of a Python SaaS api with the FastAPI framework, SQLAlchemy and Pipenv to create and manage a virtualenv.

  • FastAPI framework
  • SQLAlchemy (asynchronous) SQL toolkit and Object Relational Mapper
    • PostgreSQL
    • MySQL
    • Oracle
    • Microsoft SQL Server
    • SQLite
  • Alembic database migration tool
  • Authentication with OAuth2
  • Account
    • User Account Crud
    • Email password recovery
    • Registration email verification
  • Notification
    • Strategy for notifications
  • Store
    • Permissions control for owner
    • Store segment
  • Address
    • Address with a so-called "generic foreign key" to accounts and stores

Prepare environment

Install Pyenv for Python version management.

Pyenv installation instructions can be found in Pyenv page

Install Python 3.10.

$ pyenv install 3.10

Install Pipenv.

$ pip install --user pipenv

More detailed about Pipenv installation instructions can be found in the Pipenv page.

Create a new virtualenv using Python 3.10.

$ pipenv --python 3.10

Spawns a shell within the virtualenv.

$ pipenv shell

Install dependencies

Execute the following commands to install dependencies:

$ make requirements-dev

in production

$ make requirements

Configure the application environment

Copy and edit the .env file as needed.

$ cp .env.example .env

Run migrations

Execute the following command to create a migration:

$ alembic revision -m "Create catalog_products table"

The migrations will be created in the alembic/versions folder.

Execute the following command to upgrade to last revision:

$ alembic upgrade head

Execute the following command to downgrade version:

$ alembic downgrade -1

Execute the following command to display the current revision for a database.

$ alembic current

Execute the following command to list the history of migrations:

$ alembic history

Run application

Execute the following command to run the application in a development environment:

$ make runserver-dev

Execute the following command to run the application with gunicorn:

$ make runserver

Display registered routes.

Execute the following command to list all registered routes:

$ make show-routes

Pagination with dynamic filter and sorting.

Pass the filter field in query string, as in the example:

[{"field":"foo", "op":"ilike", "value":"%bar%"}]

Operators options are:

is_null, is_not_null, eq, ne, gt, lt, ge, le, like, ilike, not_ilike, in, not_in, any, not_any

Pass the sort field in query string, as in the example:

[{"field":"foo", "direction":"asc"}]

Api documentation

The base address of RESTful API is http://localhost:8000 and Swagger documentation is http://localhost:8000/docs

Outdated packages

Execute the following command to list outdated packages:

$ make outdated

Celery

Execute the following command to run celery task queues:

$ make runcelery

Execute the following command to run flower: Flower is a web based tool for monitoring and administrating Celery clusters

$ make runflower

Testing

Unit tests

Execute the following command to run all tests:

$ make test

Execute the following command to run test with name match, example:

$ make test-matching test=test_store_view_should_get_segments

Execute the following command to run celery task queues in tenting mode:

$ make runcelery-test

Execute the following command to run test with coverage reports, example:

$ make coverage

Lint

Execute the following command to check lint:

$ make check-lint

Execute the following command to try fix lint:

$ make lint

Security

Execute the following command to check security vulnerabilities in packages:

$ make check-safety

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

saas-api's People

Contributors

fndmiranda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

chivlakon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.