Skip to content

Add request validation, DTOs, new IoT analysis endpoints, and real-time WebSocket streaming#53

Open
abhinavsharma72 wants to merge 6 commits intoDataBytes-Organisation:mainfrom
abhinavsharma72:main
Open

Add request validation, DTOs, new IoT analysis endpoints, and real-time WebSocket streaming#53
abhinavsharma72 wants to merge 6 commits intoDataBytes-Organisation:mainfrom
abhinavsharma72:main

Conversation

@abhinavsharma72
Copy link
Collaborator

Validation added (Zod)
• Installed zod.
• Created BackendCode/middleware/validateRequest.js for reusable request validation.
• Added BackendCode/validation/schemas.js with endpointspecific schemas.
• Wired validation into BackendCode/routes/mock.js so inputs are checked at the boundary.

Controllers updated
• mockController.js and pythonController.js now use req.validatedBody when present, reducing defensive code and runtime errors.

DTOs for consistent responses
• Added BackendCode/dtos/index.js with mapEntryDto and
mapEntriesDto.
• Applied to GET /api/streams and POST /api/filterstreams to normalize response shape.

Documentation improved
• Expanded README.md:
• Full project structure and file purposes
• Validation and DTO sections with sample 400 error payload
• Copy-pasteable curl examples for all endpoints

IoT Project Features
New API Endpoints
POST /api/correlations: correlation analysis with multiple algorithms
POST /api/anomalies: Z-score anomaly detection across streams
POST /api/export: export data (JSON/CSV) with date range & filtering
GET /api/algorithms, GET /api/statistics: ML algorithms + dataset metadata

WebSocket Integration:-

Real-time data streaming (ws://localhost:8080)

image

Stream subscriptions + on-demand correlation/anomaly detection
ML Algorithm Integration
Correlation coefficient calculation
Z-score anomaly detection (configurable thresholds)
Stream/date filtering and statistical analysis

Complete Data Flow
Frontend → API → Service Layer → Repository → Mock Data
Real-time WebSocket communication
JSON/CSV export functionality
Robust error handling and validation

Signed-off-by: abhinavsharma72 <122045935+abhinavsharma72@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants