Skip to content

justlab-ai/co2ai-frontend

Repository files navigation

🌱 CO2AI Frontend - Wet Lab Equipment Emissions Monitoring

React TypeScript Vite Tailwind CSS License

A modern, responsive dashboard for real-time wet lab equipment emissions monitoring with comprehensive analytics and inventory management.


✨ Key Features

πŸ“Š Dashboard

  • Real-time Monitoring - Track COβ‚‚ emissions, active equipment, efficiency scores, and energy consumption
  • Interactive Charts - Visualize monthly emissions trends and top equipment by emissions
  • Predictive Alerts - Get notified about maintenance needs and optimization opportunities
  • Month-over-Month Analytics - Compare current and previous month metrics with percentage changes

πŸ”§ Equipment Inventory

  • List/Grid View Toggle - Switch between 3-column responsive grid and sortable table views
  • Equipment Search - Filter by name, type, manufacturer, or equipment ID
  • Faulty Equipment Tracking - Visual indicators with error messages for equipment needing maintenance
  • Color-Coded Status Badges - Active 🟒 | Idle 🟑 | Maintenance 🟠 | Offline ⚫ | Faulty πŸ”΄
  • Sortable Columns - Click headers to sort any equipment attribute
  • Persistent Preferences - Remember view preference across sessions

πŸ“ˆ Analytics

  • Time Range Selection - Toggle between Week, Month, or Year views
  • Dual Metrics Tracking - Monitor emissions (πŸ“‰ line chart) and consumption (πŸ“Š bar chart)
  • Smart Unit Scaling - Auto-converts MWh/kWh and tCOβ‚‚e/kgCOβ‚‚e based on magnitude
  • Daily Data Points - Month view shows 30 individual days for granular analysis
  • Comprehensive Statistics - Totals and averages with context-aware formatting

πŸ’Ύ Data Management

  • Internal Database - Centralized data store with observer pattern for reactive updates
  • Time Series Aggregation - 90 days of historical data with daily, weekly, and monthly aggregates
  • Realistic Mock Data - Historical data generation with:
    • πŸ“… Weekend/weekday variations (30% reduction on weekends)
    • πŸ“ˆ Seasonal trends (10% growth over 90 days)
    • 🎲 Natural daily fluctuations (Β±15% variation)
  • Data Consistency - Dashboard and Analytics use unified time series source

🎨 User Experience

  • Dark Theme - Professional dark UI, easy on the eyes
  • Responsive Design - Perfect on desktop πŸ’», tablet πŸ“±, and mobile πŸ“±
  • Real-time Sync - Manual sync button with loading states
  • Error Handling - Graceful error messages with retry functionality

πŸ›  Tech Stack

Technology Purpose Version
React UI Framework 18
TypeScript Type Safety 5.0+
Vite Build Tool 5.4+
Tailwind CSS Styling 3.0+
Recharts Data Visualization Latest
React Router Navigation v6
@tanstack/react-table Table Functionality Latest
Lucide React Icons Latest

πŸš€ Getting Started

Prerequisites

  • Node.js 16+
  • npm or yarn

Installation

# 1️⃣ Clone the repository
git clone https://github.com/BrandeisPatrick/co2ai-frontend.git
cd co2ai-frontend

# 2️⃣ Install dependencies
npm install

# 3️⃣ Start development server
npm run dev

# 4️⃣ Open in browser
# Visit http://localhost:5173

πŸ“‹ Available Scripts

# Start development server with hot reload
npm run dev

# Build for production
npm run build

# Preview production build locally
npm run preview

# Run ESLint and type checking
npm run lint

πŸ“ Project Structure

