8000 GitHub - OMDANGE01/EcoGram011: the full production ready web site and we use the supa base with email varifiaction · GitHub
[go: up one dir, main page]

Skip to content

About

the full production ready web site and we use the supa base with email varifiaction

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

EcoGram — Morgaon Digras Gram Panchayat Portal & CEP Showcase

Public village showcase and authenticated Gram Panchayat worker portal for Morgaon Digras (Buldhana District, Maharashtra), built with React, TypeScript, Vite, Tailwind CSS, and Supabase (PostgreSQL + Supabase Auth).


Features

  1. Public Village Showcase (/) — Read-only portal accessible to all visitors:

    • Demographics & Household Statistics: Live census metrics (population, households, male, female distribution) fetched from Supabase village_stats.
    • Gram Panchayat Leadership: Elected Sarpanch and Administrative Gram Sevak profiles.
    • Plastic-Free Village Mission (CEP 01): Live cumulative waste segregation metrics (Wet, Dry, Plastic in kg) and dynamic SVG Plastic Waste bar chart computed from Supabase waste_logs.
    • Sustainable Low-Cost Housing (CEP 02): Showcase of CSEB blocks, treated bamboo roof trusses, lime-mud thermal plaster, and rainwater harvesting.
    • Interactive Satellite Map: Embedded Google Maps satellite view centered on Morgaon Digras (20.811684° N, 76.557083° E).
  2. Panchayat Login (/login):

    • Email and password sign-in powered by supabase.auth.signInWithPassword.
    • Password visibility toggle, loading spinner, inline error handling, and Forgot Password reset email flow (supabase.auth.resetPasswordForEmail).
    • Invite-only access: no public sign-up button or hardcoded demo credentials.
  3. Protected Panchayat Portal (/panchayat):

    • Accessible only to authenticated Panchayat workers (unauthenticated users are automatically redirected to /login).
    • Daily Waste Logger: Add, edit, delete, and filter daily waste collection logs by date range and waste type (Wet, Dry, Plastic), with optional notes and non-negative validation.
    • Village Statistics Editor: Update official village demographics and leadership (id = 1 in village_stats) with strict validation ensuring Male + Female = Total Population.

Local Setup

  1. Install dependencies:

    npm install
  2. Configure environment variables: Copy .env.example to .env and fill in your Supabase project credentials (found in Supabase Dashboard → Project Settings → API):

    VITE_SUPABASE_URL="https://your-project-id.supabase.co"
    VITE_SUPABASE_ANON_KEY="your-public-anon-key"

    Security Note: Only use the public anon key in VITE_SUPABASE_ANON_KEY. Never expose your service_role secret key in frontend code.

  3. Start the development server:

    npm run dev

Database Schema Reference (Supabase)

The app expects two existing tables in your Supabase PostgreSQL database with Row Level Security (RLS) enabled (Public SELECT, Authenticated INSERT/UPDATE/DELETE):

  • village_stats:

    • id (int / bigint, primary key — single row with id = 1)
    • population (integer)
    • households (integer)
    • male (integer)
    • female (integer)
    • sarpanch (text)
    • gram_sevak (text)
    • updated_at (timestamptz)
  • waste_logs:

    • id (uuid, primary key, default gen_random_uuid())
    • log_date (date)
    • wet_kg (numeric)
    • dry_kg (numeric)
    • plastic_kg (numeric)
    • notes (text, nullable)
    • created_by (uuid, nullable)
    • created_at (timestamptz, default now())

How to Add a New Panchayat Worker in Supabase

Because public sign-up is disabled for security, new Panchayat staff accounts are created by the administrator directly in Supabase:

  1. Open your project in the Supabase Dashboard.
  2. In the left sidebar, click Authentication → Users.
  3. Click the Add user button (top right) and select Create new user (or Send invitation).
  4. Enter the Panchayat worker's Email Address and a strong Password.
  5. Ensure Auto Confirm User is checked so they can sign in immediately.
  6. Click Create user. The worker can now log in at /login on the portal.

Deploying to Vercel & Setting Environment Variables

  1. Push this repository to GitHub/GitLab/Bitbucket and import it into Vercel.
  2. In your Vercel project dashboard, go to Settings → Environment Variables.
  3. Add the following two variables for Production, Preview, and Development environments:
    • VITE_SUPABASE_URL = https://your-project-id.supabase.co
    • VITE_SUPABASE_ANON_KEY = your-public-anon-key
  4. Click Save and trigger a Redeploy from the Deployments tab.
  5. The included vercel.json file automatically configures SPA rewrites so refreshing /login or /panchayat works seamlessly without 404 errors.

About

the full production ready web site and we use the supa base with email varifiaction

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0