GitHunt
AL

alastair87/plastic-dropoff-tracker

Plastic Drop-off Tracking Application

A comprehensive system for tracking plastic waste drop-offs with SMS integration, real-time monitoring, and geographic visualization.

System Architecture

Components

  1. SMS Gateway - Twilio integration for receiving drop-off reports via SMS
  2. API Layer - Express.js REST API for data management
  3. Application Logic - Data validation, processing, and user authentication
  4. Database - PostgreSQL with PostGIS for geographic data
  5. GIS Integration - Location-based queries and spatial analysis
  6. Notification System - SMS confirmations and alerts
  7. Analytics - Real-time reporting and insights
  8. Admin Dashboard - React-based monitoring interface

Tech Stack

Backend

  • Node.js + Express.js
  • PostgreSQL + PostGIS
  • Prisma ORM
  • Twilio SDK for SMS
  • JWT for authentication
  • Winston for logging

Frontend

  • React 18
  • React Router for navigation
  • Chart.js for data visualization
  • Leaflet for maps
  • Material-UI for styling
  • Axios for API calls

Project Structure

plastic-dropoff-tracker/
├── backend/
│   ├── src/
│   │   ├── controllers/
│   │   ├── models/
│   │   ├── routes/
│   │   ├── services/
│   │   ├── middleware/
│   │   ├── utils/
│   │   └── server.js
│   ├── prisma/
│   ├── package.json
│   └── .env.example
├── frontend/
│   ├── src/
│   │   ├── components/
│   │   ├── pages/
│   │   ├── services/
│   │   ├── utils/
│   │   └── App.js
│   ├── public/
│   └── package.json
├── docker-compose.yml
└── README.md

Installation

Prerequisites

  • Node.js 18+
  • PostgreSQL 14+ with PostGIS extension
  • Twilio account (for SMS functionality)

Backend Setup

  1. Navigate to backend directory:
cd backend
npm install
  1. Set up environment variables (copy .env.example to .env):
DATABASE_URL=postgresql://user:password@localhost:5432/plastic_tracker
JWT_SECRET=your-secret-key
TWILIO_ACCOUNT_SID=your-twilio-sid
TWILIO_AUTH_TOKEN=your-twilio-token
TWILIO_PHONE_NUMBER=your-twilio-number
  1. Initialize database:
npx prisma migrate dev
npx prisma generate
  1. Start the backend server:
npm run dev

Frontend Setup

  1. Navigate to frontend directory:
cd frontend
npm install
  1. Set up environment variables (create .env):
REACT_APP_API_URL=http://localhost:3001/api
  1. Start the frontend:
npm start

Docker Deployment

docker-compose up -d

Usage

SMS Format for Drop-offs

Users send SMS messages in the following format:

DROP <plastic_type> <quantity> <location>
Example: DROP PET 5 40.7128,-74.0060

Admin Dashboard

Access the dashboard at http://localhost:3000/admin

Features:

  • Real-time drop-off map
  • Analytics and charts
  • User management
  • Report generation
  • Alert configuration

API Endpoints

Public Endpoints

  • POST /api/sms/webhook - Twilio SMS webhook
  • POST /api/auth/login - Admin login

Protected Endpoints (require JWT)

  • GET /api/dropoffs - List all drop-offs
  • GET /api/dropoffs/:id - Get drop-off details
  • GET /api/analytics/summary - Get analytics summary
  • GET /api/users - List users
  • POST /api/notifications/send - Send notification

Security Features

  • JWT-based authentication
  • Encrypted data transmission (HTTPS)
  • Password hashing with bcrypt
  • Rate limiting on API endpoints
  • SQL injection prevention (Prisma ORM)
  • XSS protection
  • CORS configuration
  • Audit logging

Contributing

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

alastair87/plastic-dropoff-tracker | GitHunt