Bibi

Bibi was originally an overseas study life assistant APP, including popular modules such as e-commerce and social networking. It has experienced the test of commercial operation and is a relatively mature solution.

This project is an e-commerce service backend, based on Flask, MongoDB, Redis, Celery, RabbitMQ, support Python 3.5.

Bibi provides full stack solutions for e-commerce, which can be used with the following projects:

Bibi-frontend wechat frontend project

Bibi-ionic Mobile Hybrid APP source code


The Features:

Screenshot

Content Management InterfaceLogistics Management InterfaceCommodity Management interface

Set up the environment

This tutorial is based on Ubuntu/Debian, skip it if python3 is already installed

#Install the PYTHon3 environment
sudo apt-get update
sudo apt-get install python3-pip python3-dev
sudo apt-get install build-essential libssl-dev libffi-dev python-dev

#Install virtualenv
sudo pip3 install virtualenv virtualenvwrapper
echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.bashrc
echo "export WORKON_HOME=~/Env" >> ~/.bashrc
echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc
source ~/.bashrc

#You now have Env in your home directory, where your Python virtual environment will be created

mkvirtualenv bibi #Bibi can be changed to your project name at will
workon bibi #You are now in the standalone environment of the project

#Install mongodb (install mongodb 3.0 or later)
#Install redis slightly
#Install the rabbitMQ slightly
Copy the code

Install dependencies

pip3 install -r requirements.txtCopy the code

Initializing the database

python3 manage.py shell
# into Python3 shell
>>> from application.models import User
>>> user = User.create(email="[email protected]".password="xxx".name="xxxx")
#Change your email, password, and name to your own
>>> user.roles.append("ADMIN")
>>> user.save()
<User: 58d25726266b0451cc136c17>
Copy the code

run

python3 manage.py runserver
Copy the code

You can open http://127.0.0.1:5000/ locally

The deployment of

#The installation supervisor
sudo apt-get install supervisor
#Install the gunicorn
pip3 install gunicorn

sudo vim /etc/supervisor/conf.d/bibi.confCopy the code

Bibi. The conf code

[program: bibi] command = / root/Env/bibi/bin/gunicorn -w 0.0.0.0:3 - b - 8080 log level debug "application. The app: create_app ()"  directory=/opt/py-maybi/ ; Your project code directory autostart=false; Autorestart =false; Whether to automatically restart stdout_logfile=/opt/logs/gunicorn.log; The log log redirect_stderr = trueCopy the code

PS: above -w is the number of workers opened, formula: (Number of system cores *2 + 1)

Nginx configuration

server {
    listen 80;
    server_name bigbang.maybi.cn; This is the external domain name of the HOST machine

    location / {
        proxy_pass http://127.0.0.1:8080; # here is the service address pointing to Gunicorn Host
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }}Copy the code

Then start celery, supervisor, nginx

celery -A application.cel worker -l info &

sudo supervisorctl reload
sudo supervisorctl start bibi

sudo service nginx restart

Copy the code

And you’re done.

If you have any questions, please feel free to make an Issue.