This repo is set up for a three-service split:
| Piece | Where | Cost |
|---|---|---|
| Frontend (React/Vite static build) | Vercel | Free |
| Backend (FastAPI + UniXcoder) | Railway | ~$5–10/mo |
| Vector database | Qdrant Cloud | Free tier (1 GB) |
Total setup time: ~30 minutes plus the migration copy (a few minutes on top).
- Sign up at https://cloud.qdrant.io.
- Create a free-tier cluster (1 GB is plenty for this dataset).
- Copy the cluster URL and generate an API key. You will need both below.
Make sure your local Qdrant container is running and has these collections:
code-files(file contents used by the file endpoint)code-signatures(MiniLM embeddings of function signatures)code-snippets-unixcoder(UniXcoder embeddings; still building on first run)
Then copy them into the cloud cluster:
export SRC_URL=http://localhost:6333
export DST_URL=https://your-cluster-id.aws.cloud.qdrant.io:6333
export DST_API_KEY=your-cloud-api-key
python -m tools.migrate_to_qdrant_cloudIf a collection is not yet ready locally (for example the UniXcoder run is
still going), the script prints skip for it and moves on. Re-run once
it's ready.
-
Push this repo to GitHub.
-
In Railway, click New Project → Deploy from GitHub Repo and pick this repo. Railway detects Dockerfile and railway.json.
-
Set the following service variables in Railway:
Variable Value QDRANT_URLyour Qdrant Cloud URL (e.g. https://xxx.aws.cloud.qdrant.io:6333)QDRANT_API_KEYyour Qdrant Cloud API key CORS_ORIGINSyour Vercel frontend URL (see step 4). Comma-separate multiple. WORKERS1(raise only if you upgrade RAM significantly)INDEXED_COMMITthe qdrant/qdrant SHA the collections were built from, printed at the end of the indexing log. Result links carry line numbers and only match at that commit; leave it unset and they resolve against master, drifting as the source moves. -
Railway will build and expose a URL like
https://code-search-api.up.railway.app. Wait for the health check at/api/healthto pass; first boot takes ~30–60s because the UniXcoder model loads into memory. -
Copy that URL — you'll paste it into Vercel next.
Sizing note. UniXcoder plus MiniLM want about 2 GB of RAM to be comfortable. The free/Hobby "Starter" instance (512 MB) will OOM. Use Railway's Hobby plan (2 GB) or higher.
-
In Vercel, click Add New → Project and import this repo.
-
Set the Root Directory to
frontend. Vercel picks up vercel.json automatically. -
Under Environment Variables, add:
Variable Value VITE_API_URLyour Railway backend URL, no trailing slash -
Click Deploy. Vercel gives you a URL like
https://code-search.vercel.app. -
Go back to Railway and update
CORS_ORIGINSwith that exact URL. Railway redeploys automatically.
- Hit the frontend URL — you should see the hero.
- Run one of the demo queries. You should see results (semantic if UniXcoder is loaded, "Warming Up" keyword mode otherwise).
- Click into a code card and hit "load more lines" — the file endpoint should return 200s.
- Search returns 500 with a Qdrant 404 error: the target collection was
not migrated. Re-run
python -m tools.migrate_to_qdrant_cloud. - CORS error in browser console: the frontend URL isn't in
CORS_ORIGINSon Railway. Add it (comma-separated for multiple). - Backend crashes on boot with OOM: raise the Railway plan to at least
2 GB, or switch to a MiniLM-only build (drop UniXcoder from
CodeSearcher). - Slow first request: normal. UniXcoder loads once per container, then requests are fast.
Both Vercel and Railway support custom domains. If you attach one to the
frontend, remember to update CORS_ORIGINS on Railway to include it.