thachyyy / Retail-Store-Chain-Management-System

0 stars 0 forks source link

Run Back-end Step-by-step

Clone project on Github

git clone https://github.com/thachyyy/Retail-Store-Chain-Management-System.git

Move to project

cd Retail-Store-Chain-Management-System

Creating an Environment

python -m venv venv
# python 3.10.10

Activate venv Virtual Environment

source ./venv/Scripts/activate

Instal poetry to manage packages and dependencies

pip install poetry

Create .env file in the root folder

DEBUG=true
SQLALCHEMY_DEBUG=True
VERSION=0.1-SNAPSHOT
API_PREFIX=/api
PROJECT_NAME=Retail Chain Management System

POSTGRES_SERVER=localhost
POSTGRES_USER=postgres
POSTGRES_PASSWORD=1234
POSTGRES_DB=postgres
POSTGRES_SCHEMA=public
POSTGRES_PORT=5432
PROJECT_BUILD_TYPE=DEV

PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=
PUSHER_CLUSTER=
PUSHER_SSL=True

ACCESS_TOKEN_EXPIRES_IN_MINUTES=30
REFRESH_TOKEN_EXPIRES_IN_DAYS=30
JWT_ALGORITHM=HS256
JWT_SECRET_KEY=

S3_BUCKET_NAME=
S3_IMAGE_PREFIX=
S3_ENDPOINT_URL=
AWS_ACCESS_KEY=
AWS_SECRET_ACCESS_KEY=
AWS_REGION_NAME=

EMAIL_HOST=smtp.mailtrap.io
EMAIL_PORT=587
EMAIL_ADDRESS=nvdluan@gmail.com
EMAIL_PASSWORD=nlhzaiwefcqyoibm

# Channels
GENERAL_CHANNEL=general-channel
ALL_CHANNEL=all-channel

CROWD_BOT_API_KEY=
TIME_CANCEL_TASK=24

Quản lý database bằng PgAdmin4

  1. Tải PgAdmin4 tại link: Downloadhttps://www.pgadmin.org/download/

  2. Tạo server

    image

  3. Viết tên server (tùy ý)

    image

  4. Chuyển tab sang connection nhập các trường thông tin bao gồm:

    • host name: localhost (POSTGRES_SERVER)
    • Username: postgres (POSTGRES_USER)
    • Password: 1234 (POSTGRES_PASSWORD)
    • Maintenance Database: postgres (POSTGRES_DB)

    image

  5. Nhấn save để lưu lại, các bảng bạn cần tạo hoặc đã tạo nó sẽ ở đường dẫn sau (server\postgres\database\posgres\Schemas\table)

    image

  6. Thêm config cho postgresql. Nhấn chuột phải vào tên Database chọn Query Tool

    image

  7. Chạy lệnh:

    CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

    image

  8. Mở command line chạy trong VS code chạy lệnh để migration database:

    alembic upgrade head
  9. Quay lại giao diện Query Tool chạy lệnh:

    insert into system_settings (id, is_maintain) values (uuid_generate_v4(), false);

    image

  10. Chạy server backend

    uvicorn app.main:app --reload
  11. Mở trình duyệt web và truy cập vào

    http://localhost:8000/docs