# Modern CardDemo Autonomous best-effort modernization of AWS CardDemo from COBOL/CICS/VSAM/JCL into a small Python web/API application. ## What This Preserves - The original AWS CardDemo source clone is preserved at `../source`. - Seed data is loaded from the original ASCII/EBCDIC files under `../source/app/data`. - Fixed-width layouts are derived from CardDemo copybooks for customer, account, card, card xref, transaction, transaction type, transaction category, and user security records. - The old system remains the behavioral oracle where it can be exercised. This lab does not require human approval; unresolved behavior becomes an assumption or gap receipt. ## Modern Target - Standard-library Python 3 application. - SQLite persistence. - JSON API plus browser UI. - No external package install required. - Batch/report parity surfaces for `TRANREPT`, `CREASTMT`, `INTCALC`, and `COMBTRAN`. - Batch resource setup/control parity metadata for `DEFGDGB`, `DEFGDGD`, `ESDSRRDS`, `TRANIDX`, `CLOSEFIL`, and `OPENFIL`. - Signon, regular/admin menu routing, and SQLite-backed user security maintenance for `CC00`, `CM00`, `CA00`, `CU01`, `CU02`, and `CU03`. - Transaction type maintenance for `CTTU`, including type-code validation, update/insert, no-change rejection, and guarded delete. - MQ request/reply parity surfaces for `CDRD` and `CDRA`, including source-shaped 1000-byte message metadata, system date/time reply formatting, and account inquiry over `ACCTDAT`. - Pending authorization IMS/DB2/MQ parity surfaces for `CPVS`, `CPVD`, `CP00`, and `CBPAUP0J`, seeded from the original `DBPAUTP0` IMS unload. ## Run ```powershell cd D:\scraper_storage\modernization_labs\aws-carddemo-modernization-20260523T073000Z\modern_carddemo python -m carddemo.cli init-db --source-root ..\source --db-path .\carddemo.sqlite python -m carddemo.cli serve --source-root ..\source --db-path .\carddemo.sqlite --port 8087 ``` Open `http://127.0.0.1:8087`. ## Test And Receipts ```powershell python -m unittest discover -s tests python tools\generate_receipts.py --source-root ..\source --db-path .\carddemo.sqlite --out-dir .\reports python tools\replay_static_oracles.py --source-root ..\source --out-dir .\reports ``` Receipt and replay generation write the capability-parity proof pack: - `reports/capability_ledger.json`: every discovered AWS CardDemo online and batch capability with source refs and proof grade. - `reports/golden_traces.json`: deterministic service traces backed by legacy seed files or explicit inferred rules. - `reports/edge_cases.json`: data- and copybook-derived edge cases to drive future parity closure. - `reports/next_gap_ranking.json`: autonomous next-work queue, sorted by gap severity and capability priority. - `reports/static_oracle_replay.json`: executable modern-service replay over the static/source-oracle trace pack, using a scratch SQLite database. Proof grades are `A` for actual legacy runtime trace match, `B` for static legacy data/copybook oracle match, `C` for implemented or inferred without strict parity proof, and `F` for discovered capability gaps. ## Added Batch/API Surfaces - `GET /api/reports/transactions`: seed-data transaction detail report following the legacy `TRANREPT` joins and date filter shape. - `GET /api/statements/{account_id}`: account statement text/HTML payload following the `CREASTMT` account, customer, card, transaction source sort, 80-byte statement line, and total-expense flow. - `GET /api/interest-projection`: `INTCALC` formula preview using `TCATBALF` and `DISCGRP` seed files. - `GET /api/batch/combined-transactions`: `COMBTRAN`-style concatenation of `TRANSACT.BKUP(0)` and `SYSTRAN(0)`, ascending `TRAN-ID` sort, `TRANSACT.COMBINED(+1)` output metadata, and transaction KSDS REPRO target metadata. - `GET /api/batch/transaction-master-backup`: `TRANBKP`-style transaction master backup/redefine metadata, including `REPROC` source/backup datasets, IDCAMS delete targets, 350-byte KSDS record size, and 16-byte transaction-id key contract. - `GET /api/batch/transaction-type-extract`: `TRANEXTR`-style `DSNTIAUL` extract for transaction type/category reference files, including backup/output datasets, ordered 60-byte records, and zero-fill suffixes. - `GET /api/batch/db2-reference-setup`: `CREADB21`-style Db2 transaction reference setup, including free-plan/create/load step order, database/tablespace/table/index/grant metadata, load counts, and category-to-type restrict-delete foreign key. - `GET /api/batch/resource-setup`: setup/control metadata for `DEFGDGB`, `DEFGDGD`, `ESDSRRDS`, `TRANIDX`, `CLOSEFIL`, and `OPENFIL`; pass `job=` for one source job. - `GET`/`POST /api/mq/system-date`: `CDRD`/`CODATE01` MQ request/reply model that returns `SYSTEM DATE : MM-DD-YYYY` and `SYSTEM TIME : HH:MM:SS` using the source reply labels. - `GET`/`POST /api/mq/account-inquiry`: `CDRA`/`COACCT01` MQ request/reply model for `INQA` plus an 11-digit account key, returning labeled `ACCTDAT` account fields or the source-shaped invalid-parameters reply. - `GET /api/pending-authorizations/summary`: `CPVS` pending authorization summary and five-row page flow over decoded `PAUTSUM0`/`PAUTDTL1` IMS unload records. - `GET /api/pending-authorizations/detail`: `CPVD` pending authorization detail lookup by source-shaped authorization key or transaction id. - `POST /api/pending-authorizations/process`: `CP00` authorization request processing with comma-delimited MQ request shape, available-credit decision, response CSV, summary update/insert, and detail insert. - `POST /api/pending-authorizations/fraud`: `CPVD`/`COPAUS2C` fraud mark/remove flow with `AUTHFRDS` shadow-table write. - `POST /api/batch/purge-authorizations`: `CBPAUP0J`/`CBPAUP0C` expired authorization purge using the reverse-date `PA-AUTH-DATE-9C` calculation and summary counter adjustment. - `PATCH /api/accounts/{account_id}`: `CAUP` account update flow with account/xref lookup, Y/N status validation, signed money/date validation, no-change rejection, and account/customer SQLite rewrites. - `GET /api/cards/{card_number}` and `PATCH /api/cards/{card_number}`: `CCDL`/`CCUP` card detail and update flow with account/card key validation, alphabetic embossed names, Y/N status, expiry month/year validation, no-change rejection, hidden-field preservation, and card SQLite rewrites. - `POST /api/transactions`: `CT02` transaction-add flow with account/card xref lookup, confirmation, signed amount/date/merchant validation, transaction-id increment, and `TRANSACT` write without account-balance mutation. - `GET /api/transaction-types`: `CTLI` transaction type list view with source-shaped seven-row cursor paging, forward/backward navigation, exact type-code filtering, and `LIKE` description filtering. - `POST /api/transaction-types`, `PATCH /api/transaction-types/{type_code}`, and `DELETE /api/transaction-types/{type_code}`: `CTTU` transaction type maintenance with two-digit numeric nonzero type codes, required alphanumeric descriptions, no-change rejection, update-or-insert behavior, and child-record delete protection. - `POST /api/batch/transaction-types`: `MNTTRDB2`/`COBTUPDT` batch transaction type maintenance over fixed `INPFILE` records, including `A` add, `U` update, `D` delete, `*` comment handling, return-code 4 error reporting, duplicate/missing-row SQL outcomes, and Db2 restrict-delete behavior. - `POST /api/post-transactions`: `POSTTRAN`-style batch posting with card/account lookup, overlimit rejection, expiration rejection, category-balance update, and account cycle update. - `POST /api/signon`: `CC00` signon over decoded `USRSEC`, including uppercase credential normalization and admin/user menu routing. - `GET /api/menu/main` and `GET /api/menu/admin`: `CM00` and `CA00` menu option surfaces transcribed from the legacy menu copybooks/source. - `POST /api/users`, `PATCH /api/users/{user_id}`, and `DELETE /api/users/{user_id}`: `CU01`, `CU02`, and `CU03` user maintenance flows over the modern SQLite user table, including source-shaped blank-field, duplicate, no-change, not-found, and non-admin user-type behavior. ## Current Claim Limit This is not claimed to be a proven production-equivalent replacement. It is a runnable modern target with seed-data parity checks, source fingerprints, tests, capability proof grades, gap ranking, and executable modern-service replay over static/source-oracle traces. Runtime parity against the original COBOL/CICS execution remains a gap unless a compatible mainframe or emulator harness is attached.