The web application lives in src/server/ and consists of two projects:
| Project | Type | Purpose |
|---|---|---|
SmartBotBlazorApp |
ASP.NET Core 8.0 (Blazor Web App host) | SignalR hub, EF Core persistence, Identity, image processing, server-rendered pages |
SmartBotBlazorApp.Client |
Blazor WebAssembly 8.0 | Browser-side diagnostic/auth pages; /chat connects to SignalR from WASM |
| Route | Component | Render mode | Description |
|---|---|---|---|
/ |
Home.razor |
Server | Landing page and project overview |
/chat |
Client/Pages/Chat.razor |
WebAssembly | Text-message diagnostics for the SignalR connection |
/image-receiver-server |
ImageReceiver_server.razor |
Server | Authorized live 512×512 depth heatmap plus joystick/keyboard robot control and speed gauges |
/matrix-receiver-server |
MatrixReceiver_server.razor |
Server | Authorized live 32×32 interpolated depth grid with per-cell coloring and robot control |
/measurement-charts |
MeasurementCharts.razor |
Server | Authorized historical MudBlazor charts: temperature, average distance, acceleration (X/Y/Z), rotation (X/Y/Z); date-range picker, defaults to the last 5 minutes |
/weather |
Weather.razor |
Server (stream rendering) | Air-quality data pulled from an external GreenCity/InPost sensor API |
/Account/* |
Identity pages | Server | Registration, login, 2FA, password reset, account management |
The control panel in ImageReceiver_server.razor accepts pointer events from mouse
or touch and keyboard events from the arrow keys:
Components/RobotMovementInput/JoystickInputHandler.csnormalizes the two joystick axes, applies stop/straight-driving dead zones, and mixes them asleft = y + xandright = y - x. This provides proportional straight motion, curved motion, and rotation around the robot's own axis from one joystick.Components/RobotMovementInput/keyboardInputHandler.csmaps the arrow keys to full-range-255,0, or255motor commands. Up/down drive both motors in the same direction; left/right drive them in opposite directions for rotation in place.ImageReceiver_server.razorsends commands throughSendMovementCommand, updates both speed gauges, limits normal command transmission to one message per 250 ms, and sends(0, 0)when pointer or keyboard input is released.
See architecture.md for the equations, exact key mapping, and the interaction with the firmware dead-man timer.
The single real-time endpoint shared by robots and dashboards. See architecture.md for the full message contract. On each ReceiveRobotData invocation it concurrently:
- saves the measurement (
MeasurementService), - broadcasts a heatmap frame (
ReceiveBase64Frame), - broadcasts the interpolated matrix (
ReceiveMatrix).
GenerateHeatmapBase64Image(ushort[64])— renders the 8×8 depth frame to a PNG heatmap (ImageSharp) using a red→yellow→green→blue→purple gradient normalized over 10–3500 mm, returned base64-encoded.InterpolateData(ushort[64], 32)— bilinear upsampling of the frame to 32×32 for the matrix view.
SaveMeasurementsToDatabase(user, measurements, avgDistance)— validates the seven-value IMU payload and inserts at most one row per second for each robot ID. The in-process throttle is synchronized across concurrent hub calls and uses UTC for elapsed-time comparisons while retaining local timestamps for the existing chart filters.RoundMeasurements(measurements, digits)— display rounding (2 decimal places).- Date-range query used by the charts page.
EF Core context combining ASP.NET Core Identity tables with the Measurement telemetry table. Migrations live in Data/Migrations/ and are applied automatically at startup.
Measurement (Data/Measurement.cs):
| Column | Type | Notes |
|---|---|---|
Id |
int | Primary key |
RobotId |
string (≤ 50) | Required; identifies the sending robot |
TemperatureC |
double | From the MPU6050 die sensor |
AccelerationX/Y/Z |
double | m/s² |
RotationX/Y/Z |
double | °/s |
AvgDistance |
ushort | Average ToF distance, mm |
Timestamp |
DateTime | Defaults to insert time |
| Key | Purpose |
|---|---|
ConnectionStrings:DefaultConnection |
SQL Server connection (LocalDB by default) |
Logging:LogLevel:* |
Standard ASP.NET Core logging levels |
Api:Url |
External API base URL placeholder |
AccountAccess:AllowRegistration |
Enables the registration endpoint; false by default, true in Development |
AccountAccess:ShowSelfConfirmationLink |
Shows the no-email confirmation link; for local development only |
AllowedHosts |
Host filtering (* by default) |
| Variable | Purpose |
|---|---|
SmartBotDBConnectionString |
Overrides the connection string (used in Docker/Azure) |
RobotApiKey |
URL-safe key (minimum 32 characters) accepted from robot connections to /signalhub |
ASPNETCORE_ENVIRONMENT |
Development / Production |
AccountAccess__AllowRegistration / AccountAccess__ShowSelfConfirmationLink |
Environment-variable overrides for account provisioning |
ASPNETCORE_HTTP_PORTS / ASPNETCORE_HTTPS_PORTS |
Optional container port bindings; the image serves HTTP on 8080 by default |
| Profile | HTTP | HTTPS |
|---|---|---|
Kestrel (http/https) |
5221 | 7297 |
| IIS Express | 24385 | 44312 |
| Docker (default runtime) | 8080 | — |
Response compression (including application/octet-stream for SignalR payloads) → HTTPS redirection → static files → Identity authentication/authorization → role-aware SignalR access guard → antiforgery → Razor components (Server + WASM render modes) → SignalR hub at /signalhub → Identity endpoints.
Notes for hardening before production use:
- Registration is disabled outside Development. Temporarily provision accounts in a trusted environment or connect a controlled administrative flow.
IEmailSenderis a no-op stub (IdentityNoOpEmailSender) — plug in a real sender before enabling registration publicly. Never enable the self-confirmation link publicly.
- Docker:
src/server/SmartBotBlazorApp/Dockerfile(multi-stage .NET 10 SDK build → publish → non-rootmcr.microsoft.com/dotnet/aspnet:8.0runtime, serving HTTP on 8080). The project also defines .NET SDK container metadata (kamilr616/smartbotblazorapp:latest). - CI:
.github/workflows/smartbotweb.ymlperforms locked restore, formatting and vulnerability checks, build, tests with coverage, publish, and a container build for pushes and pull requests targetingmain. External deployment is intentionally manual; the Azure App Service used for the project presentation is no longer hosted.