Cash register solution: one core, three adapters (CLI, API, React UI)#107
Open
kenruizinoue wants to merge 40 commits into
Open
Cash register solution: one core, three adapters (CLI, API, React UI)#107kenruizinoue wants to merge 40 commits into
kenruizinoue wants to merge 40 commits into
Conversation
…demands Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…commands Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…CLAUDE.md Python package skeleton with pytest and ruff wiring under backend/, AI process docs scaffolded, plan updated. CLAUDE.md now requires explicit approval before any implementation commit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
GitHub Actions runs ruff and pytest from backend/ on push and PR to main, with least-privilege permissions, concurrency cancellation, timeout, and pip caching. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Strict owed,paid line parser producing integer cents via Decimal, domain error and transaction types, 40 parser tests covering malformed and boundary inputs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Self-validating Currency and Denomination types with USD default, greedy minimum change, underpayment domain error, euro table test proving configurability. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ChangePolicy selects random strategy when owed cents divide by the configured divisor, minimum otherwise. Random strategy proven exact over a 20-seed by 13-amount matrix; minimum path proven random-free via a failing fake rng. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
format_change renders counts largest-first with per-denomination plurals and a shared no-change sentinel; process_transaction composes policy and formatting. README samples asserted byte for byte. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
process_line converts domain failures into a consistent error line format, process_text maps non-blank input lines to output lines, process_file round-trips files. README random line asserted to sum exactly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
argparse adapter with divisor and seed flags, exit codes 0/1/2 for success, I/O failure, and usage or config errors. Both python -m and cash-register entry points verified against the README sample. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Both strategies proven to return bills via fake random sources; README behavior under five dollars unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Audit found and fixed three real gaps: non-ASCII digits passing the amount regex (re.ASCII), CLI traceback on non-UTF-8 input (clean exit 1), and missing negative-amount guards in both strategies. 12 audit tests added, 393 green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
fastapi/uvicorn/httpx2 gated behind the api extra, health route with TestClient smoke test, importorskip keeps core-only installs clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ChangeRequest with forbidden extras, size cap, literal currency, validated divisor; LineResult/ChangeResponse per-line envelope pre-shaping structured errors. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Handler validates, configures policy, delegates line by line, and translates results; endpoint output proven equal to the core processor under the same seed. Invalid shapes 422 before any core call; models documented in OpenAPI. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Mixed and all-invalid batches return 200 with line-number/input/message entries; blank payload lines are explicit errors; shape problems stay 422. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
CURRENCIES registry, USD|EUR request literal mapped into ChangePolicy, euro coins and five through hundred euro notes, both strategies proven to return notes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Setup, uvicorn run, and curl example with the real seeded response; commands executed live before documenting. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
11 audit tests covering batch caps, seed shapes, transport errors, and hostile line content found no defects. CLI gains --currency with choices from the CURRENCIES registry at human direction. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
React TS Vite in frontend/ reworked to the standard: ESLint flat config over template oxlint, single styles.css, jsdom vitest with jest-dom setup, @/ alias, dev proxy to the FastAPI port, smoke render test. Proxy verified live end to end. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
npm ci, lint, test, build on push and PR to main with least-privilege permissions, concurrency cancellation, timeout, and npm caching. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Types mirror the API contract in camelCase, gateway interface and typed GatewayError keep screens free of adapter internals. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…lidation Stubbed-fetch tests cover wire format, config permutations, and every failure mode; a type guard validates each results entry so unknown shapes become GatewayError. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Textarea plus file pick submitting through the ChangeGateway prop, per-line results table with error rows, alert on gateway failure. user-event dependency correctly scoped to frontend after a stray root install was caught in review. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Hook owns input state, double-submit guard, and failure translation; screen reduced to composition with all prior screen tests passing unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
toLines and resultText unit tested; hook and screen swapped to use them with prior suites passing unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Cashier and Flat File tabs with side-by-side output panel, tappable payment grid built on one shared DenominationToken used for buttons and output tokens, snackbar payment notices with overpayment flag, payment lock once paid covers owed, per-line errors and empty state in output. Supersedes the ticket 20 screen. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Global form-control styling with focus-visible outlines, output line wrapping, snackbar stacking and width bounds, reduced-motion support, narrow-viewport spacing. CSS only, all 108 tests unchanged and green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Three Chromium specs with the API mocked at the network layer: flat file sample flow with token assertions, cashier tap-and-calculate, per-line error rows. Dedicated-port webServer config and a frontend CI e2e job. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tence Route abort surfaces the failure alert, payment notice dismisses on real timers, results survive tab switches. 6 Playwright specs green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Four cashier state-boundary regression tests added (notice replacement, lock after late owed entry, unlock on raised owed, zero-owed submission). 112 unit tests, 6 e2e specs, lint, and build green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
README solution sections for all phases with submission-docs links, ARCHITECTURE.md with boundaries and extension points, self-critique transcribed from author answers, logs verified against history with the transcript export flagged as the one open gap. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Drop the paid-exceeds-owed suffix at author direction; grid lock behavior unchanged, tests rewritten red-first. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Native JSONL session log copied verbatim, TRANSCRIPT.md documents format and the pre-delivery refresh step, README links the export. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was built
One core, three adapters. The change-making business logic lives in a single Python package; a CLI, a FastAPI service, and a React UI are thin adapters over it. Minimum change by default, random (but exact) denominations when the owed amount divides by 3, with the divisor, special-case strategies, and currency tables (USD and EUR ship) all configurable.
How to run
Setup, run, test, and usage for each phase are in the README: Phase 1 core + CLI, Phase 2 HTTP API, Phase 3 web UI.
Tests and CI
447 backend tests, 112 frontend unit tests, 6 Playwright e2e specs. Backend and Frontend GitHub Actions workflows (lint, tests, build, e2e) are green on every commit of this branch.
AI process documentation
The client-requested documentation is in docs/ai/: full raw session transcript, per-ticket decision log (AI output used, modified, rejected), verification log, tools and task mapping, and the author's self-critique.
🤖 Generated with Claude Code