Bekithemba Matshazi
Back to Projects
EcoTrack
Vue.jsNode.jsPostgreSQLGraphQLChart.js

EcoTrack

6 min read

A sustainability tracking platform that helps individuals and businesses monitor their carbon footprint, with gamification elements to encourage eco-friendly behaviors.

EcoTrack - Carbon Footprint Monitoring

EcoTrack is a comprehensive sustainability platform that empowers users to track, understand, and reduce their environmental impact. Built with Vue.js and Node.js, it combines data visualization with gamification to make sustainability engaging.

Mission

Climate change is one of the most pressing challenges of our time. EcoTrack makes it easy for individuals and organizations to:

  • Measure their carbon footprint accurately
  • Understand the impact of daily choices
  • Take action with personalized recommendations
  • Track progress over time with detailed analytics

Core Features

Carbon Footprint Calculator

The calculator considers multiple factors:

  • Transportation (car, public transit, flights)
  • Home energy consumption
  • Diet and food choices
  • Shopping and consumption patterns
  • Waste management
// Carbon calculation engine
class CarbonCalculator {
  constructor() {
    this.emissionFactors = {
      car: 0.411, // kg CO2 per mile
      flight: 0.255, // kg CO2 per mile
      electricity: 0.92, // kg CO2 per kWh
      beef: 27.0, // kg CO2 per kg
      // ... more factors
    };
  }

  calculateTransport(miles, mode) {
    return miles * this.emissionFactors[mode];
  }

  calculateTotal(activities) {
    return activities.reduce((total, activity) => {
      return total + this.calculate(activity);
    }, 0);
  }
}

Interactive Dashboard

The dashboard provides real-time insights with beautiful visualizations:

EcoTrack Dashboard

EcoTrack Dashboard

Key metrics displayed:

  • Monthly carbon footprint trend
  • Category breakdown (transport, food, energy, etc.)
  • Comparison with regional/global averages
  • Progress towards personal goals

Gamification System

To keep users engaged, we implemented a comprehensive gamification system:

Achievements:

  • 🌱 Green Beginner: Track your first week
  • 🚴 Eco Commuter: Use sustainable transport for 30 days
  • ♻️ Recycling Champion: Maintain 90% recycling rate
  • 🌍 Climate Hero: Reduce footprint by 50%

Challenges:

  • Weekly sustainability challenges
  • Community competitions
  • Seasonal events (e.g., "Plastic-Free July")

Leaderboards:

  • Friends leaderboard
  • City/region rankings
  • Global top performers

Personalized Recommendations

The system provides AI-powered suggestions based on user data:

Based on your commute patterns, switching to public transit 2 days a week could save 45 kg CO2 per month - equivalent to planting 2 trees!

// Recommendation engine
async function generateRecommendations(userId) {
  const userData = await getUserActivities(userId);
  const highestImpact = analyzeActivities(userData);

  const recommendations = [];

  if (highestImpact.category === 'transport') {
    recommendations.push({
      title: 'Try Car-Free Tuesdays',
      impact: calculatePotentialSavings(userData.transport),
      difficulty: 'medium',
      actions: ['Find public transit routes', 'Set calendar reminder']
    });
  }

  return prioritizeRecommendations(recommendations);
}

Technical Implementation

Frontend Architecture

Built with Vue 3 and the Composition API for reactive, maintainable code:

<script setup>
import { ref, computed } from 'vue';
import { useQuery } from '@vue/apollo-composable';
import { CARBON_FOOTPRINT_QUERY } from '@/graphql/queries';

const userId = ref(getCurrentUserId());

const { result, loading } = useQuery(CARBON_FOOTPRINT_QUERY, {
  userId: userId.value,
  period: 'month'
});

const totalFootprint = computed(() => {
  return result.value?.carbonFootprint.total || 0;
});
</script>

<template>
  <div class="dashboard">
    <h1>Your Carbon Footprint</h1>
    <CarbonMeter :value="totalFootprint" />
  </div>
</template>

Backend with GraphQL

The backend uses Node.js with Apollo Server for a flexible GraphQL API:

type Query {
  carbonFootprint(userId: ID!, period: Period!): CarbonFootprint
  achievements(userId: ID!): [Achievement!]!
  leaderboard(scope: LeaderboardScope!): [LeaderboardEntry!]!
}

