Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,24 @@ FLASK_ENV=development
SECRET_KEY=change-me-to-a-random-string

# --- Service ports (local mode) ---
MONOLITH_PORT=6000
USER_SERVICE_PORT=5001
PRODUCT_SERVICE_PORT=5002
ORDER_SERVICE_PORT=5003
BFF_PORT=8000
FRONTEND_PORT=5173
# Defaults live in scripts/service_table.py. Offset from the parent project
# (5001-5003, 8000, 5173) so both projects can run at the same time.
USER_SERVICE_PORT=5101
CATALOG_SERVICE_PORT=5102
ORDER_SERVICE_PORT=5103
GATEWAY_PORT=8100
FRONTEND_PORT=5273

# --- Service base URLs (used by the BFF and by services calling each other) ---
MONOLITH_BASE_URL=http://127.0.0.1:6000
USER_SERVICE_BASE_URL=http://127.0.0.1:5001
PRODUCT_SERVICE_BASE_URL=http://127.0.0.1:5002
ORDER_SERVICE_BASE_URL=http://127.0.0.1:5003
# --- Service base URLs (used by the gateway and by services calling each other) ---
USER_SERVICE_BASE_URL=http://127.0.0.1:5101
CATALOG_SERVICE_BASE_URL=http://127.0.0.1:5102
ORDER_SERVICE_BASE_URL=http://127.0.0.1:5103

# --- SQLite (local mode, default) ---
# Optional overrides — each path is relative to that service's own directory
# (e.g. MONOLITH_DB_PATH is relative to monolith/). Leave unset to use the
# built-in default of instance/<service>.sqlite3 inside each service folder.
# MONOLITH_DB_PATH=instance/monolith.sqlite3
# Optional overrides — each path is relative to that service's own directory.
# Leave unset to use instance/<service>.sqlite3 inside each service folder.
# USER_DB_PATH=instance/user.sqlite3
# PRODUCT_DB_PATH=instance/product.sqlite3
# CATALOG_DB_PATH=instance/catalog.sqlite3
# ORDER_DB_PATH=instance/order.sqlite3

# --- Azure Database for MySQL Flexible Server (azure mode only) ---
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
# Each suite gets its own install: monolith/app, bff/app and every
# Each suite gets its own install: gateway/app and every
# service's config.py share top-level module names, so they cannot
# run in one interpreter (see CLAUDE.md, "collision note").
matrix:
include:
- suite: repo-root
requirements: requirements-dev.txt
tests: tests/unit
- suite: bff
requirements: bff/requirements.txt
tests: bff/tests
- suite: user-service
requirements: microservices/user-service/requirements.txt
tests: microservices/user-service/tests
- suite: product-service
requirements: microservices/product-service/requirements.txt
tests: microservices/product-service/tests
- suite: order-service
requirements: microservices/order-service/requirements.txt
tests: microservices/order-service/tests
- suite: gateway
requirements: gateway/requirements.txt
tests: gateway/tests
- suite: user
requirements: services/user/requirements.txt
tests: services/user/tests
- suite: catalog
requirements: services/catalog/requirements.txt
tests: services/catalog/tests
- suite: order
requirements: services/order/requirements.txt
tests: services/order/tests
steps:
- uses: actions/checkout@v4

