Welcome to Google Brew, a modern, real-time coffee loyalty and rewards platform built in 10 minutes as a showcase for the Build the Next series.
This repository demonstrates a complete transition from the outer loop (spec-driven backend generation) to the inner loop (IDE development, component refactoring, and integration fixes).
- API Specifications: We first defined the system requirements in
api-design.json:- Customers earn 1 point for every $1 spent
- Free coffee rewards unlock at 50 points
- Premium Gold tier unlocks at 200 points
- Anti-Fraud limits: Maximum of 3 redemptions per day per customer
- Interactive rewards dashboard required
- Backend Scaffolding: We used Antigravity-CLI to automatically generate a Node.js Express server matching the JSON specifications.
- Frontend Development: The frontend was built using Antigravity IDE to quickly spin up a themed dashboard, connecting the static visual layout to the generated API endpoints.
- IDE Refactoring: We transitioned to inner-loop optimization, modularizing the frontend from a monolithic structure in
App.jsxinto self-contained sub-components undersrc/components/.
- Express.js: Provides the main API routing layer.
- In-Memory Store: Since this project was designed as a rapid demo, the server-side transactional locking rules (to guard against promotion race conditions) are simulated using an in-memory memory store state (
store.js) rather than a heavy persistent database. - Public API Access: The original
api-design.jsonspecified JWT token authentication headers. To support quick public testing and dashboard simulation for the demo web layout, the active API routes operate as public endpoints.
- React + Vite: High-speed frontend build tooling.
- Vanilla CSS Layout: A dark, premium espresso coffee theme designed with HSL color tokens, glassmorphism card layouts, interactive elements, custom scrollbars, and fluid animations.
- Modular Components:
Header: Navigation logo and backend health/connection state checks.CustomerSwitcher: Swaps between active customer accounts.CustomerProfile: Renders profile details, a points circle meter progress gauge, and daily limit indicator dots.CashierSimulator: Allows cashier simulation to record purchases ($1 = 1 point) and log instant scores.RewardsCatalog: A tabbed view of available rewards coupons versus redeemed history.ToastContainer: Controls floating notifications and system confirmations.AntiFraudModal: Shows dialog warnings when velocity limits are hit.
Follow these instructions to run both the frontend and backend servers.
cd backend
npm install
npm run devThe API server will listen on http://localhost:3000/.
cd frontend
npm install
npm run devOpen your browser and navigate to http://localhost:5173/. The frontend is configured to call http://localhost:3000 directly. This cross-origin communication is permitted because the backend Express server (server.js) explicitly sends CORS headers (Access-Control-Allow-Origin: *) during development.
A multi-stage Dockerfile is included at the root of the project to bundle the built React frontend and serve it from the Express backend in production.
This application is designed to be deployed directly to Google Cloud Run.
You can build and deploy the containerized application to Cloud Run with a single command:
gcloud run deploy coffee-brew \
--source . \
--port 3000 \
--allow-unauthenticatedAlternatively, you can build the image with Cloud Builds and deploy:
# Build the image in the cloud
gcloud builds submit --tag gcr.io/YOUR_PROJECT_ID/coffee-brew .
# Deploy the image to Cloud Run
gcloud run deploy coffee-brew \
--image gcr.io/YOUR_PROJECT_ID/coffee-brew \
--port 3000 \
--allow-unauthenticated