bantay-init: This folder contains the frontend application for BANTAY-INIT, a cost-effective IoT system designed for real-time heat index monitoring to address urban heat island (UHI) effects. The project combines IoT sensors, machine learning, and a web-based dashboard to provide actionable data for local government units (LGUs) and communities.
The BANTAY-INIT project focuses on:
- Real-Time Heat Index Monitoring: Data from IoT devices is sent to the Firebase Realtime Database and visualized through the frontend.
- Urban Heat Island Mitigation: Identifying localized hotspots to assist in informed urban planning.
- Inclusivity: The system emphasizes helping marginalized communities by providing open access to environmental data.
This frontend application is developed as part of our Special Problem for CMSC 198.1 and CMSC 198.2 (Thesis) at UP Visayas - Miagao.
-
Real-Time Data Visualization:
- Displays temperature, humidity, and heat index using responsive and dynamic graphs powered by Chart.js.
- Updates instantly using Firebase Realtime Database.
-
Modern, Minimal UI:
- Built with React, TypeScript, and TailwindCSS for a clean, responsive, and user-friendly experience.
-
Expandable Architecture:
- Designed for scalability to integrate additional environmental metrics or external systems.
- IoT Sensors:
- ESP32-based devices measure temperature and humidity and transmit data to the Firebase Realtime Database.
- Dashboard:
- The frontend fetches real-time data from Firebase and visualizes it as interactive charts.
- Data Analysis:
- The system identifies anomalies and trends to support heat island mitigation efforts.
This section provides a structured workflow for frontend and backend developers contributing to the project, including steps for design implementation, component development, and backend integration.
- Clone the repository:
git clone https://github.com/tinapayy/B-1N1T.git cd bantay-init
- Install dependencies:
npm install
- Main Branches:
main
: Production-ready branch.dev
: Development branch (merge all features here).
- Feature Branches:
- Use
feature/<feature-name>
for individual features or components. - Create a new branch:
git checkout -b feature/<your-feature-name>
- Use
- Follow coding conventions defined in
CONTRIBUTING.md
. - Document new dependencies or configurations in
README.md
.
- Ensure all dependencies are installed and the development server is running:
npm run dev
- Refer to design mockups in Figma, Adobe XD, or Sketch.
- Use Tailwind CSS for styling:
- Responsive design: Use responsive utilities (
sm
,md
,lg
, etc.). - Reusable components: Create modular components.
- Responsive design: Use responsive utilities (
- Add components in the
src/components
folder. - Example file structure:
src/ ├── components/ │ ├── Header.tsx │ ├── Footer.tsx │ └── Graph.tsx
import React from "react";
const Header: React.FC = () => {
return (
<header className="bg-blue-500 text-white p-4">
<h1 className="text-xl font-bold">BANTAY-INIT Dashboard</h1>
</header>
);
};
export default Header;
- Import and use the component in
App.tsx
:
import Header from "./components/Header";
const App = () => {
return (
<div>
<Header />
{/* Other components */}
</div>
);
};
export default App;
- Run the development server and visually test the component.
- Write unit tests where applicable.
- Add, commit, and push changes:
git add . git commit -m "Add Header component" git push origin feature/<your-feature-name>
- Open a pull request to the
dev
branch.
- Ensure backend dependencies are installed:
npm install
- Run the backend server (if applicable):
npm start
- For new data types, define a clear structure in Firebase:
{
"sensor": {
"temperature": 25.5,
"humidity": 60.3
},
"alerts": {
"thresholds": {
"temperature": 30,
"humidity": 80
}
}
}
- Example: Retrieve sensor data:
import { ref, get } from "firebase/database";
import { db } from "./utils/firebaseConfig";
export const getSensorData = async () => {
const snapshot = await get(ref(db, "sensor"));
return snapshot.val();
};
- Use Postman or similar tools to test backend functionality.
- Add, commit, and push changes:
git add . git commit -m "Add Firebase threshold rules" git push origin feature/<your-feature-name>
- Open a pull request to the
dev
branch.
-
Create Pull Request (PR):
- Clearly describe the changes made.
- Mention any dependencies or follow-up tasks.
-
Review Process:
- PRs must be reviewed by at least one other developer.
- Resolve conflicts and update the branch before merging.
- Regularly pull changes from the
dev
branch:git pull origin dev
- Linting:
- Ensure ESLint and Prettier are set up for consistent formatting:
npm run lint
- Ensure ESLint and Prettier are set up for consistent formatting:
- Testing:
- Write unit tests for components and backend logic.
- Deploy the frontend using Vercel or Netlify.
- Update environment variables (Firebase keys) in the deployment platform.
- Use Firebase Hosting for Realtime Database functions.
- Ensure database security rules are updated before deployment.
- Heat Index Alerts: Notify users when heat index exceeds safe thresholds.
- Data History and Analysis: Provide trends and insights based on stored data.
- GIS Mapping: Overlay data on geographic maps for spatial analysis of hotspots.
@tinapay, @xkaze09, @Megunut