GameHub is an educational project demonstrating the work of a distributed system using PostgreSQL, microservice architecture and Docker. The project includes:
- Game Store (store-service): allows users to view games, add them to the cart, and make purchases.
- Banking service: processes transactions and manages the balance of users.
- Database: stores data about users, games, studios, tags, purchases, and media content.
- python3
- python-pillow
python3 tools/deGenerator.py
This utility will generate a set of initializing data for the store's database and put it in a set of initializing csv files.
USERS_COUNT = 100 # amount of users generated by the rule "user_name:password" username<id>:username<id>, where <id> from 1 to USERS_COUNT
STUDIO_COUNT = 10 # amount of studios with names studio<id>, where <id> from 1 to STUDIO_COUNT
TAGS_COUNT = 20 # amount of tags with names tag<id>, where <id> from 1 to TAGS_COUNT
GAMES_COUNT = 100 # amount of games with names game<id> from random studio from above, where <id> from 1 to GAMES_COUNT
MAX_SCREENSHOT_COUNT = 8 # amount of max-screenshot for one game. A number up to MAX_SCREENSHOT_COUNT is selected for each game.
GAME_TAGS_COUNT = 1000 # amount of associations of random tags created earlier with random games created earlier.
PURCHASES_COUNT = 1000 # amount of created purchases. With chance 50% create purchases with ts = NULL ( game in cart, not in library ) for random users.
STORE_DB_NAME=store-db
STORE_DB_PSWD=store-pswd
STORE_DB_USER=store-user
BANK_DB_NAME=bank-db
BANK_DB_PSWD=bank-store
BANK_DB_USER=bank-user
DB_PORT=51488
curl --insecure -X GET -H 'Content-Type: application/json' -u "seregga:seregga" "https://127.0.0.1:5001/api/balance"
curl --insecure -X POST -H 'Content-Type: application/json' -d '{"uuid" : "test", "password" : "test"}' "https://127.0.0.1:5001/api/add-account"
curl --insecure -X POST -H 'Content-Type: application/json' -u "test:test" "https://127.0.0.1:5001/api/delete-account"
curl --insecure -X POST -H 'Content-Type: application/json' -u "test:test" -d '{"uuid_to" : "seregga", "amount" : 500 }' "https://127.0.0.1:5001/api/transfer"
- 401 : authorization failed
- 402 : wrong requested data
- 404 : wrong request
- docker
- docker-compose
- openssl ( create certificates for your services )
- curl ( interaction with bank service )
# create test data (optional)
python tools/deGenerator.py
# store.crt and store.key files for store service
cd store-service/
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout store.key -out store.crt
cd ..
# bank.crt and bank.key files for bank service
cd bank-service/
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout bank.key -out bank.crt
cd ..
# run containers in daemon mode
docker compose up --build -d
# stop services
docker compose down
# clear database volume
docker compose down --volumes
sudo debootstrap noble ./ubuntu-sandbox
sudo mount --bind ./ubuntu-sandbox ./ubuntu-sandbox
sudo chroot ./ubuntu-sandbox
passwd # set password for root in container
exit
sudo systemd-nspawn -b -D ./ubuntu-sandbox
After that you need to change /etc/resolve.conf for nameserver 8.8.8.8 and /etc/apt/source.list for :
deb http://archive.ubuntu.com/ubuntu/ noble main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ noble-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ noble-backports main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ noble-proposed main restricted universe multiverse
# install utils for os
apt install -y python3 libssl-dev nginx python3-pip python3-venv postgresql
python3 -m venv /opt/venv
export PATH="/opt/venv/bin:$PATH"
# install python requirements.txt
CFLAGS="-I/usr/local/opt/openssl/include" LDFLAGS="-L/usr/local/opt/openssl/lib" UWSGI_PROFILE_OVERRIDE=ssl=true pip3 install --no-cache-dir -r store-service/requirements.txt
pip install --no-cache-dir -r bank-service/requirements.txt
Run services (it is important at this stage to already have initialized environment variables (as in the dotenv file!!!) :
# run bank service
cd bank-service
python app.py
#run store service
cd store-service
uwsgi --ini uwsgi.ini
These utilities are stored in the tools directory.
- deGenerator.py : generator of test data for store-service with some variables parameters;
- DOSer.py : checking for resistance to basic DOS;
- tester.py : running a specific sql query to a specific database from python-psycopg3.
- Gubanov Peter (@gubanovpm)
- Khrol Ivan (@ent1r)
- Potapova Anna (@ann37)