Skip to content

zting052/ecobuddyclone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

136 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EcoBuddy β€” Your Energy Saving Companion (v1.5)

πŸš€ Want to deploy to Render? See DEPLOY_TO_RENDER.md for complete deployment guide with all specific details.

⚠️ Having issues? See TROUBLESHOOTING.md for solutions to common problems.

This repository contains EcoBuddy, a full-featured energy-saving dashboard app with:

  • React + Vite (Frontend)
  • React Router for navigation
  • Tailwind CSS (mobile-first)
  • Chart.js with React Chart.js 2 for data visualization
  • Express.js + PostgreSQL Backend
  • User Authentication & Data Persistence
  • Seeds Currency System
  • Streak Tracking
  • Friends & Social Features

Features (v1.5)

πŸ“Š Analytics Page

  • Real-time energy usage tracking based on completed tasks
  • Weekly consumption charts
  • Usage breakdown by category (heating, cooling, lighting, appliances)
  • Key performance indicators (KPIs)
  • Savings metrics and COβ‚‚ impact
  • NEW: Shows actual data only - zeros for new users

πŸ† Social & Leaderboard

  • Friends leaderboard showing completed tasks and seeds
  • See friends' EcoBuddy mascots
  • Track friends' streaks and progress
  • NEW: No default friends - only real connections

⚑ Tasks/Challenges Page

  • Active challenges with real progress tracking
  • NEW: Completable challenges that award seeds
  • Mark progress and complete challenges
  • Earn seeds for each completion
  • Track completed challenges history
  • Start new challenges from available pool

🌱 EcoBuddy Home Page

  • Interactive EcoBuddy mascot with transparent image
  • NEW: Seeds-based economy (replaced points)
  • Customizable accessories (sunglasses, top hat, crown, scarf)
  • Accessories properly positioned on mascot
  • NEW: Daily login streak tracking
  • Level progression and XP system
  • Feed and play with EcoBuddy using seeds

🧭 Navigation

  • Mobile-optimized bottom navigation bar
  • Smooth transitions between pages
  • Active route highlighting

Local Development

Quick Diagnostic (Recommended First Step)

Before starting development, run the diagnostic tool to check your environment:

npm run diagnostic

This will check:

  • Node.js version
  • Environment variables
  • Dependencies
  • Configuration files

Frontend Only (Client-side mode)

  1. Install dependencies:
npm install
  1. Run the dev server:
npm run dev
  1. Build:
npm run build
  1. Preview production build locally:
npm run preview

Full Stack Development (Frontend + Backend)

Backend Setup

  1. Install backend dependencies:
cd backend
npm install
  1. Set up PostgreSQL database:
createdb energyteen
  1. Create .env file in backend/ directory:
DATABASE_URL=postgresql://username:password@localhost:5432/energyteen
JWT_SECRET=your-secret-key-here
NODE_ENV=development
PORT=3001
FRONTEND_URL=http://localhost:5173
  1. Run database migrations:
npm run db:migrate
  1. Start backend server:
npm run dev

Backend will run on http://localhost:3001

Frontend Setup

  1. Create .env file in root directory:
VITE_API_URL=http://localhost:3001/api
  1. Install dependencies:
npm install
  1. Start frontend dev server:
npm run dev

Frontend will run on http://localhost:5173

Now you can signup/login and all data will be saved to the database!

Tech Stack

Frontend

  • Frontend Framework: React 18
  • Build Tool: Vite 5
  • Routing: React Router DOM v6
  • Styling: Tailwind CSS 3
  • Charts: Chart.js 4 + React Chart.js 2

Backend (v1.4+)

  • Framework: Express.js
  • Database: PostgreSQL
  • Authentication: JWT (JSON Web Tokens)
  • Password Hashing: bcrypt
  • Validation: express-validator

Project Structure

