Add request validation, DTOs, new IoT analysis endpoints, and real-time WebSocket streaming#53
Open
abhinavsharma72 wants to merge 6 commits intoDataBytes-Organisation:mainfrom
Open
Conversation
Signed-off-by: abhinavsharma72 <122045935+abhinavsharma72@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)
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