logo
Published on

Coffee Shop 0. A Bean Shop from Documents to Deployment

Authors
  • avatar
    Name
    seren-wib
    Twitter
Contents

0. Introduction

For a Software Engineering team assignment I built coffee-shop, an online coffee bean shop. The course grades documents more than code: the SRS and the SDD are 10% each, so from 2026-09-15 the first two months were almost all documents. Implementation and Deployment were squeezed into the last ten days. The repository is public (seren-wib/coffee-shop), and Claude Code wrote this post from the commits, PRs and work notes.

In restaurant terms, the first two months were drawing the menu and the kitchen blueprint and getting them reviewed, and the last ten days were building the kitchen and the dining room and opening the doors. Every order slip got a number so the floor and the kitchen call it the same way, there is only one kitchen so orders queue in one line at the door, and the sign was swapped only after the new place was fully set up. The menu and blueprint are the SRS and SDD, the review is the assignment submissions and the professor's feedback, construction is the implementation PRs, the slip number is the requirement ID, the single line is the SQLite write lock wait (BEGIN IMMEDIATE transaction), and the sign is the current symbolic link.

Below, documents, backend, frontend and Deployment follow in the order they happened, and the numbers are in one table in section 11.

System diagram. The React SPA in the browser goes through the Cloudflare proxy to nginx on EC2; nginx splits static files from /api/, which goes to gunicorn and Django. Django writes to a SQLite file and calls the Toss Payments API to confirm and cancel payments. The browser opens the payment window itself

1. What we built

A customer picks beans, chooses a size and grind, puts them in the cart, orders, pays and tracks delivery. An admin manages beans and stock and moves orders through preparing, shipping and cancellation. Payments run in Toss Payments test mode, so no real money moves.

AreaChoiceReason
BackendDjango 6.1, Django REST FrameworkORM, database migration and auth come built in, which shrinks the work; the test runner is built in
DBSQLite (WAL, IMMEDIATE transactions)One server and only demo users, so no reason for a separate DB server. Concurrent orders checked by a spike
FrontendReact 19, Vite 8, Tailwind CSS 4An SPA with 16 screens. The Vite dev server proxies /api to Django, so local setup is one line
PaymentsToss Payments window SDK 2.10.0, test keysKorean test payments work with just a sign-up
OperationsEC2 t3.micro, nginx, gunicorn, systemdAbout $14.96 a month (estimate, SPMP 4.1). Only one server to look after
AutomationGitHub Actions (ci, docs-sync, deploy)Reaches Google and AWS through OIDC with no secrets

Three people, listed by GitHub ID only. seren-wib (me) did requirements, architecture, the document restructure, all implementation and Deployment. Heisnotanimposter did the HW1 DB schema DDL, the class diagram and domain model, and method algorithm design. Yang-HA-03 did the screen list and wireframes, sequence diagrams, external interfaces and the screen flow. From November 17 I opened several Claude Code sessions by role (documents, backend, frontend, Deployment) and handed them the implementation. Each session owned its own folders, and the order, payment and admin order PRs went through a code review (/code-review) before the merge. What to build and in which order was my call.

Project timeline diagram. Sep 15 repository created, Sep 22 to Oct 11 HW1 requirement documents, Nov 6 to 9 HW2 design documents, Nov 17 documents restructured and docs-sync, Nov 19 backend implementation, Nov 23 frontend, Nov 27 deployment and CD, Nov 28 SDD feedback applied

2. Requirements and design documents

HW1 and HW2

