# AegisTrade AI — Installation & Setup Guide

## 1. System Requirements

- **Operating System**: macOS 12+, Ubuntu 20.04/22.04 LTS, Debian 11+, or Windows (via WSL2)
- **Python**: Python 3.9, 3.10, 3.11, or 3.12
- **Node.js**: v18.0.0 or higher
- **RAM**: Minimum 2 GB (4 GB recommended for extensive historical backtesting)
- **Disk Space**: ~500 MB for application files and dependencies

---

## 2. Installation Steps

### Step 1: Clone Repository & Create Environment Configuration
```bash
cp .env.example .env
```
Edit `.env` to configure your preferred settings. By default, `TRADING_MODE` is set to `PAPER` and `ENABLE_LIVE_TRADING` is set to `false`.

### Step 2: Set Up Python Backend Environment
```bash
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
```

### Step 3: Set Up Frontend Terminal
```bash
cd frontend
npm install
npm run build
cd ..
```

### Step 4: Verify Installation with Test Suite
```bash
source .venv/bin/activate
pytest -v tests/
```
All 32 tests must pass with 100% success rate.

---

## 3. Starting the System

### Option A: Unified Single-Server Mode (Recommended)
Because the frontend has been built into `frontend/dist`, the FastAPI server automatically serves both the backend API and the web application:
```bash
source .venv/bin/activate
python -m uvicorn backend.app.main:app --host 0.0.0.0 --port 8000
```
Open your browser at **`http://localhost:8000`**.

### Option B: Development Hot-Reload Mode
- Terminal 1 (Backend):
  ```bash
  source .venv/bin/activate
  python -m uvicorn backend.app.main:app --host 0.0.0.0 --port 8000 --reload
  ```
- Terminal 2 (Frontend):
  ```bash
  cd frontend
  npm run dev
  ```
  Access the Vite dev server at **`http://localhost:5173`**.
