Railway

Deploy fastapi-fullstack-mysql

One click deploy and Host official full stack FastAPI template with mysql

Deploy fastapi-fullstack-mysql

Just deployed

/var/lib/mysql

FastAPI + MySQL Full-Stack Template for Railway

The official Full Stack FastAPI Template switched from PostgreSQL to MySQL 8.4, packaged for one-click deployment on Railway.

One deploy provisions two services and hands you a working, authenticated full-stack app:

  • backend — FastAPI + SQLModel + Alembic with JWT authentication, and the React/TypeScript frontend (Vite, Tailwind CSS, shadcn/ui) built and served by the same container on a single domain.
  • MySQL — MySQL 8.4 with a persistent volume, wired to the backend automatically via DATABASE_URL.

Deploy on Railway

What this template handles for you

  • Database schema migrations on every deploy — Alembic runs in the container start command before the app serves traffic, so the schema is always current.
  • Admin bootstrap — the first superuser is seeded from FIRST_SUPERUSER / FIRST_SUPERUSER_PASSWORD on first boot.
  • Production-ready defaults — the app binds to Railway's PORT, exposes a redirect-free GET /health used as the platform healthcheck, refuses placeholder secrets outside development, and connects to MySQL with connection pooling tuned for MySQL (pool_pre_ping, pool_recycle, READ COMMITTED isolation).
  • MySQL instead of PostgreSQL — pure-Python PyMySQL driver (no native build dependencies), with the template's migration history rewritten to run on MySQL from an empty database.

After deploying

  1. Wait for the deployment to go live — migrations and the superuser seed run automatically before the healthcheck passes.
  2. In the backend service, generate a public domain and set FRONTEND_HOST to that URL (used for CORS).
  3. Open the domain: the React app is served at /, the API at /api/v1, and interactive docs at /docs. Log in with FIRST_SUPERUSER / FIRST_SUPERUSER_PASSWORD.

Deploy and Host

Deploy this template to get a FastAPI backend serving a built React frontend on one domain, backed by MySQL 8.4. Railway builds the repo-root Dockerfile, runs Alembic migrations, seeds the first superuser, and passes the /health healthcheck before marking the deployment live.

About Hosting

Hosting consists of two Railway services:

  • backend (Docker, from the repo-root Dockerfile) — FastAPI application with the frontend static build served by the same process. It expects these variables: DATABASE_URL (auto-wired to the MySQL service as ${{MySQL.MYSQL_URL}}), PROJECT_NAME, SECRET_KEY, FIRST_SUPERUSER, FIRST_SUPERUSER_PASSWORD, and FRONTEND_HOST (set it to the generated public domain after the first deploy). Migrations (alembic upgrade head) and superuser seeding run at container start; the platform healthchecks GET /health.
  • MySQL (database plugin) — MySQL 8.4 with a persistent volume at /var/lib/mysql, exposing MYSQL_URL to the project.

You scale by changing the compute plan of each service; data persists on the MySQL volume across deploys.

Why Deploy

Deploying this template instead of assembling the stack manually gives you:

  • A working full-stack app in minutes — authentication, user management, and CRUD examples already wired end to end, with an auto-generated TypeScript client for the frontend.
  • Zero migration babysitting — the database schema is brought up to date on every deploy, including the very first one on an empty database.
  • One domain for frontend and API — no CORS juggling, no separate static hosting.
  • MySQL compatibility done right — the upstream template is PostgreSQL-only; this variant has the driver, config, migration history, and connection-pool behavior all adapted and tested against MySQL 8.4 (the full backend test suite passes).

Common Use Cases

  • SaaS MVPs that need JWT auth, user management, and email flows on day one.
  • Internal tools and admin panels built on the included React + shadcn/ui dashboard.
  • REST APIs for teams standardized on MySQL hosting (existing RDS/PlanetScale-style setups, legacy MySQL data).
  • A learning or reference implementation of a production-shaped FastAPI project: Alembic migrations, typed CRUD, background emails, and CI included.

Dependencies for

The template depends on two Railway services and a set of environment variables.

Deployment Dependencies

  • backend service — built from the repo-root Dockerfile (multi-stage: Bun builds the React frontend, Python 3.14 + uv installs the FastAPI backend). Requires the environment variables listed under About Hosting; only DATABASE_URL is pre-wired by the template.
  • MySQL service — Railway's MySQL 8.4 plugin with a persistent volume; provides MYSQL_URL (and MYSQLHOST, MYSQLPORT, MYSQLUSER, MYSQLPASSWORD, MYSQLDATABASE) referenced by the backend.
  • GitHub repository — deploys are built from this repo; CI workflows (pytest against MySQL, Docker Compose smoke test) run on push.

Template Content

More templates in this category

View Template
open-excalidraw
Self-hostable collaborative drawing built on Excalidraw

Prateek Mohanty
3
View Template
caring-vibrancy
Deploy and Host caring-vibrancy with Railway

5
View Template
Appsmith
Low-code platform for internal tools, dashboards, and admin panels.

Agaz Self-Host
0