AWS Builder Center
 Weekend Creative Agent Challenge: Midnight City After Dark

Weekend Creative Agent Challenge: Midnight City After Dark

Midnight City After Dark is a neon street racer whose garage agent wakes at midnight, paints a new car with Amazon Bedrock, and has tonight’s build waiting when you return.

FOSS Enthusiast, Linux User, Cyber Sec <3

Vision & What It Does

Last week I shipped Midnight City — a browser arcade racer that tries to bottle one feeling: dropping a loud car onto a glowing night circuit and chasing the vanishing point. You paint a coupe in the garage, tap Drop In, and drive a closed neon loop while a chase camera sits high and a little late, looking past the hood into the next corner.
This week’s challenge asked a different question. The best tool is the one you never have to open. So I turned the garage into an always-on agent: something that makes a new creative artifact on its own, every night, and has it waiting when you come back.
The problem I wanted to solve is small but specific. A racing game with a paint shop still needs you to press the button. AI Paint Job was already there — tap it, Nova Micro invents a livery — but that is still a request/response toy. The agent is the opposite. You do nothing. At midnight IST an EventBridge rule fires, a Lambda asks Amazon Bedrock (Nova Micro) for two things, and DynamoDB stores the result under the key  today :
  1. Tonight’s livery — a name, a cinematic tagline, body / rim / underglow hex colors, spoiler on or off, headlights on or off.
  1. Tonight’s track mood — a weather label for the HUD, fog density, a sky hex, an ambient light tint, and a one-line atmosphere tagline. The weather vibe itself rotates on a seven-day cycle (clear moon, harbour fog, thunderstorm, frost on the kerbs…) so the city does not feel the same every night.
When you open the site, the garage shows Tonight’s Build. 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. No prompt, no form, no “generate.” The city just keeps working.
The rest of the game grew with it. Traffic is no longer scenery. Ten named racers sit on the circuit with their own speed tiers. Position is live on the HUD. Commentary now knows who you passed, who passed you, what lap you are on, and how fast you were going: “Past Nakamura! P4 now. Eyes forward.”



How I Built It

I already had the WeekAhead pattern in my hands: Vite frontend, AWS CDK, Lambda + HTTP API, S3 + CloudFront, Nova Micro behind a function that cannot fail the player. This week I added three things to that skeleton: a DynamoDB table, an EventBridge cron, and a new agent Lambda. The existing livery Lambda gained a  GET /today  route so the browser can read whatever the agent last wrote.
The agent prompt is deliberately small. Nova Micro is asked for compact JSON, not a novel. The Lambda strips markdown fences, parses the first  {…}  block, and sanitizes every field — hex colors get a regex check, names get a length cap, booleans default on. If Bedrock hiccups, the previous  today  item stays in the table and the garage still has a car. The race loop never waits on AWS.
Frontend work was the other half of the weekend:
  • Garage. Tonight’s Build is always visible. It loads as pending, then either lights up with a sparkle when DynamoDB has a drop, or stays clickable with a fallback message if the agent has not run yet today.
  • Race.  getRacePositions()  sorts player + NPCs by lap and spline  t  every frame. Overtake and “you got passed” events fire commentary with opponent name, P-of-N, and speed.
  • Minimap. CSS  border-radius: 50%  does not clip WebGL. The GPU paints through the div. I stopped fighting that and did two things instead: a static north-up orthographic camera centred on the circuit’s bounding box (the white line can never leave the viewport), and a  radial-gradient  overlay that paints the square scissor corners dark so the circle reads as a circle.
  • Mobile. Discrete left/right steer buttons were two-handed and covered the car. A virtual joystick on the left thumb and GAS / BRAKE pedals on the right made the phone actually playable. HUD and garage got shoved to the edges so the road stays visible.
  • CI. The first GitHub Actions deploy baked the localhost into the Vite bundle because  VITE_API_URL  was a runtime env var, not a build-time one. The workflow now injects the secret during  vite build . Every push to  main  deploys infra + frontend.
Challenges that actually ate the clock:
  • WebGL vs CSS. You cannot clip a canvas scissor rect with  overflow: hidden  on a sibling div. Overlay, or don’t bother.
  • EventBridge is always UTC. Midnight IST is  cron(30 18 * * ? *) , not  0 0 . I wrote the wrong hour once, caught it before the first scheduled run.
  • Credentials in CI. The workflow failed with “could not load credentials from any providers” until the five GitHub secrets existed. CDK cannot invent those for you.
  • Commentary repetition. One Bedrock line plus a tiny local pool sounds like a broken radio. Per-event-type cooldown plus rotating pools keyed on position, opponent, lap, and km/h made it feel like a race announcer instead of a toast.



AWS Services Used / Architecture Overview

Midnight City After Dark is still a static Three.js game. The new piece is an overnight agent that writes creative state, plus a read path so the garage can pick it up.
  • Amazon EventBridge — daily rule at 18:30 UTC (midnight IST). This is the agent trigger. Nobody clicks it.
  • AWS Lambda —  midnight-city-agent  generates livery + mood via Bedrock and writes DynamoDB.  midnight-city-livery  still serves  POST /livery  (on-demand paint) and now also  GET /today  (agent drop). Commentary stays 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.
  • Amazon DynamoDB — table  midnight-city-agent , partition key  pk . One item:  pk = "today" . Overwritten every run so the garage always has a current drop without scanning.
  • 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, SPA-friendly 404 →  index.html .
  • AWS CDK —  infra/  is the source of truth.
  • GitHub Actions — Node 22, Vite build with  VITE_API_URL ,  aws s3 sync , CloudFront invalidation.


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



What I Learned

An always-on agent is mostly scheduling plus a contract. The creative part is a JSON schema Nova can hit reliably. The engineering part is making sure that JSON lands in a place the app already knows how to read, on a clock you do not have to babysit. EventBridge plus a single DynamoDB item is almost embarrassingly small for how much it changes the feel of the garage.
I also learned to keep the model off the hot path. Last week Nova painted the car when you asked. This week Nova paints the car while you sleep. Same model, different job. The player-facing loop (physics, commentary fallbacks, traffic) still works with the Wi-Fi unplugged.
On the AWS side, repeating the CDK pattern was faster than inventing a new topology. The new skills were EventBridge cron in UTC, granting the agent Lambda  bedrock:InvokeModel  plus DynamoDB write, and teaching the existing livery function to read the same table without owning the write path. IAM stays boring if you split those jobs.
The unglamorous lesson: build-time env vars. Vite inlines  import.meta.env.VITE_*  at compile. If CI does not pass  VITE_API_URL  into the build step, production will call localhost forever and you will spend an hour blaming Bedrock.



Link to App and 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.
Thanks for Reading! Praneel S
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