# Starting All Services

## Quick Start Guide

### 1. Start FastAPI Backend (Port 8000)

```bash
cd /home/stark/Downloads/PLAGIS_AUMENTUM-main
source venv/bin/activate
export CONTENTSTORE_BASE=~/aumentum_contentstore
uvicorn aumentum_api:app --host 0.0.0.0 --port 8000 --reload
```

**Or use the start script:**
```bash
./start-api
```

### 2. Start Next.js Frontend (Port 3000)

```bash
# Make sure Node.js 20 is active
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm use 20

# Start Next.js
cd plagis-nextjs
npm run dev
```

## Services

- **FastAPI Backend**: http://localhost:8000
  - API Docs: http://localhost:8000/docs
  - Health: http://localhost:8000/health

- **Next.js Frontend**: http://localhost:3000

## Environment Setup

### For FastAPI:
```bash
export CONTENTSTORE_BASE=~/aumentum_contentstore
```

### For Node.js:
```bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm use 20
```

## Make Persistent

Add to `~/.bashrc`:
```bash
# NVM Setup
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

# Contentstore
export CONTENTSTORE_BASE=~/aumentum_contentstore
```

## Test Endpoints

```bash
# Test API
curl "http://localhost:8000/health"
curl "http://localhost:8000/documents/by-document-number?document_number=BP1133"

# Test Frontend
curl "http://localhost:3000"
```