type Mutation {
  logActivity(input: ActivityInput!): Activity
  updateGoal(userId: ID!, goal: Float!): User
}

type CarbonFootprint {
  total: Float!
  byCategory: [CategoryBreakdown!]!
  trend: [DataPoint!]!
  comparisonToAverage: Float!
}

Data Visualization

Using Chart.js and custom components for engaging data presentation:

  • Line charts for trends over time
  • Pie charts for category breakdowns
  • Progress bars for goals
  • Heat maps for activity patterns

Database Design

PostgreSQL schema optimized for time-series data:

CREATE TABLE activities (
    id SERIAL PRIMARY KEY,
    user_id INTEGER REFERENCES users(id),
    category activity_category NOT NULL,
    carbon_amount DECIMAL(10, 2) NOT NULL,
    metadata JSONB,
    created_at TIMESTAMP DEFAULT NOW()
);

CREATE INDEX idx_activities_user_date
ON activities(user_id, created_at DESC);

CREATE INDEX idx_activities_category
ON activities(category);

API Integration

EcoTrack integrates with multiple external services:

  • Transport APIs: Real-time public transit data
  • Energy Providers: Automatic energy usage import
  • Smart Home Devices: Nest, Ecobee integration
  • Fitness Trackers: Strava, Fitbit for tracking walking/cycling

Challenges and Solutions

Challenge 1: Data Accuracy

Problem: User-reported data can be inaccurate or incomplete.

Solution:

  • Implemented smart defaults based on demographics
  • Added data validation and reasonability checks
  • Integrated with third-party data sources for automatic tracking
  • Used ML to detect and flag anomalies

Challenge 2: User Engagement

Problem: Many users lost interest after initial enthusiasm.

Solution:

  • Added gamification elements
  • Implemented social features (share achievements, compete with friends)
  • Weekly email digests with insights and tips
  • Push notifications for challenges and milestones

Result: User retention improved from 30% to 68% over 3 months

Challenge 3: Scalability

Problem: Real-time dashboard updates slowed down with many concurrent users.

Solution:

  • Implemented Redis caching for frequently accessed data
  • Used GraphQL subscriptions for efficient real-time updates
  • Optimized database queries with proper indexing
  • Added CDN for static assets

Result: API response time improved from 800ms to 120ms (85% improvement)

Impact Metrics

Since launch, EcoTrack has achieved:

  • 50,000+ active users across 25 countries
  • 2.5 million kg CO2 reduction tracked
  • Average 23% reduction in user carbon footprints
  • 92% user satisfaction rate
  • Featured in sustainability publications

Environmental Partnerships

EcoTrack partners with environmental organizations:

  • 1% for the Planet: Donate 1% of revenue to environmental causes
  • Tree Planting Programs: Plant trees based on user achievements
  • Carbon Offset Projects: Direct investment in verified offset programs

Future Roadmap

Q2 2025:

  • Mobile apps (iOS and Android)
  • Corporate sustainability tracking
  • API for third-party integrations

Q3 2025:

  • AI-powered habit formation coaching
  • Blockchain-based carbon credit marketplace
  • Expanded international support

Q4 2025:

  • VR educational experiences
  • Integration with smart city infrastructure
  • Advanced predictive analytics

Tech Stack Summary

  • Frontend: Vue 3, TypeScript, Tailwind CSS
  • State Management: Pinia
  • Backend: Node.js, Express, Apollo Server
  • Database: PostgreSQL with TimescaleDB
  • Caching: Redis
  • Charts: Chart.js, D3.js
  • Testing: Vitest, Cypress
  • Deployment: Docker, AWS ECS
  • CI/CD: GitHub Actions

Conclusion

EcoTrack demonstrates how technology can be a powerful force for environmental good. By making sustainability tracking accessible, engaging, and actionable, we're helping thousands of people make meaningful changes in their daily lives.

"The best time to act on climate change was yesterday. The second best time is now." - Unknown

Join us in making a difference, one carbon footprint at a time! 🌍

Related Projects

You might also be interested in these similar projects

Bookit
Next.jsGoPostgreSQL+1
Bookit

A modern event ticketing and booking platform built with Next.js, Go, and PostgreSQL. Features include secure payment processing, QR code tickets, and interactive seating maps.