Page:
Step 01 Project Foundation
Pages
Home da
Home ms
Home
Step 01 Project Foundation da
Step 01 Project Foundation ms
Step 01 Project Foundation
Step 02 Product Catalog da
Step 02 Product Catalog ms
Step 02 Product Catalog
Step 03 Registration and Login da
Step 03 Registration and Login ms
Step 03 Registration and Login
Step 04 Shopping Basket da
Step 04 Shopping Basket ms
Step 04 Shopping Basket
Step 05 Stripe Checkout da
Step 05 Stripe Checkout ms
Step 05 Stripe Checkout
Step 06 Order Kanban Board da
Step 06 Order Kanban Board ms
Step 06 Order Kanban Board
Step 07 Reflection da
Step 07 Reflection ms
Step 07 Reflection
Clone
3
Step 01 Project Foundation
Tirsvad edited this page 2026-11-22 19:44:23 +01:00
Table of Contents
English · Dansk · Bahasa Malaysia
Step 1: Project foundation
The first step builds nothing the shopper can use yet. It sets up the tooling and the structure that every later step stands on, and serves one page.
Setup
- Python 3.14 or newer.
pyproject.tomllists adevgroup: pytest, pytest-cov, ruff and mypy. Flask, the only direct runtime dependency, was added in step 2 (ADR-0002). - A local virtual environment.
python -m venv .venv, activate it, thenpython -m pip install --upgrade pipandpython -m pip install -e ".[dev]". The environment keeps the project's packages apart from the system Python. - Run the shop with
python -m online_shopand open http://127.0.0.1:8000/.
Structure
The code in src/online_shop/ has four layers: domain, application, infrastructure and presentation. Dependencies point inward, so the business rules never import the web server. The presentation layer follows MVC: a controller answers a request and a view builds the HTML.
Constants
Every literal that more than one place needs lives once in src/online_shop/constants.py: the app title, host, port, content types, status codes and error messages. Changing the port means editing one line.
Checks
pytestruns unit and integration tests and fails below 90 percent coverage.python scripts/run_opengrep.pyscans the code and must find nothing of severity error before a push.- The screenshot is taken by a headless browser in a Docker container, never on the desktop.
What I learned
- The first page was served with
http.serverand a small router; step 2 replaced them with Flask once the hand-written layer started to grow. - Putting constants in one module and layers in separate folders from day one costs little and saves rework later.
- A test that starts the real server on a free port catches mistakes that unit tests miss.
