AWS Builder Center
Weekend Showcase Challenge: Midnight City Dusk till Dawn

Weekend Showcase Challenge: Midnight City Dusk till Dawn

This is the Summer Showcase entry for Midnight City — a neon browser racer whose garage agent paints a new car every night using Amazon Bedrock and EventBridge. If you followed the Weekend Creative Challenge and Weekend Creative Agent Challenge articles, this is the victory lap: same city, more finished

FOSS Enthusiast, Linux User, Cyber Sec <3

What's New Since the Last Article

The agent was already running — Tonight's Build has been generating a new livery and track mood every midnight IST since the agent challenge. This showcase week was about making the game feel complete around it:
  • Fog density goes live. The agent writes a  fogDensity  value between 0 and 1 into DynamoDB every night as part of the track mood. It was sitting there unused. Now it directly drives the Three.js  FogExp2  density when the garage loads  /today  — so "Heavy fog rolling in from the harbour" actually looks like heavy fog, and "Clear night, full moon" looks open. The city literally looks different depending on which night you play.
  • The race has an ending. After three laps the game freezes input and shows a finish screen: final race position (P1 through P11), fastest lap time, and top speed in km/h. A Race Again button resets everything. Previously the game just looped forever — fine for practice, not for a race.
  • NPC name plates. The ten racers — KAI, REX, NOVA, ECHO, VOSS, PIKE, ZARA, DUSK, RUNE, COLT — already had names and commentary. Now they wear them: HTML labels project from 3D world space to screen coordinates each frame and appear above any car within ~100 units of the player. You finally know who just overtook you.



Vision & What It Does

Midnight City Dusk till Dawn is a browser arcade racer with a secret. The game is a neon street circuit — a closed loop you drive in a low-slung coupe under artificial light, chasing ten named opponents, watching your lap time tick on the HUD. That part is instant. Load the page, pick a paint scheme in the garage, tap Drop In, and you are racing.
The secret is what happens at midnight IST while you are not there. An EventBridge cron fires at 18:30 UTC, wakes a Lambda, and asks Amazon Bedrock Nova Micro for two things: tonight's car livery and tonight's track mood. Name, tagline, hex colors, rim finish, spoiler on or off — the whole package. And a weather condition: fog density, a sky tint, an ambient light tweak, a one-line atmosphere label. Nova Micro writes it all as compact JSON. The Lambda strips any markdown, sanitizes the fields, and writes a single  pk = "today"  item in DynamoDB. Then it goes back to sleep.
When you open the garage the next day, Tonight's Build is waiting. Click it and the agent's car drops onto the mesh. The paint job it designed while you were asleep. Track condition appears on the race HUD — "Harbour Fog," "Frost on the Kerbs," "Clear Moon" — and if the agent sent a fog density value, the Three.js  FogExp2  density adjusts to match. The city literally looks different depending on which night you play.
That is the idea: generative AI as a clock, not a button. You do nothing. The circuit keeps working.
The rest of the game grew up around that core. Ten named racers — KAI, REX, NOVA, ECHO, VOSS, PIKE, ZARA, DUSK, RUNE, COLT — sit on the circuit with their own speed tiers, drafting behavior, and lap tracking. Race position is live on the HUD every frame. Commentary knows who you overtook, who got you back, what lap you are on, and how fast you were going: "Past ZARA! P4 now. Eyes forward." A minimap in the top-right corner tracks the whole field. Mobile players get a virtual joystick and GAS / BRAKE pedals so the phone is actually playable. After three laps the race ends cleanly — final position, fastest lap, top speed, and a Race Again button.



How You Built It

