Files
SpeedTest/README-SPEEDTEST.md
Alexander Zinn 21b9e52f40 Add frontend speed test application and server setup
* Introduced a new HTML frontend for network speed testing with a responsive UI
* Implemented backend server functionality to serve the frontend and handle speed test APIs
* Added speed test logic for downloading and uploading data, including progress tracking and result validation
* Created README-SPEEDTEST.md for documentation on application architecture, setup, and usage.
* Updated package.json to include necessary scripts and dependencies for development and testing
2025-11-21 04:56:18 -05:00

121 lines
3.0 KiB
Markdown

# Speedtest Application
A full-stack network speed testing application built with Bun.js.
## Architecture
- **Server**: Single Bun.js HTTP server serving both frontend and APIs
- **Frontend**: HTML/JavaScript client served at `/` for running speed tests
- **Configuration**: Maximum request body size set to 3GB for large file uploads
- **APIs**:
- `GET /` - Speedtest frontend UI
- `GET /_health/readiness` - Health check
- `GET /data?size=<bytes>` - Download random test data
- `POST /data?requestId=<id>` - Upload data for validation
## Quick Start
### 1. Start the Server
```bash
bun run start
```
Server will start on `http://localhost:8080` with both backend APIs and frontend served from the same server.
### 2. Run Speed Test
1. Open `http://localhost:8080` in your browser
2. Select test size (1MB - 50MB)
3. Click "Start Speed Test"
4. View download/upload speeds and validation results
## Development
### Run Both Servers Simultaneously
```bash
# Requires concurrently (npm install -D concurrently)
bun run dev
```
### Manual Testing
Test the API directly:
```bash
# Health check
curl http://localhost:8080/_health/readiness
# Download test (1MB)
curl -o test.dat http://localhost:8080/data?size=1048576
# Upload same data back (get requestId from previous response headers)
curl -X POST "http://localhost:8080/data?requestId=<request-id>" \
--data-binary @test.dat \
-H "Content-Type: application/octet-stream"
```
## Speed Test Workflow
1. **Download Phase**: Frontend downloads random data from server
2. **Upload Phase**: Frontend uploads the same data back for validation
3. **Validation**: Server verifies data integrity and measures performance
4. **Results**: Frontend displays download/upload speeds, total time, and data integrity status
## Features
- ✅ Configurable test sizes (1MB - 2.5GB)
- ✅ Large file support (up to 3GB request body limit)
- ✅ Real-time progress indicators
- ✅ Data integrity validation with SHA256
- ✅ Upload/download speed measurements
- ✅ Clean, responsive UI
- ✅ Comprehensive logging
- ✅ Error handling and recovery
## API Reference
### GET /data
Downloads random test data for speed testing.
**Query Parameters:**
- `size` (number): Size in bytes (default: 10MB)
**Response Headers:**
- `Content-Type`: `application/octet-stream`
- `Content-Length`: Data size
- `Content-Hash`: SHA256 hash
- `X-Request-ID`: Unique request identifier
### POST /data
Uploads data for validation and performance measurement.
**Query Parameters:**
- `requestId` (string): Request ID from download phase
**Response:**
```json
{
"requestId": "uuid",
"valid": true,
"expectedHash": "sha256...",
"receivedHash": "sha256...",
"size": 1048576,
"totalTimeMs": 1250,
"dataRateBps": 838860.8,
"dataRateMbps": 6.71,
"timestamp": "2024-01-01T12:00:00.000Z"
}
```
### GET /_health/readiness
Health check endpoint.
**Response:**
```json
{
"status": "ok",
"timestamp": "2024-01-01T12:00:00.000Z",
"uptime": 123.45,
"memory": {...},
"cpu": [...],
"os": "darwin"
}
```