Commit graph

12 commits

Author SHA1 Message Date
Vadym Samoilenko
a6fc149788 Replace WebSocket with REST polling to fix GCP LB 30s timeout
POST /api/analyze submits an analysis job and returns job_id instantly.
GET /api/analyze/{job_id} returns progress + result; frontend polls every 2s.

Analysis runs as asyncio.create_task in the background — each HTTP request
completes in milliseconds, well within the 30s GCP Load Balancer limit.

- Add backend/app/services/job_store.py: in-memory AnalysisJob store with
  30-min TTL cleanup
- Add backend/app/api/analysis_routes.py: POST + GET /api/analyze endpoints
  with full analysis pipeline (hash check, DB persistence, PDF pages, etc.)
- Remove backend/app/websocket/: handlers.py, manager.py, __init__.py
- Update backend/app/main.py: wire analysis_router, store analysis_service
  in app.state, drop all WebSocket imports and endpoint
- Update frontend/services/geminiService.ts: replace WS with fetch+poll;
  function signatures unchanged so App.tsx / WIPReviewer.tsx need no edits
- Remove VITE_BACKEND_WS_URL from vite.config.ts, deploy.sh, .env.deploy.example
- Update cloudrun.yaml: remove WebSocket-specific session affinity annotation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 15:26:01 +00:00
Vadym Samoilenko
da63629720 Auto-generate backend/.env and frontend/.env.local from .env.deploy
The deploy script now generates both env files automatically — no more
manual file creation on the server. All secrets and VITE_ vars are
centralised in .env.deploy (gitignored). Updated .env.deploy.example
with all required variables and inline documentation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 11:57:17 +00:00
Vadym Samoilenko
3a66286900 Remove DATABASE_URL check from deploy.sh — injected by docker-compose
DATABASE_URL is set via the environment block in docker-compose.yml
and does not need to be present in backend/.env.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 11:23:46 +00:00
Vadym Samoilenko
f24ef038ef Validate critical env vars in deploy.sh before deployment
The script previously only checked that backend/.env existed, allowing
deployments with unset or placeholder values. This meant GEMINI_API_KEY
could be missing, causing every analysis to fail at 80% with a
PERMISSION_DENIED error from the Gemini API.

Now checks GEMINI_API_KEY, AZURE_TENANT_ID, AZURE_CLIENT_ID, and
DATABASE_URL are set to real values before any build step runs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 11:21:32 +00:00
michael
f4fd850a49 Force recreate backend container on deploy
Ensures new code changes are picked up by using --force-recreate
flag when starting the backend container.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 10:24:43 -06:00
michael
cc2c68bb02 Auto-discard package-lock.json changes before git pull
The package-lock.json changes when npm install runs on different
platforms/npm versions. Since deploy.sh runs npm install anyway,
discard local changes to this file before pulling to avoid conflicts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 10:42:54 -06:00
michael
e06dd414c9 Don't overwrite frontend/.env.local in deploy script
- Remove auto-generation of frontend/.env.local
- Instead, check that it exists and fail with helpful message if not
- Update .env.deploy.example to document manual .env.local setup

This allows manual management of frontend credentials without
the deploy script overwriting them.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 10:41:14 -06:00
michael
fed9bb26bf Add Azure AD MSAL variables to deploy script
- Include VITE_AZURE_CLIENT_ID, VITE_AZURE_TENANT_ID, and
  VITE_AZURE_REDIRECT_URI in frontend .env.local generation
- Document these variables in .env.deploy.example

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 10:39:15 -06:00
michael
99af0164e6 Add PostgreSQL database support with Alembic migrations
Backend:
- Add PostgreSQL service to docker-compose with health checks
- Add SQLAlchemy async models for all entities (Agency, User, Campaign,
  Proof, ProofVersion, FlaggedItem, ResolvedItem, ErrorItem)
- Add Alembic migration framework with initial schema migration
- Add repository layer for CRUD operations
- Add REST API endpoints for campaigns, proofs, and audit items
- Add file storage service for proof uploads
- Update WebSocket handler to optionally persist analysis results

Frontend:
- Add apiService.ts for REST API communication
- Update geminiService.ts to support database persistence options

Deployment:
- Update deploy.sh to handle database migrations (6-step process)
- Update Dockerfile to include alembic configuration
- Add PostgreSQL environment variables to .env templates

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 12:27:18 -06:00
michael
3df1b9fb92 Auto-generate .env for docker compose commands
The deploy script now creates a .env file with COMPOSE_PROJECT_NAME
and BACKEND_PORT so that manual docker compose commands (ps, logs, etc.)
work without needing to set environment variables.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 06:37:41 -06:00
michael
27113a625a Support multiple instances (prod/dev) on same server
- Add COMPOSE_PROJECT_NAME for unique container names
- Add BACKEND_PORT for configurable port mapping
- Update deploy.sh to export variables for docker compose
- Update health checks to use configured port

Allows running prod and dev instances simultaneously by cloning
the repo twice with different .env.deploy configurations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-15 15:10:20 -06:00
michael
834de7d74c Add deployment script for Ubuntu server
- Add deploy.sh for automated deployment (idempotent)
- Add .env.deploy.example template for server configuration
- Update .gitignore to exclude .env.deploy

The script handles both first-time install and updates:
- Pulls latest code from git
- Builds frontend with production URLs
- Deploys to Apache document root
- Rebuilds and restarts Docker backend
- Includes health check verification

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-15 14:50:49 -06:00