This project has three layers, built across three weeks, and each one reused the skeleton of the last.
The pattern started with WeekAhead. That first project established the template: AWS CDK monorepo, Vite frontend, Lambda + API Gateway HTTP API, S3 + CloudFront distribution, Bedrock Nova Micro behind a function that can never take down the UI. Once that CDK stack existed and the GitHub Actions workflow was running, every subsequent project started from a fork rather than a blank file.
Then came Midnight City itself. I wanted to build a Three.js racer — not a demo, an actual game you would spend five minutes with. That meant real arcade physics: throttle, drag coefficient, braking, passive coast, a steering rate that changes with speed. It meant a procedural track built on a CatmullRom spline, sampled every meter so the constraint system could keep the car on the road. A chase camera that sits high and a fraction of a second late, looking past the hood into the next bend. Procedural buildings on both sides of the circuit, street lamps with real point lights, a sky sphere with a painted gradient texture. The city needed to feel like a real city at night, not a tech demo. The car needed to feel like a car, not a box sliding on ice.
Traffic was the next step. Dropping ten NPC racers onto the same circuit required gap logic — racers just ahead slow slightly to stay raceable, racers behind push harder to close — and NPC-to-NPC draft detection so they did not stack up. Speed tiers from 70% to 105% of player max made the field spread out naturally. Commentary that could name the opponent and quote your position made each pass feel like something that mattered.
The agent layer came last. I added a DynamoDB table, an EventBridge cron, and a new Lambda alongside the existing livery function. The prompt is deliberately narrow: Nova Micro gets a schema and is asked to fill it. The Lambda parses the first  {…}  block in the response, runs every field through a sanitizer, and writes DynamoDB. The existing livery Lambda gained a  GET /today  route — one function now owns two responsibilities, but they are the same data. The garage fetches  /today  on load, silently. If DynamoDB has a drop, Tonight's Build lights up with a sparkle symbol. If not, it stays clickable with a fallback message.
Challenges that actually ate the clock:
  • WebGL vs CSS clipping. You cannot clip a canvas scissor rect with  overflow: hidden  on a sibling div. The minimap needed two things: a static orthographic camera centred on the circuit bounding box so the white track line never left the viewport, and a  radial-gradient  overlay div to paint the square scissor corners dark and make the circle read as a circle.
  • EventBridge is always UTC. Midnight IST is  cron(30 18 * * ? *) . I wrote the wrong hour once. Caught it before the first scheduled run, but only because I checked the EventBridge rule in the console fifteen minutes before midnight and did the subtraction.
  • Build-time env vars. Vite inlines  import.meta.env.VITE_*  at compile time. If  VITE_API_URL  is not injected during  vite build  in GitHub Actions, production silently points at the wrong API endpoint. I spent longer on this than I want to admit.
  • Commentary variety. One Bedrock line per event sounds like a broken radio after two laps. Per-event-type rotating pools, keyed on current position, opponent name, lap number, and km/h, made it feel like a live announcer rather than a toast notification.
  • Mobile joystick. Discrete left/right steer buttons were two-handed and covered the car. A floating joystick zone on the left thumb with pedals on the right fixed the layout. The HUD and garage got pushed to the screen edges so the road stayed visible.



AWS Services Used / Architecture Overview

Midnight City Dusk till Dawn is a static Three.js game with an overnight agent writing creative state into a single DynamoDB row each night.
  • Amazon EventBridge — daily cron at  18:30 UTC  (midnight IST). The agent trigger. Nobody clicks it.
  • AWS Lambda —  midnight-city-agent  generates livery + mood via Bedrock and writes DynamoDB each night.  midnight-city-livery  serves  POST /livery  (on-demand paint) and  GET /today  (agent drop read path). Commentary runs on its own function.
  • Amazon Bedrock (Nova Micro) — APAC inference profile  apac.amazon.nova-micro-v1:0  in  ap-south-1 . Two Converse calls per night. JSON only, schema-constrained prompt.
  • Amazon DynamoDB — table  midnight-city-agent , partition key  pk . One item:  pk = "today" . Overwritten every run. No scanning, no TTL, no history needed.
  • Amazon API Gateway (HTTP API) —  POST /livery ,  GET /today ,  POST /commentary . CORS open for the game origin.
  • Amazon S3 — hosts  frontend/dist .
  • Amazon CloudFront — HTTPS CDN with SPA-friendly 404 →  index.html  routing.
  • AWS CDK —  infra/  is the source of truth for every resource. No console-click infrastructure.
  • GitHub Actions — Node 22,  vite build  with  VITE_API_URL  injected,  aws s3 sync , CloudFront invalidation on every push to  main .

