Skip to content

Backend schema, dataset ingestion, and frontend integration#49

Open
ahadsiddiqui wants to merge 9 commits intoDataBytes-Organisation:mainfrom
ahadsiddiqui:ahadsiddiqui/backend-t2-2025
Open

Backend schema, dataset ingestion, and frontend integration#49
ahadsiddiqui wants to merge 9 commits intoDataBytes-Organisation:mainfrom
ahadsiddiqui:ahadsiddiqui/backend-t2-2025

Conversation

@ahadsiddiqui
Copy link

This pull request delivers the first working end-to-end flow for the MVP.

  • Backend

Set up Express.js backend with health endpoint and routing structure.

Implemented controllers and routes for:

/api/datasets → list datasets

/api/datasets/:id/meta → dataset fields + time bounds

/api/series → return raw time series (with quality_flag) or aggregated intervals.

Designed and applied PostgreSQL schema (datasets, timeseries_long) with quality_flag support.

Added .env support and connection pooling.

  • Data ingestion

Added ingest.js script to load CSV datasets into PostgreSQL in long format.

Verified dataset ingestion (e.g. sensor1) and confirmed rows appear in DB + via API.

Documented commands in README for installing PostgreSQL, creating appdb, and running ingest.

  • Frontend integration

Connected React dashboard to backend via Vite proxy.

Updated Dashboard.jsx to send requests with dataset, streams, interval, start/end times.

Logs and visualises data from backend (with merged chart data).

Updated Chart.jsx to plot multiple streams and color points by quality_flag:

Green = normal

Red = anomaly (once DS team updates flags).

  • Testing & verification

Endpoints tested with curl and frontend Analyse button.

Confirmed full path: CSV → PostgreSQL → API → React chart.

Screenshots/logs available showing loaded server data and merged chart data.

  • Leadership contribution

As backend lead, coordinated alignment between frontend and backend teams.

Proposed and finalised system architecture (React → Node.js → PostgreSQL).

Documented setup steps in README to ensure teammates can run the repo without errors.

Provided guidance during syncs on connection flow, schema design, and integration strategy.

  • Files touched

  • Backend

newBackend/server.js (setup + routes)

newBackend/src/controllers/seriesController.js

newBackend/src/controllers/datasetController.js

newBackend/src/routes/seriesRoutes.js

newBackend/src/routes/datasetRoutes.js

newBackend/src/ingest/ingest.js

sql/schema.sql

  • Frontend

frontend/src/components/Dashboard.jsx

frontend/src/components/Chart.jsx

(minor config) frontend/vite.config.js

  • Docs

README.md (setup instructions + workflow)

  • Next steps

Data Science team can extend ingestion/anomaly detection and update quality_flag.

More datasets can be ingested and visualised without schema changes.

Future enhancements: dedicated anomaly endpoints, richer flags like bad data, anomaly, correlated.

anomaly-PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Ahad,

Please update the readme with instructions on how to import the data into the database

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahadsiddiqui sensor 2 data format caused failed to import, sensor 1 and 3 worked

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these scripts works for me
node scripts/ingest.js --file ../datasets/2881821-sensor1.csv --map mappings/sensor1.json
node scripts/ingest.js --file ../datasets/1321079-sensor2.csv --map mappings/sensor2.json
node scripts/ingest.js --file ../datasets/518150-sensor3.csv --map mappings/sensor3.json

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please resolve the conflict

@FarrisBaboo
Copy link
Contributor

Hi Ahad,
Quick question, are all the connections done in the controller folder? We'll eventually have to structure it into the Controller-Service-Repository design, which I can do for you after the merge since I have some experience with that. Thanks for your work,
Farris

- Added 2 more datasets for Sensor 2 and 3.

- Updated Readme

_ Multi Stream Visualization sort out
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

Comments