dimzzky / final-project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Final Project Startup Campus

This is repository for the final project of the course Startup Campus.

The primary goal of this project is to make backend for marketplace website. The website will be used to sell and buy products. The website will have a lot of features, but the main ones are:

  • Authentication
  • Home
  • Products
  • Cart
  • Orders
  • Profile

This project comes with a requirement document requirement.

Check documentation for more details. Documentation

Table of Contents

  1. Dependencies
  2. Getting Started
  3. Commands
  4. Database
  5. Application Structure
  6. Development
  7. Testing

Dependencies

You will need docker and docker-compose.

Getting Started

First, clone the project:

$ git clone https://github.com/Cizz22/final-project.git <my-project-name>
$ cd <my-project-name>

Then install dependencies and check that it works

$ make install      # Install the pip dependencies on the docker container
$ make daemon        # Run the container containing your local python server

If everything works, you should see the available routes here.

in this project you will need storage for images, so you need to create a folder using command

$ make server.storage

after that, you can migrate the database

$ make database.upgrade

Commands

You can display availables make commands using make.

While developing, you will probably rely mostly on make server.start; however, there are additional scripts at your disposal:

make <script> Description
help Display availables make commands
server.install Install the pip dependencies on the server's container.
server.start Run your local server in its own docker container.
server.daemon Run your local server in its own docker container as a daemon.
server.bash Connect to server to lauch commands
server.stop Stop server in its docker container
server.logs Display server logs
server.storage Make storage file
server.nginx Run nginx container with its nginx conf file
database.connect Connect to your docker database.
database.migrate Generate a database migration file using alembic, based on your model files.
database.upgrade Run the migrations until your database is up to date.
database.downgrade Downgrade your database by one migration.
database.seeder Run database seeder
database.drop Drop all table
test Run unit tests with pytest in its own container.

Database

The database is in PostgreSql.

Locally, you can connect to your database using :

$ make database.connect

Application Structure

The application structure presented in this boilerplate is grouped primarily by file type. Please note, however, that this structure is only meant to serve as a guide, it is by no means prescriptive.

.
├── migrations               # Database's migrations settings
│   └── versions             # Database's migrations versions generated by alembic
├── src                      # Application source code
│   ├── models               # Python classes modeling the database
│   │   ├── abc.py           # Abstract base class model
│   │   └── user.py          # Definition of the user model
│   ├── repositories         # Python classes allowing you to interact with your models
│   │   └── user.py          # Methods to easily handle user models
│   ├── resources            # Python classes containing the HTTP verbs of your routes
│   │   └── user.py          # Rest verbs related to the user routes
│   ├── routes               # Routes definitions and links to their associated resources
│   │   ├── __init__.py      # Contains every blueprint of your API
│   │   └── user.py          # The blueprint related to the user
│   ├── seeder               # Database seeder
│   │   ├── __init__.py      # Contains main seeder
│   │   └── user.py          # User seeder
│   ├── util                 # Some helpfull, non-business Python functions for your project
│   │   └── parse_params.py  # Wrapper for the resources to easily handle parameters
│   ├── config.py            # Project configuration settings
│   └── server.py            # Server configuration
└── test                     # Unit tests source code

Development

To develop locally, here are your two options:

$ make server.start           # Create the containers containing your python server in your terminal
$ make server.daemon          # Create the containers containing your python server as a daemon

The containers will reload by themselves as your source code is changed. You can check the logs in the ./server.log file.

Testing

To add a unit test, simply create a test_*.py file anywhere in ./test/, prefix your test classes with Test and your testing methods with test_. Unittest will run them automaticaly. You can add objects in your database that will only be used in your tests, see example. You can run your tests in their own container with the command:

$ make test

About


Languages

Language:Python 98.0%Language:Makefile 1.7%Language:Mako 0.3%Language:Shell 0.1%