File size: 5,206 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# 🎯 DEPLOY NOW - Everything Ready!

## βœ… What's Configured

I've set up everything to work exactly like your localhost, using your FREE API keys:

- βœ… **Groq API**: `gsk_3pLc...kvfC` - For chat, transformations, insights
- βœ… **Gemini API**: `AIzaS...ep_0` - For embeddings, search, long context
- βœ… **Database**: test namespace/database (same as localhost)
- βœ… **All settings**: Same retry/worker config as your working setup

---

## πŸš€ STEP 1: Copy Railway Variables

Go to Railway Dashboard β†’ Your Service β†’ Variables, and paste ALL of these:

```plaintext
SURREAL_URL=ws://127.0.0.1:8000/rpc
SURREAL_USER=root
SURREAL_PASSWORD=root
SURREAL_NAMESPACE=test
SURREAL_DATABASE=test
INTERNAL_API_URL=http://127.0.0.1:5055
API_URL=http://localhost:5055
SURREAL_COMMANDS_MAX_TASKS=5
SURREAL_COMMANDS_RETRY_ENABLED=true
SURREAL_COMMANDS_RETRY_MAX_ATTEMPTS=3
SURREAL_COMMANDS_RETRY_WAIT_STRATEGY=exponential_jitter
SURREAL_COMMANDS_RETRY_WAIT_MIN=1
SURREAL_COMMANDS_RETRY_WAIT_MAX=30
GROQ_API_KEY=<YOUR_GROQ_KEY_HERE>
GOOGLE_API_KEY=<YOUR_GEMINI_KEY_HERE>
```

**Note**: We'll update `API_URL` after first deploy.

---

## πŸš€ STEP 2: Push Code

```powershell
cd c:\sem6-real\studyrocket\notebookllm\open-notebook
git add .
git commit -m "Add Railway deployment with FREE tier (Groq + Gemini)"
git push origin main
```

---

## πŸš€ STEP 3: Wait for Deploy

Railway will:
1. Build the Docker image (~5-10 minutes)
2. Start all services (SurrealDB, API, Worker, Frontend)
3. Run migrations (0 β†’ 18)
4. Expose your app on a public URL

**Watch the logs** in Railway dashboard for:
```
βœ“ Ready in XXXms
INFO: Application startup complete
Migrations completed successfully. Database is now at version 18
```

---

## πŸš€ STEP 4: Update API_URL

1. Find your Railway domain in the dashboard (e.g., `https://se-production-1a2b.up.railway.app`)
2. Update the `API_URL` variable:
   ```plaintext
   API_URL=https://se-production-1a2b.up.railway.app
   ```
3. Railway will auto-redeploy (~1 minute)

---

## βœ… STEP 5: Test Everything

Visit your app: `https://your-railway-domain.up.railway.app`

**Test these features:**
- βœ… Create a notebook
- βœ… Upload a document (tests embeddings)
- βœ… Search documents (tests Gemini embeddings)
- βœ… Chat with documents (tests Groq LLM)
- βœ… Generate insights (tests transformations)
- βœ… Create notes

**Skip for now:**
- ⏸️ Podcast generation (you'll configure later)

---

## πŸŽ‰ What You'll Have

### Working Features (FREE):
- βœ… Chat using Groq Llama 3.1 70B
- βœ… Document embeddings using Gemini
- βœ… Semantic search using Gemini
- βœ… Transformations using Groq
- βœ… Insights using Groq
- βœ… Long context (1M tokens!) using Gemini
- βœ… All for **$0/month** (AI costs)

### Railway Costs:
- First month: **FREE** ($5 credit)
- After: **$5-10/month** (just hosting)

---

## πŸ”§ Models Available

In the UI, you can select from:

### Groq Models (FREE):
- `llama-3.1-70b-versatile` - Best for complex tasks
- `llama-3.1-8b-instant` - Fast for simple tasks
- `mixtral-8x7b-32768` - Alternative option

### Gemini Models (FREE):
- `gemini-1.5-flash` - Fast, FREE
- `gemini-1.5-pro` - 1M context, FREE tier
- `text-embedding-004` - Embeddings

---

## πŸ†˜ If Something Goes Wrong

### Build Fails
β†’ Check Railway logs for error message
β†’ Ensure all files are committed (especially migrations/18.surrealql)

### Services Won't Start
β†’ Check `SURREAL_URL=ws://127.0.0.1:8000/rpc` (not localhost!)
β†’ Verify both API keys are set correctly

### Can't Access App
β†’ Wait 2-3 minutes after deploy
β†’ Check `API_URL` is set to your Railway domain
β†’ Try incognito/private browser window

### Features Don't Work
β†’ Groq models: Check chat works in UI
β†’ Gemini embeddings: Try uploading a document
β†’ If API key issues: Regenerate keys at provider dashboards

---

## πŸ“Š Your Setup Summary

| Component | Configuration | Status |
|-----------|--------------|--------|
| **Database** | SurrealDB (embedded) | βœ… Ready |
| **API** | FastAPI on port 5055 | βœ… Ready |
| **Frontend** | Next.js on port 8080 | βœ… Ready |
| **Worker** | Background tasks | βœ… Ready |
| **LLM** | Groq Llama 3.1 | βœ… FREE |
| **Embeddings** | Gemini | βœ… FREE |
| **Hosting** | Railway | βœ… $5-10/mo |
| **Podcasts** | Not configured | ⏸️ Later |

---

## 🎊 Next Steps After Deploy

1. βœ… Test all features (except podcasts)
2. βœ… Upload some test documents
3. βœ… Try searching and chatting
4. βœ… Generate some insights
5. ⏸️ Configure podcasts later when needed

---

## πŸ’° Cost Tracking

Track your FREE tier usage:
- **Groq**: https://console.groq.com/dashboard
- **Gemini**: https://console.cloud.google.com/apis/dashboard
- **Railway**: https://railway.app/dashboard

All providers show FREE tier limits and usage!

---

## πŸš€ Ready to Deploy!

Everything is configured. Just run:

```powershell
git add .
git commit -m "Railway deployment ready with FREE tier keys"
git push origin main
```

Then watch Railway build and deploy! πŸŽ‰

---

**Questions?** Everything should work exactly like your localhost setup, but on Railway! The same models, same features (minus podcasts), all working with your FREE API keys.