Giter Site home page Giter Site logo

melardev / flaskapiecommerce Goto Github PK

View Code? Open in Web Editor NEW
27.0 3.0 26.0 156 KB

Python Ecommerce Api application built with Flask + Flask SQlAlchemy

Home Page: http://melardev.com

Python 99.08% Mako 0.67% Batchfile 0.25%
flask api python django ecommerce e-commerce full-stack fullstack shopping-cart flask-sqlalchemy

flaskapiecommerce's Introduction

Introduction

This is one of my E-commerce API app implementations. It is written in Python with Flask as the main dependency. This is not a finished project by any means, but it has a valid enough shape to be git cloned and studied if you are interested in this topic. If you are interested in this project take a look at my other server API implementations I have made with:

The next projects to come will be:

  • Elixir with phoenix and Ecto
  • AspNet MVC 6
  • Java EE with Jax RS with jersey
  • Java EE with Apache Struts 2
  • Spring Boot with Kotlin
  • Go with Gorilla and Gorm
  • Go with Beego
  • Laravel with Fractal and Api Resources
  • Flask with other Rest Api frameworks such as apisec, flask restful

WARNING

If you debug the seed_database.py file then be warned you may run into exceptions related to thread safety, in that case just rerun the script and try to not place the breakpoint where creating the model takes place

Getting started

  1. Git clone the project
  2. Setup Flask-Migrate flask db init && flask db migrate && flask db upgrade
  3. Seed the database with
  4. Seed the database python2 seed_database.py

While you play with the project, if you want to reset the database(delete the app.db, regenerate the migrations and migrate) you can execute reset.bat, it relies on flask2 executable(you may want to change it to flask instead); Flask2 it is just a custom bat file that I have that points to flask.exe from my Python2 Installation folder

Useful commands

  • Setup the migrations folder to hold migration files flask2 db init
  • Generate migration files flask2 db migrate
  • Make the actual migration and create tables on database flask2 db upgrade

Features

  • Authentication / Authorization
  • JWT middleware for authentication
  • Multi file upload
  • Database seed
  • Paging
  • CRUD operations on products, comments, tags, categories, orders Fetching products page
  • Orders, guest users may place an order Database diagram

What you will learn

  • Flask

  • Jwt authentication with flask

  • Controllers

  • Middlewares

  • JWT Authentication

  • Role based authorization

  • Flask SQLAlchemy ORM

    • associations: ManyToMany, OneToMany, ManyToOne
    • Select specific columns
    • Eager loading
    • Count related association
  • seed data

  • misc

    • project structure

Understanding the project

In project apps you will most of the times see that there is the launcher file, and the creation of the app and db is done elsewhere, why? to avoid circular dependencies. The app flask instance along with the db are heavily import from all over the places in our project, those variables are better placed in a separate file, I will explain this aspect in a youtube video if you did not get it.

TODO

  • Security, validations, fix vulnerabilities
  • File upload validation
  • unit testing
  • Create annotation to require authenticated user to be admin
  • Considering changing the project structure to a flask-ish way, with extensions clearly separated in a separate file even though the way it is implemented right now is not that bad
  • I do not think it is a good idea to put the get_dto inside the model itself, that should be placed in the corresponding serializer class to clearly separate the concerns, this is easy to refactor

Resources

flaskapiecommerce's People

Contributors

melardev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.