src/
β”œβ”€β”€ πŸ“„ components/
β”‚   β”œβ”€β”€ πŸ“Š dashboard/
β”‚   β”‚   β”œβ”€β”€ StatCard.tsx              # KPI metric cards
β”‚   β”‚   β”œβ”€β”€ MonthlyEmissionsTrend.tsx # Trend line chart
β”‚   β”‚   β”œβ”€β”€ TopEquipmentChart.tsx     # Top 5 equipment bar chart
β”‚   β”‚   └── PredictiveAlerts.tsx      # Alert cards
β”‚   β”œβ”€β”€ πŸ”§ equipment/
β”‚   β”‚   β”œβ”€β”€ EquipmentCard.tsx         # Grid view card component
β”‚   β”‚   β”œβ”€β”€ EquipmentTable.tsx        # List view table (@tanstack/react-table)
β”‚   β”‚   └── ViewToggle.tsx            # Grid/List toggle buttons
β”‚   └── 🎨 layout/
β”‚       β”œβ”€β”€ Sidebar.tsx               # Navigation sidebar
β”‚       └── DashboardLayout.tsx       # Main layout wrapper
β”œβ”€β”€ πŸ“„ pages/
β”‚   β”œβ”€β”€ Dashboard.tsx                 # Dashboard page
β”‚   β”œβ”€β”€ EquipmentInventory.tsx        # Equipment inventory page
β”‚   └── Analytics.tsx                 # Analytics page
β”œβ”€β”€ πŸ“„ services/
β”‚   β”œβ”€β”€ api.ts                        # Mock API & equipment data
β”‚   β”œβ”€β”€ dataStore.ts                  # Internal database with observer pattern
β”‚   └── mockTimeSeriesDb.ts           # 90-day historical data generation
β”œβ”€β”€ 🎯 hooks/
β”‚   └── useDataContext.ts             # Custom hook for data access
β”œβ”€β”€ πŸ“š utils/
β”‚   └── timeSeriesHelpers.ts          # Time series calculations & formatting
β”œβ”€β”€ πŸ“„ contexts/
β”‚   └── DataContext.tsx               # Global data context provider
β”œβ”€β”€ 🎨 types/
β”‚   └── index.ts                      # TypeScript interfaces
β”œβ”€β”€ App.tsx                           # App component with routing
β”œβ”€β”€ main.tsx                          # React entry point
└── index.css                         # Global Tailwind CSS

πŸ— Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   React Components                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  Dashboard   β”‚  β”‚  Equipment   β”‚  β”‚  Analytics   β”‚  β”‚
β”‚  β”‚              β”‚  β”‚  Inventory   β”‚  β”‚              β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                  β”‚                  β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚                  β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚     DataContext Provider              β”‚
          β”‚   (Global State Management)           β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚    InternalDatabase (DataStore)     β”‚
          β”‚  β€’ Observer Pattern                 β”‚
          β”‚  β€’ Equipment State                  β”‚
          β”‚  β€’ Historical Data                  β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚   MockTimeSeriesDatabase            β”‚
          β”‚  β€’ 90 days of history               β”‚
          β”‚  β€’ Daily aggregates                 β”‚
          β”‚  β€’ Realistic variations             β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚    Equipment Data (Mock API)        β”‚
          β”‚  β€’ 12 lab equipment items           β”‚
          β”‚  β€’ Faulty equipment tracking        β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“Š Data Flow

API/JSONBin
    ↓
Equipment Data
    ↓
DataStore (InternalDatabase)
    β”œβ”€β†’ Equipment List (12 items)
    └─→ MockTimeSeriesDb
        β”œβ”€β†’ 90 days of snapshots
        β”œβ”€β†’ Daily Aggregates (30 days)
        β”œβ”€β†’ Weekly Aggregates (12 weeks)
        └─→ Monthly Aggregates (12 months)
    ↓
DataContext (Global State)
    β”œβ”€β†’ Dashboard (derives metrics)
    β”œβ”€β†’ Equipment Inventory (filters/sorts)
    └─→ Analytics (time series visualization)

🎯 Recent Implementations