HW1 (requirements) ran from September 22 to October 11 and HW2 (design) from November 6 to 9. Roles were split by folder (docs/backend/, docs/frontend/). Figures were unified as .drawio.svg (#31): GitHub shows them as images and draw.io edits them as they are, while a plain .drawio shows only as XML on GitHub.

With several people writing at once, the same fact differed between documents. Two were left in #36 as "items to confirm", decided at the October 11 meeting and applied in #41.

  • State after a rejected cancellation. The requirement said to return to the state before the request (PAID or PREPARING), but the schema had no column to store it. We added status_before_cancel, and the final implementation also got the CHECK constraint ck_orders_cancel_request_previous (#104).
  • When stock is deducted. The requirements and the create_order algorithm said at order creation, the table specification said at payment. We chose a single conditional UPDATE inside the order creation transaction (#100).

The HW2 submission was a merged Google Docs file, and putting figures in as PNG took two fixes. draw.io to PNG broke Korean labels, so they became HTML labels (#55), and the screen flow did not fit the two-page limit, so a compressed two-row version was made just for the merged file (#57).

November 17: rewriting as stage documents

Document restructure diagram. Left, old layout: HW1 and HW2 documents scattered across docs/backend, docs/frontend and docs/architecture.md. Right, new layout: six folders under docs/specs: spmp, srs, sdd, stp, sip, smp. The SRS defines DR, FR, NFR and UC IDs, and the SDD, STP, test names and PR bodies cite those IDs

Right before implementation I rewrote the scattered documents into six in docs/specs/ (SPMP, SRS, SDD, STP, SIP, SMP) and gave every requirement an ID (DR-, FR-, NFR-, UC-). It took four PRs in one day.

PRLines changedContent
#59+557 / -10Moved old documents to docs/old/ and created the six document skeletons
#60+554 / -35SRS sections 1~7. DR 24, FR 57, NFR 35, UC 14. Environment changed from "local PC" to EC2 + Cloudflare
#62+2,292 / -51SDD sections 1~10. 9 components, 8 tables, 15 screens. 17 open questions in 11.2
#68+49 / -2,345Deleted docs/old/ (still in git history); only the 14 wireframes moved to docs/images/

#60 had 0 references to IDs outside the scope, and in #62 every FR, NFR, DR and UC was cited at least once with 0 missing IDs. There were three reasons to rewrite.

  • Without IDs there is no traceability. To say which test checks "the order cancellation requirement", the requirement needs a number. So requirements traceability runs through IDs.
  • The environment changed. HW1 said "runs on a local PC only", but once the demo moved to a production server, Deployment and security requirements appeared.
  • Stage documents let each implementation session read only what it needs. Each session started from docs/specs/README.md and opened only its own section.

On terms: in the SRS, a domain requirement (domain requirements) is a business rule such as option prices, shipping fees and order state changes, and a non-functional requirement (non-functional requirements) is a quality such as response time, security and concurrency.

Once the SRS fixes the IDs, everything else cites them, and test function names are the surest link.

RequirementTest functionWhat it checks
NFR-8test_nfr8_token_lifetimesAccess token 1,800 s, refresh token 604,800 s
NFR-9test_nfr9_every_private_route_needs_tokenWalks the whole URL config; a request without a token must get 401
NFR-15test_nfr15_last_stock_concurrent_orders10 concurrent orders for 1 unit: 1 success, 9 get 409
DR-19test_dr19_disallowed_transitions_raise_invalid_stateEvery (action, state) pair outside the allowed table gets INVALID_STATE (409 in the API)

The NFR-9 test walks the URL config itself, so routes added later are covered without editing it (#83). The new routes of the address API (#87) and the admin API (#95, #104) were checked automatically.

When code and documents disagreed during implementation, the document was the one I fixed, and document-only PRs stayed separate from code PRs. #121 (November 27) raised CI/CD, deploy failure handling and the payment-off switch to requirements (FR-60~63, NFR-37~42, UC-15). The HW1 premise "local PC only" had left the SRS without CI/CD requirements, although CI had been running since November 19. #123 aligned the SDD, STP, SIP and SPMP lines that cite the new IDs.

Professor feedback (#129, #130)

There were two points: number every UI part, and add a class and method specification.

  • Section 6 got a 6.x.0 whole screen subsection and 72 part subsections (6.1.1 SCR-01-01 search box) for 16 screens, and 62 of the same ID badges went into the draw.io sources of the 14 wireframes, which were exported again.
  • A new section 12 lists 55 public backend functions, 29 internal functions and 92 classes. A script checked them against def and class in backend/: 0 missing names, 0 signature mismatches.
  • Sections 1~11 kept their numbers, because many other documents point to them by section number.

How documents sync to Google Docs automatically is in Google Docs sync.

3. SQLite concurrent order spike

The biggest risk at design time was the DB. SQLite has only one write lock for the whole file. I could not write the order code without knowing what happens when 10 orders hit a bean with 1 unit left at once.

SQLite transaction mode comparison diagram. DEFERRED starts with a read and, when it tries to upgrade to a write lock after another connection committed first, gets SQLITE_BUSY with no waiting and becomes a 500. IMMEDIATE asks for the write lock at BEGIN, waits up to the 20 second timeout until it is free, then checks stock with a conditional UPDATE, and the loser gets 409

It is committed in spikes/sqlite-concurrent-order/ (#73). It uses the design document's create_order as is: behind 3 gunicorn sync workers, 10 threads send POST /api/orders/ at once. 10 requests per condition, 30 rounds, data reset every round.

Condition201409500Rounds with wrong stockp95 (local)
IMMEDIATE, 300 requests302700041.96 ms
DEFERRED (default), 300--68 (in 29 of the 30 rounds)0not compared

The environment was WSL2 Ubuntu (16 logical CPUs), Python 3.14.4, Django 6.1.1, gunicorn 27.0.1, SQLite 3.46.1. I did not measure on the t3.micro, so p95 is a local value.

  • Stock was right in both modes. What protects stock is the WHERE stock_quantity >= n conditional UPDATE plus rollback, not the transaction mode. That design stays.
  • The DEFERRED 500s cannot be prevented by timeout. If a transaction that started with a read tries to upgrade to a write after another connection committed, SQLite decides waiting is useless and returns SQLITE_BUSY (database is locked) immediately. It came back at once instead of after 20 seconds (server time at most 16.86 ms). That made transaction_mode="IMMEDIATE" a required setting.

4. CI and branch protection

I added CI while there was still no feature code (#77). Even with 0 tests, the format check and the database migration check mean something from the first model PR. The backend job runs black --check, makemigrations --check, tests on in-memory SQLite and a concurrency test on file SQLite; the frontend job runs prettier --check, oxlint, vitest and vite build.

The concurrency test runs separately because connections cannot see the same DB on in-memory SQLite, so test_settings_file.py holds a file-DB setting. It mutated the shared DATABASES dictionary at import time, which broke the in-memory run with KeyError: 'MIRROR'; deepcopy fixed it. CI has no repository secrets and tests run on fake values in config/test_settings.py.

The same day I put branch protection on main.

SettingValue
Required checksbackend, frontend
PR required, approvalsrequired, 0
enforce adminson (admins cannot bypass)
Force push, deletionblocked
strict (up to date with main)off

Approvals are 0 because one person merges alone. Instead, nobody can merge without passing CI.

5. Models, auth, stock, addresses

I dropped HW1's backend/schema.sql and wrote the models fresh from SDD section 5 (#80, +1,623 / -590 lines). With a SQL file and Django models side by side, one of them ends up lying. Every constraint moved into Meta.constraints so the database migration generates it.

SettingValue
DBSQLite, transaction_mode="IMMEDIATE", WAL, timeout=20
Default permissionIsAuthenticated (public APIs opened explicitly)
Response formatJSON renderer only
Throttlinglogin 10/min, sign-up 20/hour
JWTaccess token 30 min, refresh token 7 days
Timezone, localeAsia/Seoul, ko-kr
Django adminattached only when DEBUG is on

The constraint names alone show the rules: uq_user_addresses_one_default (one default address), uq_payments_order_success (one successful payment per order), ck_orders_shipped_fields (tracking fields required once shipped).

Auth (#83) is JWT. The token claims hold only user_id and role. That is enough for the screen to decide whether to show the admin menu, and anyone can decode a token.

  • Login failure has one response. A missing email and a wrong password both give the same 401 INVALID_CREDENTIALS (NFR-7). Different responses would reveal which emails are registered.
  • Sign-up requires privacy consent. Without privacy_agreed it is rejected, and the time goes into privacy_agreed_at (FR-58).
  • A throttling test trap. Changing the limit with override_settings had no effect, because DRF reads THROTTLE_RATES at import time. The test patches ScopedRateThrottle.THROTTLE_RATES directly.
  • Admin accounts cannot be created through the sign-up API. Only on the server, with manage.py create_admin --email ....

The stock service (#85) is five functions: decrease_stock, increase_stock, set_stock, stop_sales, resume_sales. Each is one conditional UPDATE and raises DomainError when 0 rows changed. Addresses (#87) keep "a member with addresses has exactly one default" in two layers: the service clears the old default before setting a new one, and if there are still two, a partial unique index blocks it.

6. Order state changes and order creation

One rule for everything: code that changes state is always a conditional UPDATE, and 0 changed rows means 409. An order moves among seven states.

Order state diagram. From PENDING, payment success goes to PAID and member cancellation to CANCELLED. From PAID, admin prepare goes to PREPARING. From PAID and PREPARING, a member cancel request goes to CANCEL_REQUESTED, saving the earlier state in status_before_cancel. From CANCEL_REQUESTED, admin approval cancels at the PG and goes to CANCELLED, rejection returns to the earlier state. From PREPARING, shipping goes to SHIPPED and delivery to DELIVERED. Any change not in the table is 409 INVALID_STATE
backend/orders/services.py
# When a member cancels a pending-payment order directly
updated = Order.objects.filter(
    pk=order.pk, order_status=OrderStatus.PENDING
).update(order_status=OrderStatus.CANCELLED)
if updated == 0:
    order.refresh_from_db()
    raise invalid_state(order.order_status, "cancel")

With read, check, write as three steps, two concurrent requests can both pass the check. Putting the condition in WHERE makes check and write one statement, so there is no gap. Every admin order change goes through one helper, and test_dr19_... walks every pair outside the allowed table and expects INVALID_STATE (#104). Rejecting a cancellation restores status_before_cancel with an F expression. A CANCEL_REQUESTED row with that column empty cannot exist because of the CHECK constraint, which I added after a review found that rejecting a cancel request with no earlier state returned a 500.

An order is made from the whole cart (#100), in one transaction:

  1. Read the cart under the IMMEDIATE write lock
  2. Check sale status and stock per item, collect all problem cart_item_ids and return them in a 409 (NOT_AVAILABLE or OUT_OF_STOCK). Reporting one at a time makes the customer meet the next problem after every fix
  3. Assign the order number ORD-YYYYMMDD-NNN (a per-day sequence in Seoul time)
  4. Subtract stock per item with decrease_stock; if any fails, roll back everything
  5. Copy product name and price into the order item as a snapshot, so a later price change leaves the order as it was

The concurrency test test_nfr15_last_stock_concurrent_orders encodes the expected values of the section 3 spike. On file SQLite with 10 threads it gave 201 once, 409 nine times, stock 0 and 1 order row in all 3 local runs.

The #100 review produced 8 findings and I fixed all of them. For example, only an order number collision became a 409 RETRY, while other constraint violations stay 500 (folding everything into RETRY hides bugs).

On the product side, the list (#91) is 20 per page, newest first, hides STOPPED, and ANDs the search, origin, price range and roast filters. List and detail share one query function customer_products(), so the "hide stopped products" rule cannot split, and a detail with 3 options takes 2 queries. The seed data command seed_demo (#99) creates 100 beans, 50 members and 500 orders from a fixed seed by default. Orders split 71~72 per state across 7 states, and it took 1.71 s on file SQLite (one measurement). It refuses a DB that already has data and needs --force when DEBUG=False.

7. Payments: measure first, then code

The browser opens the payment window and the server does the payment approval through the Toss Payments API. Writing code without knowing the shape of the approval response or the error for a double cancellation would be guessing, so I ran a spike before any payment code (#92, #105).

Payment flow diagram. The browser starts a payment with POST /api/orders/id/payments/ and the server creates a READY payment row. The browser opens the Toss payment window and, on success, receives paymentKey, orderId and amount at successUrl. The browser sends POST /api/payments/confirm/, the server compares the amount with the start amount and only if equal calls the Toss confirm API outside the transaction. If status is DONE the payment is SUCCESS and the order PAID. If the amount differs it does not call the PG, closes the payment as CANCELLED and returns 409 PAYMENT_MISMATCH

I measured with two test payments (1,000 won each). The 9 raw calls, with paymentKey masked, are in spikes/toss-confirm-cancel/results/calls.jsonl.

StepCheckResult
2Approval200 DONE, method: "간편결제", +09:00 in approvedAt (1,313 ms / 551 ms)
3Full cancel, second cancel with another key200 CANCELED (585 ms); second one 400 ALREADY_CANCELED_PAYMENT (215 ms)
4Approve with an amount different from the window403 FORBIDDEN_REQUEST (211 ms). The payment stays and can be approved again with the right amount
5Close the payment window with XDoes not go to failUrl; requestPayment() fails with USER_CANCEL (both runs)
6Approve a payment older than 10 minutesNot measured
7Cancel twice with the same Idempotency-KeyBoth 200, same body (616 ms / 89 ms). Only 1 cancellation
  • Step 4 changed the design. It used to be "approve, then cancel at the PG if the amount differs", but Toss rejects approving a different amount with 403, so that path is never reached. Now, if the confirm request's amount differs from the amount at payment start, the server does not call the PG, closes the payment as CANCELLED and returns 409 PAYMENT_MISMATCH (#105). The cancel-after-approval path stays as a guard for a PG reporting a different totalAmount.
  • Step 7 set the order of cancellation approval. Resending with the same idempotency key (cancel-<payment_id>) returns the first result, so cancelling at the PG first and changing the DB after is safe to resend if the request breaks midway.
  • Step 5 became a screen rule. Watching only failUrl misses the window close, so the screen receives the requestPayment() error directly (section 8).
  • Step 6 stays open in the documents as the assumption "per public docs, approval fails after 10 minutes".

The payment code (#102) follows three rules.

  • The only code that calls Toss is TossPaymentsClient in orders/pg.py; tests use FakePaymentsClient.
  • PG calls happen outside the DB transaction. An external call can take up to the 10 s timeout, and holding the SQLite write lock that long would stall every other order.
  • Only Toss status == "DONE" counts as approved. A timeout, a 5xx, a non-JSON response or a dropped connection leaves the payment READY and returns 502 PG_ERROR.

The #102 review gave 8 findings, and for each fix I first added a regression test that fails on the old code. The heaviest was that a new payment attempt replacing a payment under approval could make the order PAID with no successful payment.

8. Frontend screens

The flow came from the wireframes (HW1) and the look from a design canvas (BeanShop UI, 18 frames), then five PRs (#111, #113, #115, #117, #119) built the screens in one day, November 23. The principle was the screen does not decide. Which buttons to show and whether paying again is allowed come in the server response, and the screen draws them as given.

AreaChoiceReason
UIReact 19, React Router 718 routes set in one route table, wrapped in RequireAuth and RequireAdmin
StyleTailwind CSS 4, theme tokensMoving the canvas colors and spacing into tokens avoids rewriting values per screen
HTTPOne axios instanceToken attach and refresh live in one file, api/client.js (NFR-31)
Checksvitest, Testing Library, oxlint, prettierThe CI frontend job runs them as they are

Admin screens are split with lazy loading (React.lazy) because customers do not need to download them. #113~#119 were checked against a local backend.

Token refresh: once, and everyone waits

An access token expires in 30 minutes. If the screen calls three APIs at once with an expired token, all three get 401, and if each sends its own refresh token, the refresh goes out three times.

Token refresh diagram. Requests A, B and C all get 401 at once. The first sends POST /api/auth/token/refresh/ through refreshAccess() and keeps that Promise in the refreshing variable. B and C wait for the same Promise. When the new access token arrives, all three get a _retried mark and are resent once. If the refresh fails, the tokens are cleared and the user goes to /login?next=

The response interceptor in api/client.js works like this.

  • On a 401, if the request is not already a retry (_retried) and is not itself a login or refresh request, it tries to refresh
  • If a refresh is in progress it waits on that Promise, otherwise it creates one, and clears it when done
  • It resends the original request with the new token once; _retried prevents infinite loops
  • If there is no refresh token or the refresh fails, it clears the tokens and goes to /login?next=<current path>

Only one file reads and writes the token keys: auth/tokenStore.js. The role inside the token only decides whether to show the admin menu; the real block is the server rechecking the role in the DB on every admin request and returning 403 (NFR-10).

Checkout and payment screens

The payment window sends the browser to another page and back, and a person can close it midway.

Checkout screen flow diagram. The first click creates an order with POST /api/orders/, starts the payment right away and opens the Toss payment window. From the second click on, only the payment is reopened for the existing order. When the window returns to successUrl, /checkout/result sends confirm exactly once. PG_ERROR shows a re-check button, PAYMENT_MISMATCH a failure notice. Closing the window makes requestPayment() fail with USER_CANCEL and the checkout screen shows a cancellation notice; a failure returned through failUrl is recorded by the result screen through the fail API. The order can be paid again from its detail screen
  • First click creates the order and opens the window; later clicks only pay. If every reopen after closing the window made a new order, stock would stay locked for each one (#115).
  • Confirm only once. /checkout/result sends the confirm request once with useRef, even though StrictMode runs effects twice in development. The server confirm API is idempotent, so two calls would not break anything, but this keeps the result from flashing twice.
  • A slow PG and a failure are told apart. 502 PG_ERROR shows a "check again" button, 409 PAYMENT_MISMATCH a failure notice.
  • Closing the window arrives as an error. As step 5 in section 7 showed, lib/pay.js receives the USER_CANCEL error directly and shows "Payment cancelled." Only a failure returned through failUrl is recorded by the result screen at /api/payments/fail/.

Buttons are also decided by the server. The cancel, cancel request and pay again buttons on my order detail follow the can_* values of the response, and the prepare, ship, delivered, approve cancel and reject buttons on the admin order detail show only what is in allowed_actions (#119). If the screen kept its own state table, the backend changing a transition rule would put wrong buttons on it. Even then, a button pressed on a stale screen ends in 409 at the server's conditional UPDATE.

Production has payments off (section 9), so I checked #115 in that state. Pressing pay shows a 503 PAYMENTS_DISABLED notice, and the order stays payable later from its detail screen. The real Toss payment window has never been opened from this frontend. Confirm, failure and repay flows were checked only with fake responses in vitest.

9. A deployment that can roll back

The server starts even without a key (#108)

This project had no Toss test key of its own yet. If the server could not start without a key, the whole shop would hang on payments. So an empty TOSS_SECRET_KEY makes PAYMENTS_ENABLED false. Payment start, confirm and admin cancel approval stop with 503 PAYMENTS_DISABLED before touching the PG or DB, and everything else keeps running. The kill switch is decided by whether a key exists, not by a code path.

For dangerous settings it is the opposite: the server refuses to start (config/checks.py). DEBUG off with an empty ALLOWED_HOSTS refuses to start, and so does a TOSS_SECRET_KEY that does not start with test_, which stops a live key from moving real money at startup. All 6 new tests were confirmed to fail on the code before the change.

deploy.sh

Deploy script diagram. Under /srv/coffee-shop/releases there is one folder per tag. deploy.sh clones the new tag into a new folder and checks it is an ancestor of main, runs venv and pip install, the frontend build and version.txt, a pre-deploy DB backup and migrate, then switches the current symbolic link to the new folder. If the health check and version.txt match it is done; otherwise current goes back to the previous folder. The DB and .env live outside the release folders

deploy/deploy.sh release-YYYYMMDD-N takes one release tag, builds it in a new folder, and moves the current symbolic link only if the health check passes.

  1. Check the tag format (wrong format exits with code 2); stop if .env is missing
  2. Clone the tag into releases/<tag>/ and check the commit is an ancestor of main (otherwise delete and stop)
  3. Backend venv and pip install, frontend npm ci and build. The build gets a version.txt holding the commit hash
  4. Pre-deploy database backup, then migrate
  5. Create current.new and swap it with current using mv -T (the switch happens at once)
  6. Check that /api/health/ and the version.txt served by nginx match this commit. On failure, put current back on the previous release and, if the DB needs restoring, print the backup path
  7. Keep only the 3 most recent releases

The DB file and .env live outside the release folders (/srv/coffee-shop/data/, /srv/coffee-shop/.env), so switching the link leaves them untouched. The same PR added an nginx config template, security headers, a log format that drops query strings, a script that trusts CF-Connecting-IP only from Cloudflare address ranges, systemd units (the app and a daily 04:00 backup timer), a journald size limit and install.sh for first setup.

Rehearsal (#125)

The shell scripts in #108 had only passed bash -n. Before production I did a dry run in an Ubuntu 24.04 container with only systemctl faked.

CaseResult
First deployment54 s, health 200
Tag whose health check failsRolled back to previous (rc 1)
Tag whose migrate failscurrent unchanged (rc 1)
Tag not on maincurrent unchanged (rc 1)
Malformed tagExit code 2
ShellCheck -S warning0 warnings

It caught three bugs. The four scripts in deploy/ were committed as 100644, so I set the executable bit. The first deployment has no current, so reading the previous release with readlink returned the link path itself, and a failed first deployment left current pointing at itself (readlink -e returns empty when there is no target). gunicorn 27 opens a control socket in $HOME, but the app runs as a system account with no home folder, so control_socket_disable = True turned it off.

First production deployment

On 2026-11-27 the operator logged in over SSH and deployed by hand: tag release-20261127-1 (commit f87bffb), 29 s, health 200. From outside I checked the HTTP to HTTPS 301, the health check, the 404 JSON for an unknown API path, the security headers and version.txt. Demo data went in with seed_demo: 100 beans, 50 members, 500 orders (--force, since DEBUG is off on that DB). The server address, domain and accounts appear neither in the repository nor in this post.

10. Continuous deployment (CD)

Since #127, merging into main is the only human step.

Auto deploy diagram. A push to main runs the ci workflow, and on success the deploy workflow starts through workflow_run. It continues only when DEPLOY_ENABLED is true. It picks the next release-YYYYMMDD-N tag, gets an IAM role through GitHub OIDC and pushes the tag. SSM Run Command (AWS-RunShellScript) runs deploy.sh with the tag on EC2 and prints the result. Finally it reads version.txt through Cloudflare and checks it equals the commit. Port 22 is not opened to GitHub; the SSM agent uses outbound 443

The rules of .github/workflows/deploy.yml:

  • When it runs. When ci succeeds on a main push (workflow_run), or manually. An automatic run is skipped if the commit is no longer the tip of main, if it already has a release tag, or if only documents changed since the last tag.
  • Credentials first, tag after. If the IAM role cannot be obtained, no tag is left behind.
  • SSM, not SSH. Port 22 is not opened to the GitHub Actions runner. The server's SSM agent opens outbound 443 and fetches commands. The role may only ssm:SendCommand with AWS-RunShellScript to that one instance for requests from this repository's main, and read results.
  • One at a time. concurrency: deploy-production, cancel-in-progress: false. A deploy must not be cut off midway, so the next run waits.
  • No long-lived secret. The three Actions secrets (role ARN, instance ID, production URL) are identifiers, not secrets; they sit in secrets only so the public repository's logs mask them.
  • Off by default. It runs only when the repository variable DEPLOY_ENABLED is true, so merging before the AWS setup does nothing.

I ran the tag-picking shell in a temporary repository for five cases: first deployment, a ci rerun, only documents changed, the number after -10, and a manual run on a commit that already has a tag. The AWS side runs only once its setup is done.

The four manage.py check --deploy warnings (SECURE_HSTS_SECONDS, SECURE_SSL_REDIRECT, SESSION_COOKIE_SECURE, CSRF_COOKIE_SECURE) stay because Cloudflare does the HTTP to HTTPS switch now, and whether to turn it on in Django too is not decided.

11. Numbers and current state

As of 2026-11-28. Sources: the repository's main (git rev-list, git grep) and GitHub (gh pr list, gh run list).

ItemValue
PeriodFirst commit 2026-09-15 ~ last merge 2026-11-28
Commits on main65 (1 initial commit + 64 PR squash merges)
Merged PRs64. Two more were closed without merging
Commit authorsseren-wib 53, Heisnotanimposter 6, Yang-HA-03 6
Requirement IDsDR-1~24, FR-1~63, NFR-1~43, UC-1~15
Backend test functions231 (def test_)
Frontend tests113 (vitest, 22 files)
Main JS bundle379 kB (gzip 118 kB), admin screens split out (FE session notes, 2026-11-23)
ci runs64: 62 succeeded, 2 cancelled (by a newer push to the same branch)
docs-sync runs33: 23 succeeded, 10 cancelled
deploy runs3, all skipped (no DEPLOY_ENABLED)
First production deployment2026-11-27 by hand, 29 s, health 200. Production is up on release-20261127-1
PaymentsOff (no key of its own). The pay button shows a 503 notice
Left for automatic deploymentAWS OIDC provider, deploy role, instance role attachment, Actions secrets, DEPLOY_ENABLED=true
Not measuredResponse time p95 (NFR-1), first screen in 2 s (NFR-2), recovery after reboot, backup restore, production rollback rehearsal
check --deploy4 warnings, 0 errors

The unmeasured items only have a placeholder "to be measured" in section 9 of the STP. The six stage documents are in the repository's docs/specs/, and the repository is the source.

12. Reflection

Had I numbered the requirements in HW1, the November 17 rewrite would have been little more than moving things.