> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeus.ttr.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Set up the Zeus Rust server

## Prerequisites

* **Rust** (latest stable)
* **PostgreSQL** (14 or later)
* **Docker** (optional)
* **Git**

## Option 1: Docker (Recommended)

The fastest way to get started:

```bash theme={null}
# Clone the repository
git clone https://github.com/olympia-hq/zeus.git
cd zeus

# Start PostgreSQL
docker-compose up -d postgres

# Run migrations
cd server
cargo install sqlx-cli --no-default-features --features native-tls,postgres
cargo sqlx migrate run

# Start the server
cargo run
```

The server will be running at `http://localhost:3000`.

## Option 2: Manual Setup

### 1. Install Rust

```bash theme={null}
# Using rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Verify
rustc --version
cargo --version
```

### 2. Install PostgreSQL

**macOS:**

```bash theme={null}
brew install postgresql@14
brew services start postgresql@14
```

**Ubuntu:**

```bash theme={null}
sudo apt-get install postgresql-14
sudo service postgresql start
```

**Windows:**
Download from [postgresql.org](https://www.postgresql.org/download/windows/)

### 3. Setup Database

```bash theme={null}
# Create database
createdb zeus

# Install SQLx CLI
cargo install sqlx-cli --no-default-features --features native-tls,postgres

# Run migrations
cd server
cargo sqlx migrate run
```

### 4. Configure Environment

Create `.env` file:

```bash theme={null}
DATABASE_URL=postgres://localhost/zeus
RUST_LOG=info
PORT=3000
```

### 5. Build and Run

```bash theme={null}
# Build
cargo build

# Run
cargo run

# Or run in release mode
cargo run --release
```

## Verify Installation

```bash theme={null}
# Health check
curl http://localhost:3000/health

# Expected response
{"status": "healthy"}
```

## Development Workflow

### Watch Mode

Automatically rebuild on changes:

```bash theme={null}
cargo install cargo-watch
cargo watch -x run
```

### Run Tests

```bash theme={null}
# All tests
cargo test

# Specific test
cargo test test_name

# With output
cargo test -- --nocapture
```

### Database Migrations

```bash theme={null}
# Create new migration
cargo sqlx migrate add <name>

# Run pending migrations
cargo sqlx migrate run

# Revert last migration
cargo sqlx migrate revert
```

## Common Issues

### Database Connection Failed

```bash theme={null}
# Check PostgreSQL is running
pg_isready

# Verify database exists
psql -l | grep zeus
```

### Compilation Errors

```bash theme={null}
# Clean and rebuild
cargo clean
cargo build
```

### SQLx Compile-time Errors

```bash theme={null}
# Ensure DATABASE_URL is set
export DATABASE_URL=postgres://localhost/zeus

# Rebuild with offline mode
cargo sqlx prepare
cargo build --features sqlx-offline
```

## Next Steps

<Card title="Configuration" icon="gear" href="/server/configuration">
  Learn about environment variables and configuration
</Card>
