English | 한국어
This guide provides step-by-step instructions for deploying the AI wedding invitation using Railway.
- What is Railway?
- Pre-deployment Checklist
- Deploy with CLI
- Deploy with GitHub
- PostgreSQL Setup
- Environment Variables
- Custom Domain
- Troubleshooting
Railway is a cloud application deployment platform.
✅ Free Tier
- $5 monthly credit
- Sufficient for small projects
✅ Easy Deployment
- Auto-deploy with Git push
- No complex configuration
✅ PostgreSQL Integration
- One-click database creation
- Auto-connection setup
✅ Auto SSL
- Automatic HTTPS
- No certificate management
✅ Zero Config
- Auto Dockerfile generation
- Auto environment detection
Hobby Plan (Free)
- $5 monthly credit
- 512 MB RAM
- 1 GB disk
- Suitable for small weddings (~200 guests)
Estimated Usage
Web service: ~$3/month
PostgreSQL: ~$1/month
Total: ~$4/month (within free tier)
After Wedding?
- Pause project
- Data preserved
- Resume anytime
- Visit Railway website
- Click "Sign Up"
- Log in with GitHub account
Ensure these files exist:
wedding-invitation/
├── main.py
├── requirements.txt
├── .env.example
├── config/
│ ├── config.json
│ └── couple_knowledge.json
└── (other files)
Prepare these values:
OPENAI_API_KEY: OpenAI API keyADMIN_USERNAME: Admin IDADMIN_PASSWORD_HASH: Admin password hashSECRET_KEY: Session encryption keyKAKAO_APP_KEY: (Optional) Kakao app key
Generate admin password hash:
python scripts/generate_password_hash.pyGenerate SECRET_KEY:
python -c "import secrets; print(secrets.token_urlsafe(32))"Deploy using Railway CLI.
# Using npm
npm i -g @railway/cli
# Or Homebrew (macOS)
brew install railwayrailway loginBrowser opens for authorization.
# Navigate to project directory
cd wedding-invitation
# Create Railway project
railway initWhen prompted:
- Select "Create a new project"
- Enter project name (e.g., my-wedding-invitation)
# Add PostgreSQL plugin
railway add -d postgres# Set environment variables (one at a time)
railway variables set OPENAI_API_KEY="your_api_key"
railway variables set ADMIN_USERNAME="admin"
railway variables set ADMIN_PASSWORD_HASH="your_hash"
railway variables set SECRET_KEY="your_secret_key"
railway variables set KAKAO_APP_KEY="your_kakao_key"
# (Optional) LangSmith
railway variables set LANGCHAIN_API_KEY="your_langsmith_key"
railway variables set LANGCHAIN_TRACING_V2="true"
railway variables set LANGSMITH_PROJECT="wedding-chatbot"# First deployment
railway up
# Check URL after deployment
railway openBrowser opens automatically!
# View real-time logs
railway logs
# View errors only
railway logs -fAuto-deploy with Git push.
# Initialize Git (if not done)
git init
# After creating repository on GitHub
git remote add origin https://github.com/yourusername/wedding-invitation.git
git add .
git commit -m "Initial commit"
git push -u origin main- Access Railway dashboard
- Click "New Project"
- Select "Deploy from GitHub repo"
- Select repository
- Click "New" on project page
- Select "Database" → "Add PostgreSQL"
DATABASE_URLenvironment variable auto-configured
- Click service on project page
- Select "Variables" tab
- Click "New Variable" to add:
OPENAI_API_KEY=your_api_key
ADMIN_USERNAME=admin
ADMIN_PASSWORD_HASH=your_hash
SECRET_KEY=your_secret_key
KAKAO_APP_KEY=your_kakao_key
- Select "Settings" tab
- Verify settings:
Build Command: (leave empty - auto-detect)
Start Command: python main.py
# Auto-deploys on push to main branch
git add .
git commit -m "Update wedding info"
git push origin mainRailway automatically:
- Pulls code
- Installs dependencies
- Builds application
- Deploys
Railway automatically:
- Creates PostgreSQL instance
- Sets
DATABASE_URLenvironment variable - Auto-connects to application
No additional work needed!
To use specific PostgreSQL server:
# Set manually with environment variable
railway variables set DATABASE_URL="postgresql://user:password@host:port/database"Access with Railway CLI:
# Open PostgreSQL console
railway connect postgresAccess with external client:
- Select PostgreSQL service in Railway dashboard
- Check connection info in "Connect" tab
- Connect with pgAdmin, DBeaver, etc.
Auto backup: Railway doesn't auto-backup.
Manual backup (Important!):
# Backup locally
railway run pg_dump $DATABASE_URL > backup.sql
# Restore
railway run psql $DATABASE_URL < backup.sqlRegular backup: Recommended to backup regularly before and after wedding.
- Project → Select service
- "Variables" tab
- Click "New Variable"
# Set single variable
railway variables set KEY="value"
# Set multiple variables at once
railway variables set \
KEY1="value1" \
KEY2="value2" \
KEY3="value3"
# View variables
railway variables
# Delete variable
railway variables delete KEY# Upload all variables from .env file to Railway
while IFS= read -r line; do
if [[ ! "$line" =~ ^#.*$ ]] && [[ -n "$line" ]]; then
railway variables set "${line%%=*}=${line#*=}"
fi
done < .envDevelopment:
# .env.development
DEBUG=true
LOG_LEVEL=debugProduction (Railway):
# Set as Railway variables
DEBUG=false
LOG_LEVEL=info- API keys
- Passwords
- Database URLs
- SECRET_KEY
✅ Correct method:
- Commit only
.env.examplefile - Set actual values as Railway environment variables
- Add
.envto.gitignore
Use your own domain instead of Railway's default (e.g., your-app.railway.app).
Buy domain from registrar:
Recommended examples:
john-jane-wedding.comwedding-2026.comourwedding.com
- Select service in Railway project
- "Settings" tab
- "Domains" section
- Enter "Custom Domain" (e.g.,
www.your-domain.com)
In domain registrar's DNS management:
Add CNAME record:
Type: CNAME
Name: www (or @)
Value: your-app.railway.app
TTL: Auto (or 3600)
Railway automatically issues Let's Encrypt SSL certificate.
- Auto HTTPS
- Auto certificate renewal
- No additional setup needed
Redirect example.com → www.example.com:
Add to domain DNS:
Type: A
Name: @
Value: 76.76.21.21 (Railway's IP)
Or use URL Redirect record (varies by registrar)
- Check DNS propagation (may take up to 48 hours):
nslookup www.your-domain.com- Access in browser:
https://www.your-domain.com
- Verify SSL certificate: Click padlock icon in address bar
Symptom: "Build failed" or "Deployment failed" error
Solution 1: Check logs
railway logsSolution 2: Dependencies issue
# Verify requirements.txt
pip freeze > requirements.txt
git add requirements.txt
git commit -m "Update dependencies"
git pushSolution 3: Specify Python version
# Create runtime.txt file
echo "python-3.11" > runtime.txtSymptom: "Database connection failed"
Solution 1: Verify DATABASE_URL
railway variables | grep DATABASE_URLSolution 2: Restart PostgreSQL
- Railway dashboard
- Select PostgreSQL service
- "Settings" → "Restart"
Solution 3: Check connection string
# Check in main.py
import os
print("DATABASE_URL:", os.getenv("DATABASE_URL"))Symptom: "Application failed to start"
Solution 1: Check port configuration
# main.py
port = int(os.getenv("PORT", 8000))
uvicorn.run("main:app", host="0.0.0.0", port=port)Solution 2: Verify environment variables
railway variablesEnsure all required variables are set
Solution 3: Health check Railway checks if application is ready:
@app.get("/health")
async def health_check():
return {"status": "ok"}Symptom: Chatbot not responding or errors
Solution 1: Verify OpenAI API key
railway variables | grep OPENAI_API_KEYSolution 2: Check knowledge base files
# Verify config files deployed
railway run ls -la config/Solution 3: Check logs
railway logs | grep chatbot
railway logs | grep ERRORSymptom: Slow page loading
Solution 1: Check free plan Railway free plan has 512MB RAM limit.
Solution 2: Optimize images
# Run WebP conversion script
python scripts/resize_image.pySolution 3: Consider upgrade If high traffic, consider Hobby Plan ($5/month)
Symptom: Cannot access custom domain
Solution 1: Check DNS propagation
nslookup www.your-domain.comSolution 2: Wait for propagation DNS propagation can take up to 48 hours.
Solution 3: Verify DNS records
- Check correct CNAME value entered
- Verify domain status in Railway dashboard
Symptom: Exceeded monthly $5 credit
Solution 1: Check usage
- Railway dashboard
- "Usage" tab
- Check usage per service
Solution 2: Stop unused services
# Delete unused services
railway service delete SERVICE_NAMESolution 3: Change model
# Use cheaper GPT model
railway variables set CHAT_MODEL="gpt-3.5-turbo"- OpenAI API key ready
- Admin password hash generated
- SECRET_KEY generated
- config.json completed
- couple_knowledge.json completed
- Images optimized (WebP)
- requirements.txt updated
- Railway account created
- PostgreSQL added
- All environment variables set
- GitHub repository connected (if using auto-deploy)
- Site accessible
- Chatbot tested
- Guestbook tested
- RSVP tested
- Admin page login tested
- Mobile responsive checked
- KakaoTalk sharing tested (optional)
- Database backup created
- Server status monitored
- Logs checked
- Database backup created
- Download guestbook CSV
- Download RSVP data CSV
- Final database backup
- Pause project (save costs)
Congratulations! 🎉
If successfully deployed, you can now share your invitation with guests and let them chat with the AI chatbot!