---
title: "Deploy 🪰 Fruit Fly Brain"
description: "Deploy and host your own 🪰 Fruit Fly Brain on Railway!"
category: "AI/ML"
url: https://railway.com/deploy/fruit-fly-brain
---

# Deploy 🪰 Fruit Fly Brain

Deploy and host your own 🪰 Fruit Fly Brain on Railway!

**[Deploy 🪰 Fruit Fly Brain on Railway](https://railway.com/template/fruit-fly-brain)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/fruit-fly-brain/manifest.json

- **Creator:** Medim's Projects
- **Category:** AI/ML

## Template content

### 🪰 Fruit Fly

- **Source:** https://github.com/kadumedim/fly-brain-railway
- **Public domain:** Yes

## Documentation

# Deploy and Host 🪰 Fruit Fly Brain on Railway

🪰 Fruit Fly Brain is a live spiking simulation of an entire fruit-fly connectome — 139,255 neurons and ~2.7M synapses from FlyWire FAFB v783 — that deploys a real multi-service app. Pending infrastructure appears as *food* on a canvas; when the fly smells it, walks over and eats it, a Railway GraphQL mutation fires and a service is born beside it.

## About Hosting 🪰 Fruit Fly Brain

It deploys as one Node 22 container built from the repo's `Dockerfile` — zero npm dependencies, with the 12.4 MB connectome baked into the image. The server runs the single authoritative simulation in a `worker_thread` and fans state out over SSE, so browsers are pure renderers and hundreds of spectators cost you one process and zero extra API calls. `railway.json` wires up a `/api/health` healthcheck and on-failure restarts for you. Setup is two variables: a project-scoped `RAILWAY_TOKEN`, minted from the project after the first deploy, and an `ADMIN_PASSWORD` gating the public URL. You can skip the token entirely and run the full demo with `DRY_RUN=1`. Mount a volume at `/data` to keep best times across redeploys.

## Common Use Cases

- **A live, self-building demo of your Railway project** — spectators watch Postgres, Redis, web and worker appear on the real dashboard, with no account and no client-side simulation.
- **A conference booth or office-screen exhibit** — `AUTO_LOOP=1` runs mission → ALL GREEN → SWAT → repeat, with a HUD of runs, last and best times.
- **A sandbox for connectome-driven control** — an inspectable split between a scaffolding state machine (*what's next*) and emergent spiking behavior (*when and how*), useful for teaching or for experimenting with the FlyWire data.

## Dependencies for 🪰 Fruit Fly Brain Hosting

- **Node.js 22+** — supplied by the bundled `Dockerfile` (`node:22-alpine`); no runtime npm dependencies, no database and no Redis for the fly service itself.
- **A Railway project token** for the `production` environment, plus access to the Railway public GraphQL API (`backboard.railway.com/graphql/v2`).
- **FlyWire FAFB v783 connectome data** (`data/connectome.bin.gz`) — vendored in the repo under CC-BY-NC 4.0, see `NOTICE.md`.
- *(Optional)* a Railway volume mounted at `/data` for persistent run stats and history.

### Implementation Details

Set these on the fly service after the first deploy:

| var | meaning |
|---|---|
| `RAILWAY_TOKEN` | project token — server-side only, never sent to browsers |
| `ADMIN_PASSWORD` | gates all POSTs (`x-fly-admin` header); required for public deploys |
| `DRY_RUN=1` | log mutations and fake SUCCESS — full demo with no token and no spend |
| `AUTO_LOOP=1` | exhibit mode: loop mission → ALL GREEN → SWAT → mission |
| `TEARDOWN_AFTER_MIN` | auto-SWAT n minutes after ALL GREEN |
| `WEB_IMAGE` | custom image for the web step (default `nginx:alpine`) |
| `STATS_FILE` / `RUNS_FILE` | persisted best times and run history (default under `/data`) |

Create the token under **Settings → Tokens** in the project you deployed into. Project tokens are minted per-project, so the template can only prompt for it — deploy first, then paste the token in. Because it's scoped to exactly that project, the fly can only reach the services it sits next to. Railway's API does drift, so it's worth verifying the schema before a live run:

```sh
RAILWAY_TOKEN= node scripts/schema-smoke-test.js          # introspection only
RAILWAY_TOKEN= node scripts/schema-smoke-test.js --live   # + throwaway service
```

A live run creates four real services (`postgres:16-alpine`, `redis:7-alpine`, `nginx:alpine`, `alpine:3`). They're small, and **SWAT** or `TEARDOWN_AFTER_MIN` removes them when you're done — the fly itself is never deleted. A single run makes fewer than 60 API requests; `AUTO_LOOP` sustains 150–250 per hour, so Hobby suits continuous exhibit use better than the free tier.

## Why Deploy 🪰 Fruit Fly Brain on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying 🪰 Fruit Fly Brain on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/fruit-fly-brain