The race never blocks on the agent. If tonight's item is missing, the garage says so and you still drive. Bedrock is garnish. The circuit is the product.



What You Learned Across the Summer

Five projects. Five weeks. I want to be honest about what actually moved the needle, because the individual learnings are less useful than the shape they make together.
WeekAhead was where I learned that EventBridge is a real agent trigger, not a toy. The CDK monorepo pattern — one stack, one deploy command, infra and app in the same repo — was the thing I kept coming back to. Bundling Lambda functions as ES modules with  esbuild  inside CDK means the infra and the code version together. That saved me from "which Lambda version is deployed?" confusion on every subsequent project.
StudyPulse taught me something about product scope. I built a Next.js SSR app on Amplify and tried to put a conversational AI surface front-and-centre. It worked, technically. But the insight I took away was that a narrow AI surface — a button that does one specific thing — beats a chat box that can do anything. Users know what to expect from a button. A chat box creates a blank-canvas anxiety. I applied that directly to Midnight City: AI Paint Job is a single button, Tonight's Build is a single button. No prompt, no options, no blank field.
PlatePilgrim was the infrastructure lesson of the summer. Using CloudFront as an API proxy — pointing  /api/*  at an API Gateway origin — meant the frontend never had to deal with CORS headers or mixed-content issues. Single-table DynamoDB design clicked properly on that project: one table, composite sort keys, everything you need without a join. I also learned the Cognito Hosted UI trade-off the hard way. It handles the OAuth flow beautifully but the default login screen looks like 2014, and you cannot style it without a custom domain. The lesson: vendor your auth if UX matters, or budget time to skin it.
Opportun-AI-t was where I learned that AI agents need idempotency more than they need capability. If your agent can run the same job twice and produce consistent, safe results, you can schedule it aggressively. If it cannot, you are one EventBridge hiccup away from duplicate state. I also learned that model output is a contract: if you change the prompt, you change the schema, and the app that reads it breaks. Treat the JSON shape as a versioned API. And Amplify's environment variable injection is not the same as Vite's build-time injection — a distinction that cost me a deploy.
Midnight City had its own lessons. The chase camera position is a product decision, not a technical one. Sitting the camera high and having it lag slightly behind the car makes the game feel fast because you see the hood and the road ahead at the same time. I tried half a dozen camera positions before landing there. Generative AI as garnish — applied once at midnight, not on every frame — is genuinely sustainable. The Lambda runs for under two seconds a night. The cost is noise. And vendor your assets: CC-licensed track music, a system font stack, procedural car geometry. Zero build-time asset pipeline to break.
The meta-lesson is the one that matters most. Each project reused patterns from the last one. By week five, standing up a new CDK stack took twenty minutes instead of two hours. The EventBridge cron I added in Midnight City was the same cron I had sketched in WeekAhead. The single-table DynamoDB write-then-read pattern from PlatePilgrim was exactly what the agent needed. The narrow AI surface I learned about in StudyPulse shaped the garage UI directly.
The stack compounds. Skills do not reset between projects. The fifth project is faster and more confident than the first because the first four are embedded in it.



Link to App or Repo

Open the garage, click Tonight's Build, and drive the livery the agent designed at midnight. Then drop in and see if you can hold P1 for three laps.



Tag a Builder Who Inspired You

Shoutout to Lewis Sawe, whose The Museum That Grows — a civilization's artifact collector that wakes up every night, reads everything already in the collection, invents one new artifact that fits, and adds it to the gallery without human intervention — is the same idea as Midnight City Dusk till Dawn, just with better taste in museums. Same EventBridge soul, different world. Give them a follow.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article