
Deploy fastapi-fullstack-mysql
One click deploy and Host official full stack FastAPI template with mysql
MySQL
Just deployed
/var/lib/mysql
Just deployed
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.
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_PASSWORDon first boot. - Production-ready defaults — the app binds to Railway's
PORT, exposes a redirect-freeGET /healthused 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
- Wait for the deployment to go live — migrations and the superuser seed run automatically before the healthcheck passes.
- In the backend service, generate a public domain and set
FRONTEND_HOSTto that URL (used for CORS). - Open the domain: the React app is served at
/, the API at/api/v1, and interactive docs at/docs. Log in withFIRST_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, andFRONTEND_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 healthchecksGET /health. - MySQL (database plugin) — MySQL 8.4 with a persistent volume at
/var/lib/mysql, exposingMYSQL_URLto 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; onlyDATABASE_URLis pre-wired by the template. - MySQL service — Railway's MySQL 8.4 plugin with a persistent volume; provides
MYSQL_URL(andMYSQLHOST,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
MySQL
mysql:9.4