# StreamA2026 - Complete Streaming Platform

A full-featured streaming platform with HLS/DASH support, real-time comments, JWT authentication, and background processing.

## Features

- **Backend**: FastAPI with JWT authentication, WebSocket, SSE
- **Frontend**: React with modern UI
- **Database**: PostgreSQL for persistent storage
- **Cache**: Redis for sessions and caching
- **Streaming**: FFmpeg for HLS/DASH conversion
- **Web Server**: Nginx (Static files/Streaming)
- **Daemon**: Background service for processing jobs
- **Real-time**: WebSocket and SSE support
- **Clean Start**: No mock data, system starts empty
- **SSL**: Caddy with automatic HTTPS

## Quick Start

⚠️ **WICHTIG**: Docker muss zuerst installiert sein!

### Detaillierte Installationsanleitung

Siehe `SETUP.md` für vollständige Anleitung zur Installation und Konfiguration.

### Kurzanleitung (nach Docker Installation)

1. Stelle sicher, dass Docker Desktop läuft
2. Starte alle Services:
```bash
docker compose up -d
```
3. Warte auf alle Services (erste Installation: 5-10 Minuten)
4. Öffne Frontend: http://localhost:3000
5. Registriere einen Benutzer und beginne mit dem Upload

### Zugriff

- **Frontend**: http://localhost:3000
- **Backend API**: http://localhost:8000
- **API Docs**: http://localhost:8000/docs

## Services

| Service | Port | Description |
|---------|------|-------------|
| Frontend | 3000 | React application |
| Backend | 8000 | FastAPI with WebSocket/SSE |
| PostgreSQL | 5432 | Database |
| Redis | 6379 | Cache/Sessions |
| Nginx | 80/443 | Static files/Streaming |
| Caddy | 443 | SSL/TLS termination |

## API Endpoints

### Authentication
- `POST /api/auth/register` - Register new user
- `POST /api/auth/login` - Login and get tokens
- `POST /api/auth/refresh` - Refresh access token
- `POST /api/auth/logout` - Logout

### Streams
- `GET /api/streams` - List all streams
- `GET /api/streams/{id}` - Get stream details
- `POST /api/streams` - Create new stream
- `PUT /api/streams/{id}` - Update stream
- `DELETE /api/streams/{id}` - Delete stream
- `POST /api/streams/{id}/upload` - Upload video file

### Comments
- `GET /api/streams/{id}/comments` - Get stream comments
- `POST /api/streams/{id}/comments` - Add comment
- `PUT /api/comments/{id}` - Update comment
- `DELETE /api/comments/{id}` - Delete comment

### Real-time
- `WS /ws/stream/{id}` - WebSocket for live updates
- `SSE /api/events` - Server-Sent Events for system events

## Project Structure

```
StreamA2026/
├── backend/           # FastAPI backend
│   ├── app/
│   │   ├── api/      # API routes
│   │   ├── models/   # Database models
│   │   ├── schemas/  # Pydantic schemas
│   │   ├── services/ # Business logic
│   │   ├── daemon.py # Background daemon
│   │   └── main.py   # Application entry
│   ├── Dockerfile
│   └── requirements.txt
├── frontend/          # React frontend
│   ├── src/
│   │   ├── components/
│   │   ├── pages/
│   │   ├── services/
│   │   └── App.tsx
│   ├── Dockerfile
│   └── package.json
├── nginx/            # Nginx configuration
│   ├── nginx.conf
│   └── conf.d/
├── caddy/            # Caddy configuration
├── flyway/           # Flyway migrations
├── docker-compose.yml
└── .env.example
```

## Production Deployment

### Using Nginx (default)

The included Nginx configuration is production-ready. Update the config in `nginx/conf.d/` for your domain.

### SSL/TLS

Caddy handles SSL/TLS automatically with Let's Encrypt. Configure your domain in `caddy/Caddyfile`.

### Environment Variables

Set these in production:
- `POSTGRES_PASSWORD` - Strong password
- `REDIS_PASSWORD` - Strong password
- `JWT_SECRET_KEY` - Random secret key
- `ALLOWED_ORIGINS` - Your frontend domain
- `LOG_LEVEL` - INFO or DEBUG

## Adding New Services

To add a new service:

1. Add to `docker-compose.yml`
2. Create configuration in respective folder
3. Update backend to use the service
4. Add environment variables to `.env.example`

## Development

### Backend Development
```bash
cd backend
pip install -r requirements.txt
uvicorn app.main:app --reload
```

### Frontend Development
```bash
cd frontend
npm install
npm run dev
```

## Logging

Logs are available via:
- Docker logs: `docker-compose logs -f [service]`
- API endpoint: `GET /api/logs`
- SSE: `/api/events` for real-time log events

## Security

**Important Security Notes:**

- Never commit `.env` files or secrets to version control
- Use strong, unique passwords in production
- Change default JWT secret keys
- Enable HTTPS in production
- See [SECURITY.md](SECURITY.md) for detailed security guidelines
- Use `.env.example` as template for environment variables

## Contributing

We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

## License

MIT
