File size: 4,865 Bytes
f871fed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# πŸš€ Railway Deployment Quick Checklist

## Pre-Deployment
- [ ] Fork repository to your GitHub account
- [ ] Have at least one AI API key ready (OpenAI, Anthropic, etc.)
- [ ] Have Railway account created

## Step 1: Push Code
```bash
git add .
git commit -m "Add Railway deployment fixes"
git push origin main
```

## Step 2: Create Railway Project
- [ ] Go to https://railway.app/
- [ ] Click "New Project"
- [ ] Select "Deploy from GitHub repo"
- [ ] Choose your forked repository
- [ ] Railway will start building automatically

## Step 3: Set Environment Variables (CRITICAL!)

Go to Railway β†’ Your Service β†’ Variables tab

### Required Variables (Set BEFORE first successful deploy):
```bash
SURREAL_URL=ws://127.0.0.1:8000/rpc
SURREAL_USER=root
SURREAL_PASSWORD=root
SURREAL_NAMESPACE=open_notebook
SURREAL_DATABASE=production
INTERNAL_API_URL=http://127.0.0.1:5055
OPENAI_API_KEY=sk-your-actual-openai-key
```

- [ ] All required variables set
- [ ] Wait for build to complete
- [ ] Note your Railway domain (e.g., `https://yourapp-production.up.railway.app`)

## Step 4: Set API_URL (AFTER getting domain)
```bash
API_URL=https://yourapp-production.up.railway.app
```

- [ ] API_URL variable added with YOUR actual Railway domain
- [ ] Redeploy triggered (automatic after adding variable)

## Step 5: Configure Railway Settings
- [ ] Go to Settings β†’ Networking
- [ ] Verify port 8080 is exposed (should auto-detect)
- [ ] Health check path: `/api/health`

## Step 6: Verify Deployment

### Check These URLs:
- [ ] `https://yourapp.up.railway.app/` β†’ Should show Open Notebook UI
- [ ] `https://yourapp.up.railway.app/api/health` β†’ Should return `{"status":"ok"}`
- [ ] `https://yourapp.up.railway.app/api/docs` β†’ Should show API documentation

### Check Railway Logs:
- [ ] All 4 services started: surrealdb, api, worker, frontend
- [ ] No error messages (warnings are OK)
- [ ] Migrations completed successfully
- [ ] Frontend shows "Ready in XXms"

## Step 7: Test Functionality
- [ ] Create a new notebook
- [ ] Upload a test document
- [ ] Try chat functionality
- [ ] Generate a podcast (optional)

## Common Issues & Quick Fixes

### ❌ Build Timeout
**Solution:** Upgrade to Railway Hobby plan ($5/month) for longer build times

### ❌ Services Keep Restarting
**Solution:** Check environment variables are set correctly, especially `SURREAL_URL`

### ❌ Frontend Can't Connect to API
**Solution:** Ensure `API_URL` is set to your actual Railway domain (with https://)

### ❌ Out of Memory
**Solution:** Upgrade Railway plan (single container needs ~2GB RAM)

### ❌ "Database Connection Failed"
**Solution:** 
1. Check `SURREAL_URL=ws://127.0.0.1:8000/rpc` (note: 127.0.0.1, not localhost)
2. Verify SurrealDB service is running in logs

## Environment Variables Checklist

### Required (App Won't Work Without These):
- [ ] `SURREAL_URL`
- [ ] `SURREAL_USER`
- [ ] `SURREAL_PASSWORD`
- [ ] `SURREAL_NAMESPACE`
- [ ] `SURREAL_DATABASE`
- [ ] `INTERNAL_API_URL`
- [ ] `API_URL` (add after first deploy)
- [ ] At least one AI API key (OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.)

### Optional (Add As Needed):
- [ ] `ANTHROPIC_API_KEY` - For Claude models
- [ ] `GOOGLE_API_KEY` - For Gemini models
- [ ] `GROQ_API_KEY` - For Groq models
- [ ] `MISTRAL_API_KEY` - For Mistral models
- [ ] `OPEN_NOTEBOOK_PASSWORD` - For password protection
- [ ] `FIRECRAWL_API_KEY` - For enhanced web scraping
- [ ] `JINA_API_KEY` - For advanced embeddings

## Success Indicators

Your deployment is successful when you see in Railway logs:
```
βœ“ Ready in XXXms
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:5055
Migrations completed successfully. Database is now at version 17
All services entered RUNNING state
```

## Cost Estimation

**Railway Hobby Plan**: ~$5-10/month
- Includes $5 usage credit
- Covers single container deployment
- Sufficient for testing and small-scale use

**Plus AI API Costs**: Pay-per-use
- OpenAI: ~$0.002-0.06 per 1K tokens
- Anthropic: Similar pricing
- Varies by model and usage

## Support

Need help?
- πŸ“– Read [RAILWAY.md](./RAILWAY.md) for detailed guide
- πŸ’¬ Join [Discord](https://discord.gg/37XJPXfz2w)
- πŸ› Report [GitHub Issues](https://github.com/PremKxmar/se/issues)

---

## After Successful Deployment

1. **Bookmark your Railway app URL**
2. **Set up volume** (in Railway) for `/mydata` to persist database
3. **Monitor usage** in Railway dashboard
4. **Configure more AI providers** as needed
5. **Secure with password** by setting `OPEN_NOTEBOOK_PASSWORD`

## Development Workflow

To update your deployed app:
1. Make changes locally
2. Test with `docker compose up` or `npm run dev`
3. Commit and push to GitHub
4. Railway auto-deploys (if enabled)
5. Verify in Railway logs

---

**Pro Tip:** Copy this checklist and check off items as you complete them!