Tirsvad 4139bc79ed
TirSystem/git-workflows: CD / changes (push) Successful in 7s
TirSystem/git-workflows: CI / secret-scan (push) Successful in 8s
TirSystem/git-workflows: CI / validate (push) Successful in 17s
TirSystem/git-workflows: CI / opengrep (push) Successful in 1m10s
TirSystem/git-workflows: CI / release-check (push) Successful in 6s
TirSystem/git-workflows: CD / wait-for-ci (push) Successful in 1m50s
TirSystem/git-workflows: CD / release (push) Skipped
TirSystem/git-workflows: CD / sync-milestones (push) Successful in 23s
TirSystem/git-workflows: CD / publish-wiki (push) Successful in 26s
TirSystem/git-workflows: CD / sync-metadata (push) Successful in 5s
Merge pull request 'Add the reflection to the wiki and fix the repository name in links' (#54) from reflection-wiki-page into main
Reviewed-on: #54
2026-11-22 19:42:03 +01:00

🚀 Online Shop

An online shop built with Flask, SQLite, Stripe Checkout and plain JavaScript, with Flask as the only direct runtime dependency. It is Day 97 of the 100 Days of Code bootcamp: products, a basket, registration and login, payment in a Stripe sandbox, and a Kanban board where the shop owner follows each order. It is for course participants who want to compare solutions and for visitors who look for ideas.

📚 Table of Contents

🧭 Overview

Shoppers browse products, keep them in a basket, register, sign in and pay through Stripe Checkout (test mode). The shop owner signs in as admin and moves paid orders across a Kanban board: Needs confirmation, Confirmed, Being packed, Shipped and Delivered. The project is built in seven steps, and each step has a screenshot below and a wiki page in English, Danish and Bahasa Malaysia that explains what it taught.

Folder What it is for
src/online_shop/ The program: domain, application, infrastructure and presentation layers (the Flask app and its templates live in presentation); constants.py holds every constant
tests/ unit, integration and e2e tests, run with pytest
docs/ Project documents, wiki pages (docs/wiki/) and screenshots (docs/screenshots/)
tools/screenshots/ The Docker container that opens the app in a headless browser and takes the screenshots
scripts/ Helper scripts, such as the opengrep scan

📋 Requirements

  • Python 3.14 or newer, to run the program. The program's only direct runtime dependency is Flask, which pip installs for you.
  • pip and venv, which come with Python, to create the local environment.
  • pytest, pytest-cov, ruff and mypy for development; they are installed by the dev group below.
  • Docker, only to take screenshots and run the browser tests.
  • Doxygen, only to build the source documentation.
  • opengrep, only to scan the code before a push.

🛠️ Setup

Create a local virtual environment named .venv in the repository root, then upgrade pip.

python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

On Linux or macOS the commands are:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

To leave the environment, run deactivate. The folder .venv/ is ignored by git.

▶️ Run

With the environment active:

python -m online_shop

Then open http://127.0.0.1:8000/ in a browser.

Accounts use three optional environment variables. They are read at start and never printed:

Variable Meaning
SHOP_SECRET_KEY Signs the session cookie. If it is missing, a random key is made at start and sessions end when the server stops.
SHOP_ADMIN_EMAIL Email of the admin account, created at start when both admin variables are set.
SHOP_ADMIN_PASSWORD Password of the admin account. There is no default; choose your own.

Payment uses Stripe Checkout in test mode. Create a local file stripe.env in the project folder (git ignores it; never commit it) with your Stripe sandbox test keys:

PUBLISHABLE_KEY=pk_test_...
SECRET_KEY=sk_test_...

The shop refuses live keys and never prints a key. If the file is missing, the shop reads the environment variables PUBLISHABLE_KEY and SECRET_KEY instead (for example from a CI secret store); the file wins when both exist. Without either, the shop still runs, but the Checkout button is hidden. SHOP_STRIPE_ENV_FILE points to another path. To try a payment, sign in, fill the basket, press Checkout and pay on the Stripe page with the test card 4242 4242 4242 4242, any future expiry date and any CVC.

For example, in PowerShell: $env:SHOP_ADMIN_EMAIL = "admin@example.com"; $env:SHOP_ADMIN_PASSWORD = "<your password>", then python -m online_shop. The admin page is at http://127.0.0.1:8000/admin. Stop the server with Ctrl+C. The host and port are in src/online_shop/constants.py.

📸 Screenshots

Step What it shows
1. Project foundation The first page of the shop Step 1
2. Product catalog and storage The dark catalog on desktop and phone, rendered by Flask Step 2
3. Registration and login The login page on desktop and the register page on a phone Step 3
4. Shopping basket A filled basket on desktop and phone Step 4
5. Stripe checkout The basket with its Checkout button on desktop and the order confirmation on a phone Step 5
6. Order Kanban board The admin board with the five order columns on desktop and phone Step 6

Screenshots are made in a Docker container, never on the desktop:

docker build -t online-shop-shots tools/screenshots
docker run --rm -v "${PWD}:/work" online-shop-shots step-01

🧪 Tests

python -m pytest
python -m ruff check src tests
python -m mypy src tests
python scripts/run_opengrep.py
doxygen Doxyfile

pytest also prints the coverage and fails below 90 percent. Run the opengrep scan before every push.

The browser tests in tests/e2e/ run only in the Docker container, never on the desktop. They write their result to results/e2e.xml:

docker build -t online-shop-shots tools/screenshots
docker run --rm -v "${PWD}:/work" -w /work --entrypoint python online-shop-shots -m pytest -o addopts="" -o pythonpath="src tests" --junitxml=results/e2e.xml tests/e2e

💭 Reflection

How I approached the project. I planned first. The business case, the stakeholders, the plan and seven milestones were written and reviewed before any code, and each milestone went through one pull request with its review record. The code is in four layers (domain, application, infrastructure, presentation), so the shop rules do not depend on Flask, SQLite or Stripe and most of the 340 tests run without a browser. I chose a Kanban board for the orders because an order moves through a few clear steps (needs confirmation, confirmed, being packed, shipped, delivered), and a board shows the whole queue at a glance, so the owner sees what to do next and moves an order with a drag.

What was easy. The domain rules (money in cents, the basket, the order statuses) and the SQLite repositories. Once the ports existed, fakes made them quick to test.

What was hard. The order board with drag and drop that keeps positions in the database, and Stripe checkout, which has to be tested without real keys or real payments. CI also caught what my local checks missed: a fake sk_live_ key in a test tripped the secret scan, and SQL built from f-strings tripped the code scan. SQL injection is the risk to watch: every query is now a plain literal with ? placeholders, and user input only travels as a bound value.

How I might improve for the next project. Run the same scans CI runs before every push, look at a real screenshot as soon as a page exists, and keep the plan and the code in step as I go.

My biggest learning. A decision that changes in the middle of a project (the switch from the standard library to Flask) is cheapest when it is written down first, in an ADR and the plan, and only then coded. A bug like site.update rendering a dict method in a template is found by looking at a real screenshot, not by the unit tests.

What I would do differently. Settle the framework before the first milestone, and write the SQL as plain literals with placeholders from the first repository.

The longer version is in the wiki, step 7.

📄 License

GNU Affero General Public License v3.0, see LICENSE.

📎 Appendix: Project documents

Document What it tells you
Business Case Why the project exists, its scope and success criteria
Stakeholder Analysis Who is involved; the stakeholder IDs used for owners and reviewers
Project Plan The gateways and their schedule
Milestones One document per gateway: Go/No-Go criteria and tasks
Artifact registry Where each artifact type lives, the next version, the PO language and domain
Traceability matrix How the artifacts link and when each was last reviewed
Framework README The framework this project uses
Framework changelog What changed in each framework release

S
Description
Online shop in Python 3.14 with Flask, SQLite, Stripe checkout and an order kanban board (Udemy 100 Days of Code, assignment 097)
Readme AGPL-3.0
1.7 MiB
1 Stars 1 Watchers 0 Forks
Languages
Python 88.6%
CSS 4.5%
HTML 4.2%
JavaScript 2.5%
Dockerfile 0.2%