Tech Stack & Dev Notes
The nuts and bolts of what makes TW 3002 AI tick — and how it was built.
Architecture
TW 3002 AI has three deploy targets, all hosted on Cloudflare. The web client and marketing/docs site auto-deploy on every push to main; the API Worker is deployed separately:
| Layer | Stack | URL |
|---|---|---|
| API | Cloudflare Worker (TypeScript) + D1 (SQLite) | api.tw3002.net |
| Game Client | Vue 3 SPA + Pinia + Tailwind CSS | play.tw3002.net |
| Marketing & Docs | Astro static site (what you’re reading now) | tw3002.net |
The API handles all game logic — trading, combat, warp routing, PvP encounters, NPC ticks, missions, planets, and auth. The game client is a single-page app that talks to the API via fetch(). The marketing site is pure static Astro, hosting these guides, the changelog, and the API reference.
Development tooling: Bun runs the seed scripts that generate the galaxy and NPC data, Wrangler manages D1 migrations and remote queries, and Vite powers the game client dev server.
Most of the stack sits comfortably inside Cloudflare’s low-cost footprint — Workers, D1, Pages, and Workers AI all scale well for a small live game. The real variable costs now come from integrated services like email, AI usage as activity grows, and payment infrastructure.
Database
All game state lives in Cloudflare D1, a serverless SQLite database distributed to Cloudflare’s edge network.
Key tables:
| Table | What It Holds |
|---|---|
galaxies | Shared galaxy metadata: names, slugs, active status, and the multi-galaxy world list |
sectors | Sector state per galaxy: ports, trade inventories, warp connections, planet data, danger levels |
players | Email-based auth with opaque Bearer tokens |
player_ships | Every active ship: stats, credits, cargo, fighters, mines, upgrades, kills/deaths, alignment, XP |
npcs | AI-driven NPCs across the live galaxies, with factions, personas, ships, and memory |
planets | Player-owned planets: colonists, citadels, production, cannons, and storage |
sector_fighters | Deployed fighters in live sectors, including mode and optional fleet name |
sector_mines | Deployed limpets and armids in live sectors |
pvp_kills | All player-vs-player combat records |
pvp_encounters | Active PvP encounter state while players are choosing fight/flee/surrender/hail |
news | Galaxy event log and sector headlines |
player_action_log | Audit trail of player actions for debugging, analytics, and dispute review |
player_daily_missions | Per-player daily mission state and progress |
npc_tick_log | Observability for NPC/LLM ticks, model usage, and action counts |
D1 was chosen over traditional databases because it colocates data with the Worker runtime — queries run at the edge with sub-millisecond latency.
Integrated Services
| Service | What It Does |
|---|---|
| Cloudflare Workers AI | Powers NPC decision-making (24 ticks/day in each galaxy) and the daily galaxy summary narrative |
| Resend | Transactional email: account verification codes, admin digest, re-engagement campaigns |
| Discord | Community server + webhook notifications for player deaths, bounties, and admin alerts |
| Stripe | Optional player support and payment flows through hosted checkout and Worker-backed Stripe integration |
| Turnstile | Cloudflare’s privacy-respecting CAPTCHA on registration and verification |
NPC AI System
Every hour, the server ticks NPCs in each active galaxy. Each one evaluates its situation and takes an action — move, trade, hunt, or idle. This runs 24 times per day in each galaxy, making the galaxies feel alive regardless of player activity.
The LLM layer (Cloudflare Workers AI running @cf/zai-org/glm-4.7-flash) is used only for Raider-type NPCs — the hostile ones. It receives a small snapshot (faction, danger level, port presence, warp exits) and picks one action word. Traders and patrols use a fixed probability matrix instead.
What the LLM doesn’t do: It can’t see players, fighters, mines, or cargo. It doesn’t choose routes or targets. All tactical decisions — movement destinations, combat resolution, commodity selection — are handled by deterministic server code. The LLM is a seasoning, not the chef.
A daily summary at 8 AM UTC feeds 24 hours of player activity through a larger model to generate short in-universe narrative summaries for the public news feed and the admin digest.
Game Client
The game interface is a Vue 3 SPA with a terminal-inspired design system. Key choices:
- Pinia for state management — stores handle both reactive UI state and API communication with the Worker.
- Tailwind CSS with a custom palette:
terminal-cyan,terminal-green,terminal-red,terminal-yellow, and deep void backgrounds. - JetBrains Mono for all code/terminal text, Inter for headings.
- Vue Composition API with
<script setup>throughout. - Teleported modals — every overlay (combat, trade, PvP, planets, settings) renders into
<Teleport to="body">so only one is visible at a time. - Keyboard-first — every major action has a shortcut. Mouse is optional.
AI-Driven Development
TW 3002 AI was built with heavy use of AI coding agents — and this page exists to be transparent about that.
The short version
Yes, AI did all the coding. The planning, design decisions, game mechanics, and direction were human. The execution was AI-driven.
More about me and my workflow
My name is Aaron Prill and I’ve been a software engineer for 25 years. Since late 2025, when coding agents reached a tipping point, my daily workflow involves writing very few lines of code by hand.
How agentic development works in practice
Rather than writing code, the workflow shifts to:
- Describing what needs to exist — in plain language, with constraints and design rules
- Providing project context — AGENTS.md files (like the ones in the repo) that teach the agent about architecture, conventions, and gotchas
- Reviewing the output — reading every line the agent produces, asking for corrections where needed
- Iterating — tightening the specification until the implementation matches the intent
The agent handles the typing, the boilerplate, the refactoring, the bug fixes. The human handles the vision, the game design, the product decisions, and the final accountability for what ships.
This is similar to how a senior engineer works with a team — they don’t write every line of code themselves. They set direction, review pull requests, and ensure quality. The agent just happens to be an LLM instead of a junior developer.
Why be open about this?
Because it’s the reality of software in 2026, and pretending otherwise does a disservice to everyone — especially new developers wondering how to get started. If you use AI to build something, own it. The work is in the ideas, the design, the persistence, and the taste to know what’s worth building. The code is just the final artifact.
Open Source?
Not yet. The repo is private while the game is in active development. If there’s interest down the road, some components (like the shared game engine or the client design system) could be extracted and open-sourced.
Resources
Support The Signal
If the guide helped, help keep the galaxy growing.
These guides are written alongside the live game so new pilots can get moving without guesswork.
Support helps fund the servers, APIs, and ongoing development behind TW 3002 AI.
Ko-fi is the easier option if you do not use GitHub.
