|
| 1 | +# DevFlow AI: Production Deployment & Verification |
| 2 | + |
| 3 | +## 1. Cloud Infrastructure & Architecture |
| 4 | + |
| 5 | +Moving from a local Docker Compose setup to a production-ready cloud architecture required distributing our services across multiple specialized platforms to balance cost, performance, and scalability. The final production architecture is 100% free-tier compliant while maintaining high availability. |
| 6 | + |
| 7 | +### 1.1 Web Frontend (Vercel) |
| 8 | +- **Host**: Vercel |
| 9 | +- **Live URL**: `https://dev-flow-ai-five.vercel.app` |
| 10 | +- **Why**: Vercel provides zero-config Next.js deployments, global CDN caching, and automatic CI/CD from GitHub. |
| 11 | +- **Configuration**: The `NEXT_PUBLIC_API_URL` environment variable was set to point to the production Render backend instead of localhost. |
| 12 | + |
| 13 | +### 1.2 Backend API (Render) |
| 14 | +- **Host**: Render (Web Service) |
| 15 | +- **Live URL**: `https://devflow-api-comy.onrender.com` |
| 16 | +- **Why**: Render offers native Node.js/NestJS support, easy environment variable management, and automatic HTTPS. |
| 17 | +- **Configuration**: Configured CORS to whitelist the Vercel frontend domain, preventing unauthorized clients from accessing the API. |
| 18 | + |
| 19 | +### 1.3 PostgreSQL Database (Neon) |
| 20 | +- **Host**: Neon.tech |
| 21 | +- **Why**: Serverless Postgres that scales to zero and supports the `pgvector` extension out of the box, which is critical for our RAG (Retrieval-Augmented Generation) embeddings. |
| 22 | +- **Configuration**: The `DATABASE_URL` was securely stored in Render. We executed `npx prisma migrate deploy` and `npx prisma db seed` during the build step. |
| 23 | + |
| 24 | +### 1.4 Redis Cache (Upstash) |
| 25 | +- **Host**: Upstash |
| 26 | +- **Why**: Serverless Redis with a generous free tier. It provides the exact same API as local Redis, making it a drop-in replacement. |
| 27 | +- **Usage**: Used for BullMQ background job processing, caching GitHub repositories, and JWT session blacklisting. |
| 28 | + |
| 29 | +### 1.5 AI Runtime (Oracle Cloud Infrastructure) |
| 30 | +- **Host**: Oracle Cloud "Always Free" ARM VM |
| 31 | +- **IP**: `http://152.67.112.59:11434` |
| 32 | +- **Why**: Ollama requires significant RAM to run models like LLaMA 3. Oracle Cloud provides a 24GB RAM / 4 OCPU ARM instance entirely for free, which is perfect for hosting an LLM API. |
| 33 | +- **Configuration**: Configured `OLLAMA_HOST=0.0.0.0` and opened port `11434` in the Oracle Cloud VCN ingress rules. The backend connects to this via the `OLLAMA_URL` environment variable. |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## 2. Production Verification & Testing |
| 38 | + |
| 39 | +To ensure the system works reliably under real-world conditions, we implemented two rigorous testing suites. |
| 40 | + |
| 41 | +### 2.1 End-to-End (E2E) Testing with Playwright |
| 42 | +We implemented automated browser tests to verify critical user flows in the live production environment. |
| 43 | +- **Framework**: Playwright |
| 44 | +- **Coverage**: User Registration, Login, Workspace Creation, Project Setup. |
| 45 | +- **Execution**: The tests were configured to dynamically use `PLAYWRIGHT_TEST_BASE_URL=https://dev-flow-ai-five.vercel.app`. |
| 46 | +- **Result**: The test suite successfully completed all end-to-end flows in **15.8 seconds** with zero errors. |
| 47 | + |
| 48 | +### 2.2 API Load Testing with k6 |
| 49 | +To verify that our free-tier architecture (specifically Neon and Render) wouldn't collapse under a sudden influx of traffic, we used `k6` to stress-test the backend. |
| 50 | +- **Framework**: k6 by Grafana |
| 51 | +- **Scenario**: 50 concurrent Virtual Users (VUs) constantly hitting the `/` endpoint and the `/auth/login` endpoint for 60 seconds. |
| 52 | +- **Result**: |
| 53 | + - Over 1,800 requests were processed. |
| 54 | + - The NestJS `ThrottlerModule` (Rate Limiter) successfully intercepted the flood. It allowed exactly 100 requests per IP and returned `429 Too Many Requests` for the rest, preventing database connection exhaustion. |
| 55 | + - 95th percentile latency (p95) for successful requests remained under 800ms. |
0 commit comments