GhostWriter Complete Setup Guide
Walks through setting up a full-stack app with a Go backend, React frontend, and iOS client, including Docker, database, and push notifications.
What this file does
Walks through setting up a full-stack app with a Go backend, React frontend, and iOS client, including Docker, database, and push notifications.
When to use it
- You are cloning the GhostWriter repository and need to run all three tiers
- You want to test WebSocket sync between a mobile app and a Go API
- You need to configure pgvector and semantic search in a new project
Assumes this stack
GhostWriter Complete Setup Guide
This guide will help you set up the complete GhostWriter stack: Backend (Go), Frontend (Web), and iOS App.
Table of Contents
Prerequisites
Required Software
- Docker & Docker Compose (for backend services)
- Node.js 20+ and npm (for frontend)
- Go 1.22+ (for backend development)
- Xcode 15+ (for iOS app)
- PostgreSQL 17+ with pgvector (via Docker)
- Redis 7+ (via Docker)
Optional
- OpenAI API Key (for semantic search embeddings)
- Apple Developer Account (for push notifications)
Backend Setup
Method 1: Docker Compose (Recommended)
This starts PostgreSQL, Redis, and the Go API all together.
-
Navigate to the repository root:
cd /path/to/GhostWriter- -
Configure environment variables:
cd backend-go cp .env.template .envEdit
.envand add your configuration:OPENAI_API_KEY: Your OpenAI API keyAPNS_*: Apple Push Notification credentials (optional)
-
Start all services:
cd .. docker compose up -d -
Check logs:
docker compose logs -f ghost-api -
Verify services are running:
# Check health endpoint curl http://localhost:8080/health # Should return: {"status":"healthy","timestamp":"...","service":"ghostwriter-api"}
Method 2: Manual Setup (Development)
If you want to run the backend without Docker:
-
Install and start PostgreSQL with pgvector:
# Install PostgreSQL 17 # Then install pgvector extension psql -U postgres -c "CREATE EXTENSION vector;" -
Install and start Redis:
redis-server -
Build and run the Go backend:
cd backend-go # Install dependencies go mod download # Configure environment cp .env.template .env # Edit .env with your settings # Build go build -o server ./cmd/server # Run ./server
The API will be available at http://localhost:8080.
Backend API Endpoints
GET /health- Health checkGET /ws- WebSocket connection for real-time syncPOST /vault/search- Semantic search endpointGET /entries?user_id=<uuid>&limit=100- Get user entries
Database Schema
The backend automatically creates the following schema on startup:
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE portal_entries (
id SERIAL PRIMARY KEY,
user_id UUID NOT NULL,
text_content TEXT NOT NULL,
embedding VECTOR(512),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Indexes for performance
CREATE INDEX idx_portal_entries_user_id ON portal_entries(user_id);
CREATE INDEX idx_portal_entries_created_at ON portal_entries(created_at);
CREATE INDEX idx_portal_entries_embedding ON portal_entries
USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100);
Frontend Setup
The frontend is a React/TypeScript web application.
-
Install dependencies:
npm install -
Start development server:
npm run dev -
Access the app:
- Local:
http://localhost:5173 - Network (for mobile testing):
http://YOUR_IP:5173
- Local:
-
For mobile testing:
npm run dev:hostThen access from your mobile device using your computer's IP address.
iOS App Setup
Prerequisites
- macOS with Xcode 15+
- iOS 17+ device or simulator
- Apple Developer account (for push notifications)
Setup Steps
-
Open Xcode:
- Create a new iOS App project
- Choose SwiftUI as the interface
- Choose Swift as the language
-
Add Swift files: Copy all
.swiftfiles fromios-native/to your Xcode project:- GhostWriterApp.swift
- EnhancedContentView.swift (set as main view)
- ContentView.swift
- VaultView.swift
- WebSocketClient.swift
- APIClient.swift
- PushNotificationManager.swift
- ExportView.swift
- ViewModel.swift
- Models.swift
- OCRService.swift
- TextPipeline.swift
- VideoFrameExtractor.swift
- ShareSheet.swift
-
Configure capabilities:
- In Xcode, go to Signing & Capabilities
- Add Push Notifications
- Add Background Modes → Remote notifications
- Add iCloud → iCloud Documents
-
Update Info.plist: Add these keys:
<key>NSPhotoLibraryUsageDescription</key> <string>We need access to your photos to extract text from screenshots</string> <key>NSUserNotificationsUsageDescription</key> <string>We'll notify you when text processing is complete</string> -
Configure backend URL: In the app's Settings tab, update the server URL to point to your backend:
- Local:
ws://localhost:8080/ws - Network:
ws://YOUR_COMPUTER_IP:8080/ws - Production:
wss://your-server.com/ws
- Local:
-
Build and run:
- Select your device/simulator
- Click Run (⌘R)
Push Notifications Setup (Optional)
To enable push notifications:
-
Generate APNS credentials:
- Go to Apple Developer Portal
- Create an APNS key or certificate
- Download the .p8 key file
-
Configure backend: In
backend-go/.env, add:APNS_AUTH_MODE=token APNS_KEY_PATH=/path/to/AuthKey_XXXXXXXXXX.p8 APNS_KEY_ID=XXXXXXXXXX APNS_TEAM_ID=XXXXXXXXXX APNS_TOPIC=com.yourcompany.ghostwriter APNS_PRODUCTION=false -
Restart backend:
docker compose restart ghost-api
Testing the Integration
1. Test Backend Health
curl http://localhost:8080/health
Expected response:
{
"status": "healthy",
"timestamp": "2026-01-27T00:00:00Z",
"service": "ghostwriter-api"
}
2. Test WebSocket Connection
You can use a WebSocket client or the iOS app to test:
// JavaScript example
const ws = new WebSocket('ws://localhost:8080/ws')
ws.onopen = () => {
console.log('Connected')
// Send a test message
ws.send(
JSON.stringify({
type: 'text_sync',
user_id: 'test-user-123',
text_content: 'Hello from WebSocket!',
timestamp: new Date().toISOString(),
})
)
}
ws.onmessage = event => {
console.log('Response:', event.data)
}
3. Test Semantic Search
First, insert some data via WebSocket, then search:
curl -X POST http://localhost:8080/vault/search \
-H "Content-Type: application/json" \
-d '{
"user_id": "test-user-123",
"query": "Hello",
"limit": 10
}'
4. Test iOS App
- Open the iOS app
- Go to Settings tab
- Enter your backend URL
- Connect to WebSocket
- Go to Capture tab
- Upload screenshots or recordings
- Run OCR
- Check Vault tab to see synced entries
Troubleshooting
Backend Issues
Problem: Backend fails to start
- Check if PostgreSQL is running:
docker compose ps - Check logs:
docker compose logs ghost-api - Verify database connection string in
.env
Problem: Embeddings not generated
- Check if
OPENAI_API_KEYis set in.env - Verify API key is valid
- Check logs for API errors
iOS App Issues
Problem: Cannot connect to backend
- Verify backend is running:
curl http://YOUR_IP:8080/health - Check firewall settings
- Use correct URL format:
ws://nothttp://
Problem: Push notifications not working
- Verify APNS is configured in backend
- Check device token is registered
- Ensure app has notification permissions
Problem: OCR not working
- Grant photo library permissions
- Check iOS version (requires iOS 17+)
- Verify Vision framework is available
Network Issues
Problem: Mobile device can't access backend
- Ensure both devices are on same network
- Check firewall rules
- Use
npm run dev:hostfor frontend - Use computer's IP address, not
localhost
Database Issues
Problem: pgvector extension not found
- Ensure using
pgvector/pgvector:pg17Docker image - Check extension is created:
docker compose exec vault-db psql -U bobby_admin -d ghostwriter_vault -c "SELECT * FROM pg_extension;"
Production Deployment
Backend
-
Build Docker image:
cd backend-go docker build -t ghostwriter-backend:latest . -
Deploy to your preferred platform:
- Kubernetes
- Docker Swarm
- Cloud providers (AWS ECS, Google Cloud Run, etc.)
-
Use production environment variables:
- Set
APNS_PRODUCTION=true - Use secure database credentials
- Enable TLS for WebSocket (
wss://)
- Set
Frontend
-
Build for production:
npm run build -
Deploy to static hosting:
- Vercel (recommended)
- Netlify
- AWS S3 + CloudFront
- Any static hosting service
iOS App
-
Configure for production:
- Update server URL to production endpoint
- Use production APNS certificates
-
Build for TestFlight/App Store:
- Archive in Xcode
- Submit to App Store Connect
Support
For issues and questions:
- GitHub Issues: Report a bug
- Documentation: Check
README.md,backend-go/README.md,ios-native/README.md
License
MIT License - see LICENSE file for details.
What's inside
7 sections covering prerequisites, backend, frontend, iOS, testing, troubleshooting, and production deployment
Change this for your project
- Replace
Bboy9090/GhostWriter-with your own repository path - Replace
bobby_adminandghostwriter_vaultwith your database user and database name - Replace
com.yourcompany.ghostwriterwith your own bundle identifier - Replace
ws://localhost:8080/wswith your own server URL
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Worth borrowing
- Using a health endpoint to verify service readiness before integration tests
- Separating Docker Compose for production vs manual setup for development
- Providing both curl and JavaScript WebSocket examples for testing
Related Documents
Incident Response Runbooks - Deal Scout
Defines step-by-step procedures for 9 incident types plus a rollback and escalation policy for a Docker-based deal-scraping service.
Document Preview & Download Feature - Complete Guide
Adds document preview and download endpoints that retrieve files from MinIO and serve them through the application with caching and security.
On-Call Policy
Defines a weekly on-call rotation, escalation matrix, paging procedures, and shift handoff process for engineering teams.
SRO-001 On-Call & Incident Response
Defines a complete on-call schedule, incident severity levels, response procedures, and post-incident analysis workflow for SRE teams.