# From Railway, with the database

Tell your AI “Move my Railway project to BitHut”. It brings the code, the variables and the Postgres data, checks the project here, and only then do you turn Railway off.

## Tell your AI

1. Connect BitHut to your AI (Claude, ChatGPT or Codex): add the address `https://api.bithut.app/mcp`. How: https://bithut.app/connect.md
2. Then tell it:

```
Move my Railway project to BitHut
```

## How the move goes

1. **Connect BitHut once.** Add BitHut to Claude Code, Codex or Cursor, in the folder of your project.
2. **Variables into a file.** Your AI runs Railway's own command to save the service's variables into a .env file on your computer.
3. **Code, keys, database.** The code comes from GitHub or your folder, the keys from the file, the Postgres data straight from Railway. The project waits here, paused.
4. **You switch over.** Turn the Railway service off. Your AI resumes the project on BitHut and checks it works.

## What your AI takes from Railway

- **Variables.** `railway variables --kv` prints them as `KEY=VALUE` lines, which go into a `.env` file on your computer and from there straight into BitHut's secret storage. Railway never shows the values of sealed variables, so you type those in again.
- **The database.** Inside Railway the address is `DATABASE_URL` on `railway.internal`, which nothing outside can reach. BitHut needs `DATABASE_PUBLIC_URL`, which appears once Public Access is turned on for the database. Railway counts that copy as outgoing traffic.
- **The code.** Usually it is on GitHub, and BitHut deploys it from there. If you deployed with `railway up`, the code is in your folder.
- **Files on a volume.** `railway volume files download` saves them to your computer, and they go onto the project's disk here.

## Nothing runs twice

A bot answering from two places, or a cron job firing twice, is the usual mess after a move. While the project is paused on BitHut it does not run. You turn the Railway service off, then resume here.

## If something goes wrong

The database copy starts with a restore point of the project's own database, and the data from before stays for 7 days. Keep the Railway service for at least 3 days after the switch.

## Templates to start from

- [Telegram bot](https://bithut.app/templates/telegram-bot.md): A bot in Telegram that does what you ask: answers customers, takes bookings, reminds, looks things up. It stays online even when your laptop is closed.
- [Daily report](https://bithut.app/templates/daily-report-to-telegram.md): Every morning it takes yesterday's numbers and sends a short summary to your team chat, your e-mail or both.
- [Lead form](https://bithut.app/templates/lead-intake.md): A form for your clients. Every request is saved and reaches you where you work: e-mail, Telegram, Slack and more.
