Deployment Guide
Relevant source files
The following files were used as context for generating this wiki page:
- README.md
- CLAUDE.md
- package.json
- app/(chat)/api/files/upload/route.ts/api/files/upload/route.ts)
- lib/ai/prompts.ts
The deployment of LV.AI involves configuring a Next.js 16 application with a PostgreSQL database, an OpenAI-compatible AI provider (9Router), and a storage solution for construction documents. The system is optimized for the D/A/CH region and uses a dual-memory architecture via mem0 for project-specific and global contexts.
Sources: README.md:1-25, CLAUDE.md:1-35
Infrastructure Requirements
LV.AI requires several core components for a successful deployment:
- Runtime: Node.js 20+ with pnpm 10+.
- Database: PostgreSQL (Neon Postgres recommended) with Drizzle ORM.
- AI Gateway: 9Router (NeXify Multi-Provider-Gateway) for DeepSeek V4 and OpenAI-compatible models.
- Storage: Vercel Blob for production or a local file system fallback for development.
- Memory: mem0 for project and session persistence.
Sources: README.md:31-40, CLAUDE.md:37-45, app/(chat)/api/files/upload/route.ts:28-32
AI Architecture Flow
The following diagram illustrates how the application interacts with the AI infrastructure, specifically the 9Router gateway and the Headroom context optimizer.
The application routes AI requests through 9Router, which utilizes Headroom for context optimization and token caching before reaching the LLM backends.
Sources: CLAUDE.md:60-70, README.md:25-30
Environment Configuration
You must configure the following environment variables in a .env file to enable database connectivity, authentication, and AI provider access.
| Variable | Description | Required |
|---|---|---|
AUTH_SECRET | Secret key for Auth.js session signing | Yes |
OPENAI_API_KEY | API Key for the 9Router gateway | Yes |
OPENAI_BASE_URL | Endpoint URL (http://127.0.0.1:20128/v1 or public HTTPS) | Yes |
POSTGRES_URL | Full PostgreSQL connection string | Yes |
BLOB_READ_WRITE_TOKEN | Token for Vercel Blob storage (Production only) | No |
MEM0_API_KEY | API Key for mem0 integration | No |
LV_PASSWORD | Password for the MVP gate (Default: LV2026!!) | No |
Sources: README.md:57-67, CLAUDE.md:65-72, app/(chat)/api/files/upload/route.ts:28-32
Storage Strategy
LV.AI implements a dual-storage strategy based on the presence of the BLOB_READ_WRITE_TOKEN.
- Production (Vercel Blob): If the token is present, files are uploaded to Vercel's global storage under the
lv-ai/prefix. - Development (Local): If the token is missing, the system writes files to
public/uploads/lv-ai/within the project root.
The file upload system supports construction-specific formats including PDF, GAEB XML (.xml, .gaeb), Excel (.xlsx, .xls), Word, and CSV, with a maximum size limit of 20MB per file.
Sources: app/(chat)/api/files/upload/route.ts:7-32, app/(chat)/api/files/upload/route.ts:85-115
Storage Logic Flow
The upload route automatically toggles between local disk and cloud storage based on environment configuration.
Sources: app/(chat)/api/files/upload/route.ts:34-110
Deployment Procedure
Follow these steps to deploy the application to a new environment:
- Clone and Install:
git clone <repository-url> pnpm install - Database Preparation: Generate and push the schema using Drizzle Kit.
pnpm db:generate pnpm db:migrate - Build Application:
pnpm build - Start Production Server:
pnpm start
Sources: README.md:42-55, package.json:7-15
Deployment Checklist (LV.AI Protocol)
Before completing a deployment or infrastructure change, verify these specific items:
- GAEB Integrity: Ensure Import/Export logic in
lib/gaeb/is functional after environment changes. - Memory Scope: Confirm that
mem0-mcpcorrectly distinguishes between Project-Scope and Global-Scope. - Infrastructure Consistency: Verify DNS and domain routing if utilizing Hostinger connectors (
hostinger-dns,hostinger-vps). - Storage Access: Test file uploads to ensure the correct storage backend (Local vs Vercel Blob) is active.
Sources: CLAUDE.md:98-115
LV.AI is a highly specialized AVA expert system. A successful deployment ensures that all legal frameworks (VOB, ÖNORM, SIA) and GAEB data structures are correctly handled across the integrated AI and database layers.