Expand Down
25 changes: 17 additions & 8 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,34 @@ history, monolith dropped). The full agreed plan is in [`docs/PLAN.md`](docs/PLA
- Name prefix: `ms12p` (parent uses `flaskms`). Teardown deletes the whole resource group, so a
shared name would delete the other project.

## Current state (M0)
The code is still the parent project's microservices + BFF + frontend, with the monolith
removed from setup, tests and CI only. Remaining monolith references in `bff/`, `frontend/`,
`scripts/run_local.py`, `scripts/benchmark.py` and `infra/` are replaced in M1, when `bff/`
becomes `gateway/`, services move to `services/<name>/`, and ports move to the new range
(gateway 8100, registry 8500, services 5101-5105, frontend 5273).
## Current state (M1a, layout)
- Folders: `services/{user,catalog,order}/` (Flask, one DB each), `gateway/` (FastAPI),
`frontend/`, `infra/`, `scripts/`, `tests/`. The monolith and the old migration engine are gone.
- **One service table**: `scripts/service_table.py` lists every local process, folder and port.
`setup.py`, `run_local.py`, `provision.py` and the smoke tests all read it. Add a service there.
- Ports: user 5101, catalog 5102, order 5103, gateway 8100, frontend 5273 (registry 8500 and
payment/inventory 5104-5105 arrive in later milestones).
- Gateway routes `/api/shop/<path>` to `/api/<path>` on the owning service by first path segment
(`gateway/app/config.py` `ROUTE_OWNERS`). No auth or aggregation yet (M1).
- The catalog service keeps the `product` resource name in its API (`/api/product(s)`) and its
`product_api` package. Only the service, its env vars (`CATALOG_*`) and its DB (`catalog_db`) are
named catalog.
- Azure: one Container App per service plus the gateway, all external ingress, images built with
`az acr build --platform linux/amd64`.

## Stack
Python 3.12 (Flask 3.1 services, FastAPI gateway), Node 18+ (React 18, TypeScript 5, Vite 5),
SQLite locally, Azure MySQL Flexible Server (one server, one DB per service) in Azure.

## Collision note (inherited)
Every Flask service has a top-level `config.py`/`application` package and the BFF has `app`.
Each runs in its own venv. `tests/conftest.py` adds only `infra/`, `scripts/`, `bff/` to
Every Flask service has a top-level `config.py`/`application` package and the gateway has `app`.
Each runs in its own venv. `tests/conftest.py` adds only `infra/`, `scripts/`, `gateway/` to
`sys.path`. M1 fixes this with a shared `shop_common` package.

## How to run
```bash
make setup # venvs per service + frontend npm deps, no Docker
make run # every service + gateway + frontend, health-gated
make test # unit tests, each suite in its own venv
make smoke # phased smoke tests, skip gracefully when not applicable
```
16 changes: 5 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
.PHONY: setup run run-all provision pause resume teardown verify test smoke benchmark clean
.PHONY: setup run provision pause resume teardown verify test smoke clean

setup:
python3.12 scripts/setup.py

run:
python3.12 scripts/run_local.py

run-all:
python3.12 scripts/run_local.py --all

provision:
python3.12 infra/provision.py --budget-email "$(BUDGET_EMAIL)" $(ARGS)

Expand All @@ -26,17 +23,14 @@ verify:

test:
.venv/bin/python -m pytest tests/unit -v
microservices/user-service/.venv/bin/python -m pytest microservices/user-service/tests -v
microservices/product-service/.venv/bin/python -m pytest microservices/product-service/tests -v
microservices/order-service/.venv/bin/python -m pytest microservices/order-service/tests -v
bff/.venv/bin/python -m pytest bff/tests -v
services/user/.venv/bin/python -m pytest services/user/tests -v
services/catalog/.venv/bin/python -m pytest services/catalog/tests -v
services/order/.venv/bin/python -m pytest services/order/tests -v
gateway/.venv/bin/python -m pytest gateway/tests -v

smoke:
.venv/bin/python -m pytest tests/smoke -v

benchmark:
bff/.venv/bin/python scripts/benchmark.py

clean:
find . -name "instance" -type d -exec rm -rf {} + 2>/dev/null || true
find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A small Contoso e-commerce system that shows **12 microservices patterns working
Each pattern gets its own page with an explanation, when *not* to use it, and a live demo you
can click.

> **Status: M0, bootstrap.** The foundation is copied from
> **Status: M1a, layout.** Three services, a gateway and the frontend run end to end. The foundation is copied from
> [Azure-Ecommerce-Monolith-Microservices-Migration](https://github.com/MAOFILHO/Azure-Ecommerce-Monolith-Microservices-Migration).
> The patterns arrive in 3 milestones. See [docs/PLAN.md](docs/PLAN.md).

Expand Down Expand Up @@ -38,6 +38,7 @@ can click.

```bash
make setup
make run # frontend http://127.0.0.1:5273, gateway http://127.0.0.1:8100
make test
```

Expand Down
166 changes: 0 additions & 166 deletions bff/app/azure_traffic.py

This file was deleted.

Loading
Loading