This repo is for personal mini-project.
- exercises - folder for exercises, finished during classes
- mini-project - main repository for personal CAFE mini-project.
mini-project/week-*/data- includes data used for mini-project (if there are any)mini-project/week-*/notes- includes week requirements and some personal notesmini-project/week-*/source- source code for python CLI app Each week includes the completed code for that week’s requirements. The last week may still be in progress.
This mini project is about building a simple order management console app that uses a relational database to store and manage cafe data: -products -couriers information -orders history Users can create, view, update, and delete records directly in the database, making the data persistent between runs.
Week 1 - Build the basic user interface for your app: display menus, clear the screen, accept user input, and store simple data in lists using functions to keep code tidy.
Week 2 - Switch to using dictionaries to store detailed order data like customer info and status, preparing for more complex data handling.
Week 3 - Add courier management to your app and implement saving/loading data from .txt files, keeping file handling separate from display and logic code.
Week 4 - Refactor products and couriers to use dictionaries, store order items as lists of product indexes, switch to .csv files for persistence.
Week 5 - Migrate couriers and products data to a database instead of CSV, and update orders to reference couriers and products by unique IDs rather than list indexes.
Week 6 - Move all data, including orders and order statuses, into the database by creating dedicated tables and refactoring the app to fully rely on database storage.
1.1 Create Docker container
docker-compose up -dNotes:
- If you want to have database table populated with data use
docker-compose.ymlas it is:db: volumes: -./mini-project/week-*/data/cafe_dump.sql:/docker-entrypoint-initdb.d/cafe_dump.sql
- If you only want the schema:
db: volumes: ./mini-project/week-*/data/init.sql:/docker-entrypoint-initdb.d/init.sql
1.2 Create server and connect to cafe_db
- Log in to pgAdmin running in Docker (by default available at: http://localhost:8888/).
- Click on Add New Server and fill in the details:
- General tab: use any name for the server.
- Connection tab:
- Host name:
db - Maintenance database:
cafe_db - Username / Password: as specified in your
.envfile (by default:postgres/postgres)
- Host name:
Simple way to run application:
- Go to the
week-*/source/directory. - Run
main.py
python3 main.pyNotes: Application can run in venv.
To run unit tests use:
python3 -m pytest -v -sIf I had more time, I would do the following in my project:
-
Database: Separate product_ids from orders by creating a new table to store order product snapshots, or create a special type product_snapshot in the database. A "basket" = product snapshot = product info (id, name, price) + quantity.
-
Database: Create another entity called customer. Implement a menu for it and store all customer data in a separate table. Reference this table in the orders table.
-
Unit tests: Add more tests to cover at least all utility functions.
-
Docker: Fix the Dockerfile to run the entire Python app inside Docker.
-
Improve the README.md file.
-
Create a more user-friendly UI.
-
Add more comments throughout the code.