β”œβ”€β”€ backend/                 # Backend API (v1.4+)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”‚   β”œβ”€β”€ database.js  # PostgreSQL configuration
β”‚   β”‚   β”‚   └── migrate.js   # Database migrations
β”‚   β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”‚   └── auth.js      # JWT authentication
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”‚   └── User.js      # User data model
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.js      # Auth endpoints
β”‚   β”‚   β”‚   └── user.js      # User endpoints
β”‚   β”‚   └── server.js        # Express server
β”‚   β”œβ”€β”€ package.json
β”‚   └── README.md
β”‚
β”œβ”€β”€ src/                     # Frontend
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ NavBottom.jsx    # Bottom navigation bar
β”‚   β”‚   β”œβ”€β”€ KpiCard.jsx      # Key performance indicator card
β”‚   β”‚   β”œβ”€β”€ ProgressBar.jsx  # Progress bar component
β”‚   β”‚   β”œβ”€β”€ ChartLine.jsx    # Line chart component
β”‚   β”‚   └── ChartPie.jsx     # Pie/doughnut chart component
β”‚   β”œβ”€β”€ context/
β”‚   β”‚   └── AuthContext.jsx  # Authentication context
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ Login.jsx        # Login page
β”‚   β”‚   β”œβ”€β”€ Signup.jsx       # Signup page
β”‚   β”‚   β”œβ”€β”€ Home.jsx         # Home dashboard
β”‚   β”‚   β”œβ”€β”€ Analytics.jsx    # Analytics page
β”‚   β”‚   β”œβ”€β”€ Leaderboard.jsx  # Rankings page
β”‚   β”‚   β”œβ”€β”€ Tasks.jsx        # Challenges page
β”‚   β”‚   └── Profile.jsx      # User profile page
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── api.js           # API service layer
β”‚   β”œβ”€β”€ App.jsx              # Main app with routing
β”‚   β”œβ”€β”€ main.jsx             # App entry point
β”‚   └── index.css            # Global styles
β”‚
β”œβ”€β”€ BACKEND_DEPLOYMENT.md    # Backend deployment guide
β”œβ”€β”€ render.yaml              # Render deployment config
└── package.json

Features (v1.4)

βœ… User Authentication

  • Secure signup and login with JWT
  • Password hashing with bcrypt
  • Session management

βœ… Data Persistence

  • PostgreSQL database
  • User profiles saved permanently
  • Progress tracking across sessions

βœ… Real Backend API

  • RESTful API endpoints
  • User progress updates
  • Challenge management
  • Leaderboard functionality
  • Energy usage tracking

βœ… Production Ready

  • Deployable to Render
  • Environment variable configuration
  • CORS protection
  • Input validation

Design Reference

Design source: Energy-Saving Teen App Prototype.make (in repo root)

  • Push notifications for challenges
  • Social features (friends, sharing)
  • Data export and reporting
  • Advanced analytics and insights

Deployment

πŸš€ Deploy to Render (v1.4+)

πŸ“– Complete Guide: DEPLOY_TO_RENDER.md ← START HERE for all deployment details

This comprehensive guide includes:

  • βœ… Two deployment options (Blueprint & Manual with exact steps)
  • βœ… All environment variables with exact values
  • βœ… Database setup and migration instructions
  • βœ… Complete troubleshooting section
  • βœ… Cost breakdown and free tier information
  • βœ… Verification procedures

🎯 Quick Reference: DEPLOY_QUICK_REFERENCE.md ← For experienced users

πŸ“‘ All Guides: DEPLOYMENT_GUIDE_INDEX.md ← Navigation to all deployment docs

Quick Deploy Summary

The application requires full-stack deployment:

  1. Sign in to Render
  2. New + β†’ Blueprint
  3. Connect repository (gang1103app/figmafigmaboi)
  4. Select branch 1.4
  5. Configure environment variables (see complete guide)
  6. Run database migration via backend Shell

Time: 15-30 minutes | Cost: Free tier available

See DEPLOY_TO_RENDER.md for complete step-by-step instructions with all specific details.

Deployment Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend      β”‚  Static Site (Vite + React)
β”‚   Render        β”‚  https://your-app.onrender.com
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β”‚ HTTPS API Calls
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Backend API   β”‚  Node.js + Express
β”‚   Render        β”‚  https://your-api.onrender.com
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β”‚ PostgreSQL Connection
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Database      β”‚  PostgreSQL
β”‚   Render        β”‚  Managed Database
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Important Notes (v1.4+)

  • ⚠️ Backend required - App needs API to function
  • ⚠️ Database required - PostgreSQL for data persistence
  • ⚠️ Environment variables required - Set API URLs
  • βœ… Automatic deployments on git push to branch 1.4
  • βœ… Free tier available on Render (with limitations)
  • βœ… Secure authentication with JWT tokens
  • βœ… Data persistence across sessions

Contributing

This is a demonstration project for the Energy Saving Teen app. For contributions or questions, please open an issue or pull request.

License

Private repository - All rights reserved

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages