# Deployment Guide for Mnehmos Screen Vision Knowledge Base
---
## Quick Start: Local Development
### Step 1: Install Dependencies
```bash
cd C:\Users\mnehm\AppData\Roaming\Roo-Code\MCP\IndexFoundry\projects\mnehmos-screen-vision
npm install
```
### Step 2: Configure Environment
Add your OpenAI API key to the `.env` file:
```bash
# Open .env and add your key:
OPENAI_API_KEY=sk-proj-your-key-here
```
### Step 3: Start the Server
```bash
npm run dev
```
You should see:
```
Loaded X sources
Loaded Y chunks, Y vectors
HTTP server listening on port 8765
```
### Step 4: Test the Frontend
1. Copy `frontend/local.config.js.example` to `frontend/local.config.js`
2. Open `frontend/index.html` in your browser
3. The status should show "Ready" (green indicator)
4. Ask a question to verify the chat works!
### Step 5: Verify API Endpoints
```bash
# Health check
curl http://localhost:8765/health
# Search test
curl -X POST http://localhost:8765/search \
-H "Content-Type: application/json" \
-d '{"query": "test", "mode": "keyword", "top_k": 5}'
```
---
## Production Deployment
### Prerequisites
| Requirement | Where to Get It |
|-------------|-----------------|
| GitHub Account | [github.com](https://github.com) |
| Railway Account | [railway.app](https://railway.app) |
| OpenAI API Key | [platform.openai.com/api-keys](https://platform.openai.com/api-keys) |
---
### Step 1: Push to GitHub
```bash
cd C:\Users\mnehm\AppData\Roaming\Roo-Code\MCP\IndexFoundry\projects\mnehmos-screen-vision
git init
git add .
git commit -m "Initial commit"
gh repo create mnehmos-screen-vision --public --push
```
Or manually create a repo at [github.com/new](https://github.com/new) and push.
---
### Step 2: Deploy to Railway
1. Go to [railway.app/dashboard](https://railway.app/dashboard)
2. Click **"New Project"** → **"Deploy from GitHub repo"**
3. Select your `mnehmos-screen-vision` repository
4. Railway will auto-detect the Dockerfile
---
### Step 3: Configure Environment Variables
In Railway dashboard → your service → **"Variables"** tab:
| Variable | Value | Required |
|----------|-------|----------|
| `OPENAI_API_KEY` | `sk-proj-...` | ✅ Yes |
| `PORT` | `8765` | ❌ Auto-set |
| `OPENAI_MODEL` | `gpt-5-nano-2025-08-07` | ❌ Optional |
> ⚠️ **Never commit API keys to Git!**
---
### Step 4: Get Your Public URL
1. In Railway → **"Settings"** → **"Networking"**
2. Click **"Generate Domain"**
3. Copy your URL: `https://mnehmos-screen-vision-production.up.railway.app`
---
### Step 5: Verify Deployment
#### Health Check
```bash
curl https://YOUR-APP.railway.app/health
```
#### Test Search
```bash
curl -X POST https://YOUR-APP.railway.app/search \
-H "Content-Type: application/json" \
-d '{"query": "test", "mode": "keyword", "top_k": 5}'
```
#### Test Chat
```bash
curl -X POST https://YOUR-APP.railway.app/chat \
-H "Content-Type: application/json" \
-d '{"question": "What is this about?"}'
```
---
## API Reference
| Endpoint | Method | Description |
|----------|--------|-------------|
| `/health` | GET | Health check |
| `/stats` | GET | Index statistics |
| `/sources` | GET | List sources |
| `/search` | POST | RAG search |
| `/chat` | POST | Chat with streaming |
| `/chunks/:id` | GET | Get chunk by ID |
---
## Troubleshooting
### API Key Not Loaded
If you get "OPENAI_API_KEY not configured":
- Ensure you added your key to `.env` (not `.env.example`)
- The `.env` file should NOT be committed to git
### Port Already in Use
If port 8765 is busy:
- Change PORT in `.env` to another port (e.g., 3001)
- Update `frontend/local.config.js` to match
### Build Failed
- Check build logs in Railway dashboard
- Ensure `npm run build` works locally
### Health Check Failed
- Verify `OPENAI_API_KEY` is set
- Check runtime logs for errors
### Chat Returns 500
- Check OpenAI API quota
- Verify API key is valid
---
## Frontend Deployment
The project includes a ready-to-use chat interface in the `frontend/` directory.
### Option 1: GitHub Pages (Recommended for Static)
1. Push your repo to GitHub
2. Go to **Settings** → **Pages**
3. Set Source to **Deploy from a branch**
4. Select **main** branch and **`/frontend`** folder
5. Your chat UI will be live at `https://USERNAME.github.io/REPO-NAME/`
### Option 2: Serve from Railway (Same Origin)
The frontend is automatically served from the root path when deployed.
### Option 3: Any Static Host
Upload the contents of `frontend/` to:
- Netlify
- Vercel
- AWS S3 + CloudFront
- Any web server
---
*Generated by IndexFoundry*