# ASF TestArena

A full-stack web application to manage automated software test jobs.

## Features
- **Login System**: Admin and User roles.
- **Dashboard**: Real-time job monitoring with WebSocket.
- **Job Submission**: Wizard to submit jobs based on git branches.
- **Results**: HTML reports generated and served automatically.
- **Cleanup**: Automatic deletion of results older than 7 days.

## Architecture
- **Backend**: FastAPI (Python)
- **Frontend**: React + Vite (TypeScript)
- **Database**: PostgreSQL
- **Reverse Proxy**: Nginx (Local Host)
- **Containerization**: Docker Compose (Backend + DB)

## Deployment Instructions

### Prerequisites
- Docker and Docker Compose installed.
- Nginx installed on the host machine.
- Node.js installed (to build frontend).
- Domain `asf-testarena.duckdns.org` pointing to your PC.

### 1. Backend & Database
Start the backend and database using Docker Compose:
```bash
docker-compose up -d --build
```
This will expose the backend API on `localhost:8000`.

### 2. Frontend
Build the frontend application:
```bash
cd frontend
npm install
npm run build
```
Copy the contents of `frontend/dist` to your web root:
```bash
# Example path based on your request
sudo cp -r dist/* /var/www/testarena/
```

### 3. Nginx Configuration
Update your Nginx configuration (usually in `/etc/nginx/sites-available/default` or similar) using the snippet provided in `nginx_config_snippet.conf`.

Key configurations:
- Serve static files from `/var/www/testarena`.
- Proxy `/api/`, `/auth/`, `/admin/`, `/jobs/`, `/ws/` to `http://localhost:8000`.
- Alias `/results/` to the `results` folder in this project directory.

Restart Nginx:
```bash
sudo systemctl restart nginx
```

### 4. Verify
- Open `http://asf-testarena.duckdns.org`.
- Login with `admin` / `admin123`.

### Scripts Integration
- The mock scripts are located in `backend/scripts/`.
- Replace `get_scenarios.sh` and `run_tests.sh` with your actual implementation.
- Ensure the scripts are executable.
