diff --git a/README.md b/README.md index e215bc4..15897d3 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,85 @@ -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). +# StageAI -## Getting Started +WebApp for stage law attorneys (Bühnenrecht). Built with Next.js, PostgreSQL, Meilisearch, and AI-powered contract analysis. -First, run the development server: +## Prerequisites + +- Docker & Docker Compose +- Node.js 20+ (for local development) +- Git + +## Quick Start (Docker) ```bash -npm run dev -# or -yarn dev -# or -pnpm dev -# or -bun dev +# Clone the repo +git clone https://mgit.msbls.de/Remmer/StageAI.git +cd StageAI + +# Set up environment +cp .env.example .env +# Edit .env with your API keys and secrets + +# Start all services +docker compose up -d + +# Run database migrations +docker compose exec app npx drizzle-kit push ``` -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. +The app will be available at http://localhost:3000. -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. +## Environment Variables -This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. +| Variable | Description | Required | +|---|---|---| +| `DATABASE_URL` | PostgreSQL connection string | Yes | +| `NEXTAUTH_URL` | App URL for authentication | Yes | +| `NEXTAUTH_SECRET` | Random secret for session encryption | Yes | +| `AI_PROVIDER` | `anthropic` or `openai` | Yes | +| `ANTHROPIC_API_KEY` | Anthropic API key | If using Anthropic | +| `OPENAI_API_KEY` | OpenAI API key | If using OpenAI | +| `MEILISEARCH_URL` | Meilisearch URL | Yes | +| `MEILISEARCH_API_KEY` | Meilisearch master key | Yes | -## Learn More +## Local Development -To learn more about Next.js, take a look at the following resources: +```bash +npm install +npm run dev +``` -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. +## Database Migrations -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! +Migrations are in the `drizzle/` directory, managed by Drizzle Kit. -## Deploy on Vercel +```bash +# Generate a new migration after schema changes +npx drizzle-kit generate -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. +# Apply migrations +npx drizzle-kit push +``` -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. +## Deployment (VPS) + +A deployment script is included for the production VPS: + +```bash +# On the VPS (remmer@100.81.230.53): +cd /home/remmer/StageAI +./deploy.sh +``` + +This pulls the latest code from Gitea and rebuilds the app container. PostgreSQL and Meilisearch containers are kept running. + +## Services + +| Service | Port | Description | +|---|---|---| +| App (Next.js) | 3000 | Main application | +| PostgreSQL | 5432 | Database | +| Meilisearch | 7700 | Full-text search engine | + +## Repository + +Source code: https://mgit.msbls.de/Remmer/StageAI diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..f6f3c92 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +set -euo pipefail + +# StageAI Deployment Script +# Pulls latest code from Gitea and redeploys via Docker Compose +# +# Usage (on VPS): +# ./deploy.sh # Pull & redeploy +# ./deploy.sh --build-only # Pull & rebuild without restarting + +APP_DIR="/home/remmer/StageAI" +PROJECT_NAME="stageai" +REPO_URL="https://mgit.msbls.de/Remmer/StageAI.git" +BRANCH="master" + +BUILD_ONLY=false +if [[ "${1:-}" == "--build-only" ]]; then + BUILD_ONLY=true +fi + +echo "=== StageAI Deployment ===" +echo "Directory: $APP_DIR" +echo "Branch: $BRANCH" +echo "" + +# Navigate to app directory +if [[ ! -d "$APP_DIR" ]]; then + echo "App directory not found. Cloning repo..." + git clone "$REPO_URL" "$APP_DIR" +fi + +cd "$APP_DIR" + +# Pull latest changes +echo "Pulling latest changes..." +git fetch origin "$BRANCH" +git reset --hard "origin/$BRANCH" +echo "Updated to: $(git log --oneline -1)" + +# Rebuild containers +echo "" +echo "Rebuilding containers..." +docker compose -p "$PROJECT_NAME" build --no-cache app + +if [[ "$BUILD_ONLY" == true ]]; then + echo "" + echo "Build complete (--build-only mode, skipping restart)." + exit 0 +fi + +# Restart app container (keep postgres and meilisearch running) +echo "" +echo "Restarting app container..." +docker compose -p "$PROJECT_NAME" up -d app + +echo "" +echo "Waiting for app to start..." +sleep 5 + +# Health check +if curl -sf http://localhost:3000 > /dev/null 2>&1; then + echo "App is running at http://localhost:3000" +else + echo "Warning: App may not be ready yet. Check logs with:" + echo " docker compose -p $PROJECT_NAME logs -f app" +fi + +echo "" +echo "=== Deployment complete ===" +echo "" +echo "Useful commands:" +echo " docker compose -p $PROJECT_NAME logs -f app # View app logs" +echo " docker compose -p $PROJECT_NAME ps # Container status" +echo " docker compose -p $PROJECT_NAME restart app # Restart app only"