Backend systems & production engineering

Vouchers

A full-stack voucher platform built around a Laravel backend and a separate TypeScript client, designed to demonstrate API structure, database modelling, automated testing and production deployment.

LaravelTypeScriptMySQLDocker

Overview

Vouchers separates a Laravel backend from a TypeScript client. The backend owns voucher and order state, while authenticated API endpoints allow the client to retrieve a voucher by QR code and request redemption.

Architecture and application boundaries

The API routes use auth:api middleware for voucher lookup and redemption. The controller queries orders through Order::toMe(), loads related voucher, product and payment data, and returns an OrderResource. Database models represent persistent state; JSON resources define the response boundary seen by the client.

Implementation and validation

GET /api/vouchers/{qr_code} retrieves an order; POST /api/vouchers/{qr_code}/pay performs redemption checks. Before changing state, the controller rejects unpaid, expired or already used orders. A successful operation calls the order payment method and dispatches VoucherWasReleased. These are server-side decisions rather than client-only checks.

Engineering decisions and trade-offs

Keeping redemption rules in the backend gives separate clients a shared decision point. Resource serialization keeps response shape distinct from model storage. The inspected controller performs sequential state checks; this alone does not prove protection against concurrent redemption requests. Concurrency guarantees require a separate transaction and locking review.

Testing and deployment

Feature tests use RefreshDatabase and factories to check missing orders, JSON response shape, persisted used_at values and rejection of unpaid, expired and used vouchers. Model tests check merchant filtering. These tests were inspected, not executed as part of this portfolio change. Deployment evidence describes Caddy → Nginx → PHP-FPM → Laravel with MySQL in a persistent volume.

Outcomes and limitations

The source provides concrete examples of backend validation, API serialization and database assertions. Deployment HTTP checks demonstrate service reachability, not complete authenticated workflow correctness. The deployment document identifies legacy runtime upgrades and regression testing after dependency removal as follow-up work.

Source evidence