βœ… FEATURE 1: Equipment Inventory List/Grid View Toggle

  • Toggle between responsive grid and sortable table views
  • localStorage persistence of user preference
  • Faulty equipment visual indicators
  • Search functionality in both views
  • Status: ✨ Complete & Production Ready

βœ… Time Series Data Consistency Fix

  • Unified data calculation across Dashboard and Analytics
  • Fixed metric discrepancies (Dashboard vs Analytics)
  • Smart unit formatting (auto-scaling MWh/kWh)
  • Consistent month-over-month comparisons
  • Status: ✨ Complete & Production Ready

πŸ”Œ Equipment Status Colors

Status Color Meaning
Active 🟒 Green Equipment is operational
Idle 🟑 Yellow Equipment is available but not in use
Maintenance 🟠 Orange Equipment requires scheduled maintenance
Offline ⚫ Gray Equipment is not connected/powered off
Faulty πŸ”΄ Red Equipment has errors and needs attention

πŸ“Š Sample Equipment Data

The application includes 12 mock lab equipment items:

Equipment Type Power Draw Daily Emissions Status
ULT Freezer #1 Ultra-Low Freezer 2.5 kW 85 kg 🟒 Active
ULT Freezer #2 Ultra-Low Freezer 2.4 kW 82 kg 🟒 Active
COβ‚‚ Incubator Pro CO2 Incubator 0.8 kW 28 kg 🟒 Active
Autoclave #4 Autoclave 3.2 kW 110 kg πŸ”΄ Faulty
PCR Thermal Cycler PCR Machine 1.2 kW 41 kg 🟒 Active
Centrifuge Unit Centrifuge 2.1 kW 72 kg 🟑 Idle
UV-Vis Spectro #8 Spectrophotometer 0.5 kW 17 kg πŸ”΄ Faulty
...and 5 more items - - - -

🎨 Customization

Change Colors

Edit tailwind.config.js:

colors: {
  primary: '#your-color',
  secondary: '#your-color'
}

Modify Chart Appearance

Update components in src/components/dashboard/ and src/pages/Analytics.tsx

Update Navigation

Edit src/components/layout/Sidebar.tsx to add/remove menu items


πŸš€ Production Build

# Build optimized production bundle
npm run build

# Output files in dist/ directory
# Ready for deployment to:
# β€’ Vercel
# β€’ Netlify
# β€’ AWS S3 + CloudFront
# β€’ Any static hosting service

Build Statistics

  • Bundle Size: ~671 KB (minified)
  • Gzip Size: ~189 KB
  • Assets: CSS, JS, HTML optimized
  • TypeScript: Full type checking included

πŸ” Security & Performance

  • βœ… Type Safety: 100% TypeScript coverage
  • βœ… Dark Mode: Reduces eye strain
  • βœ… Responsive: Mobile-first design
  • βœ… Optimized: Code-splitting ready
  • βœ… Error Handling: Graceful fallbacks
  • βœ… Lazy Loading: Components load on demand

πŸ“ Next Steps / Roadmap

  • FEATURE 2: Remove API Integrations page
  • FEATURE 3: Reports page with CSV/PDF exports
  • FEATURE 4: Enhanced Analytics with drill-down views
  • Phase 2: AI/ML features (requires infrastructure)
  • Real-time data updates via WebSockets
  • User authentication & role-based access

πŸ“„ License

MIT Β© 2024 CO2AI


πŸ‘¨β€πŸ’» Development

Environment Setup

# Node.js version
node --version  # 16.0.0 or higher

# Install dependencies
npm install

# Start with hot reload
npm run dev

# Open http://localhost:5173

Type Checking

# Run TypeScript compiler
npm run build  # Includes type checking via tsc

πŸ“ž Support

For issues, feature requests, or questions:

  1. Check existing GitHub issues
  2. Create a new issue with detailed information
  3. Include screenshots or error messages

Made with ❀️ for sustainable computing 🌍

About

Real-time wet lab equipment emissions monitoring dashboard

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages