A Fully Async-based backend for Harmony Beauty.
- Make (GNU command)
- Python (>= 3.9)
- Poetry (1.2)
❯ tree app
.
├── auth # Package contains different config files for the `auth` app.
│ ├── crud.py # Module contains different CRUD operations performed on the database.
│ ├── models.py # Module contains different data models for ODM to interact with database.
│ ├── router.py # Module contains different routes for this api.
│ └── schemas.py # Module contains different schemas for this api for validation purposes.
├── cart # Package contains different config files for the `cart` app.
│ ├── crud.py # Module contains different CRUD operations performed on the database.
│ ├── models.py # Module contains different models for ODMs to inteact with database.
│ ├── router.py # Module contains different routes for this api.
│ └── schemas.py # Module contains different schemas for this api for validation purposes.
├── users # Package contains different config files for the `users` app.
│ ├── crud.py # Module contains different CRUD operations performed on the database.
│ ├── models.py # Module contains different models for ODMs to inteact with database.
│ ├── router.py # Module contains different routes for this api.
│ └── schemas.py # Module contains different schemas for this api for validation purposes.
├── utils # Package contains different common utility modules for the whole project.
│ ├── crypt.py
│ ├── dependencies.py # A utility script that yield a session for each request to make the crud call work.
│ ├── engine.py # A utility script that initializes an ODMantic engine and client and set them as app state variables.
│ ├── jwt.py # A utility script for JWT.
│ ├── mixins.py # A utility script that contains common mixins for different models.
├── config.py # Module contains the main configuration settings for project.
├── __init__.py
├── main.py # Startup script. Starts uvicorn.
└── py.typed # mypy related file.
The best way to configure, install main dependencies, and run the project is by using make
. So, ensure you have make
installed and configured on your machine. If it is not the case, head over to this thread on StackOverflow to install it on windows, or this thread to install it on Mac OS.
Having make
installed and configured on your machine, you can now run make
under the root directory of this project to explore different available commands to run:
make
Please use 'make <target>' where <target> is one of:
venv Create a virtual environment
install Install the package and all required core dependencies
run Running the app locally
deploy-deta Deploy the app on a Deta Micro
clean Remove all build, test, coverage and Python artifacts
lint Check style with pre-commit
test Run tests quickly with pytest
test-all Run tests on every Python version with tox
coverage Check code coverage quickly with the default Python
build Build docker containers services
up Spin up the containers
down Stop all running containers
make venv
source .venv/bin/activate
make install
Note: This command will automatically generate a .env
file from .env.example
, uninstall the old version of poetry on your machine, then install latest version 1.2.2
, and install the required main dependencies.
Head over to the official website to create a MongoDB account and a cluster.
Fill in the following environment variables in your .env file accordingly:
# Database
MONGODB_USERNAME=
MONGODB_PASSWORD=
MONGODB_HOST=cluster_name.example.mongodb.net
MONGODB_DATABASE=shop
Create a free account on Deta, and create a new project.
Set the following environment variable in your .env
file according to your project key value:
# Deta
DETA_PROJECT_KEY=
Generate a secret key using OpenSSL and update its env var in the .env file.
openssl rand -hex 128
afa1639545d53ecf83c9f8acf4704abe1382f9a9dbf76d2fd229d4795a4748712dbfe7cf1f0a812f1c0fad2d47c8343cd1017b22fc3bf43d052307137f6ba68cd2cb69748b561df846873a6257e3569d6307a7e022b82b79cb3d6e0fee00553d80913c1dcf946e2e91e1dfcbba1ed9f34c9250597c1f70f572744e91c68cbe76
# App config:
JWT_SECRET_KEY=afa1639545d53ecf83c9f8acf4704abe1382f9a9dbf76d2fd229d4795a4748712dbfe7cf1f0a812f1c0fad2d47c8343cd1017b22fc3bf43d052307137f6ba68cd2cb69748b561df846873a6257e3569d6307a7e022b82b79cb3d6e0fee00553d80913c1dcf946e2e91e1dfcbba1ed9f34c9250597c1f70f572744e91c68cbe76
DEBUG=info
make run
Note: You have to set DEBUG=info to access the docs.
First thing first, to run the entire platform, you have to clone the harmony-beauty
submodule using the following command:
git submodule update --init --recursive
Once that is done, make sure you have compose v2 installed and configured on your machine, and run the following command to build the predefined docker services(make sure you have a .env file beforehand):
Using Make
make build
or simply running:
docker compose build
Once that is done, you can spin up the containers:
Using Make
make up
or running:
docker compose up
Wait until the client service becomes available:
harmony-beauty-client-1 | Starting the development server...
You can stop the running containers but issuing the following command on a separate terminal session:
make down
You'll need to create a Deta account to use the Deta version of the APIs.
This button will only deploy the server.
The following packages are the main dependencies used to build this project:
This project and the accompanying materials are made available under the terms and conditions of the MIT LICENSE
.