Skip to content

ss6909-cloud/Fluxore

Repository files navigation

๐Ÿš— Fluxore - EV Charging Station Management System

A comprehensive Database Management System (DBMS) mini project for managing EV charging stations, slot bookings, and user operations with role-based access control.

Now powered by SQLite - Zero configuration, file-based database! ๐ŸŽ‰

๐Ÿ“‹ Table of Contents

๐ŸŽฏ Overview

Fluxore is a smart EV charging station management system that allows users to book charging slots in advance and enables administrators to manage stations, vehicles, pricing, and system configuration. The project strongly demonstrates DBMS concepts including:

  • Entity Relationships - Complex relationships between users, stations, bookings, vehicles
  • Constraints - Primary keys, foreign keys, check constraints, unique constraints
  • Normalization - Database designed in 3NF (Third Normal Form)
  • Transactions - ACID properties maintained for critical operations
  • Role-based Access - Separate admin and user functionalities
  • Triggers - Automated calculations and validation
  • Views - Simplified complex queries
  • Indexes - Performance optimization

๐Ÿš€ Quick Start

Get running in 3 commands:

cd backend
npm install
npm run setup-db && npm run dev

Then open: http://localhost:3000

Default Credentials:

  • Admin: admin / password123
  • User: john_doe / password123

See QUICKSTART.md for more details.

โœจ Features

๐Ÿ‘ค User (Consumer) Features

  • โœ… User registration and authentication
  • ๐Ÿ“ View available charging stations across multiple locations
  • ๐Ÿš— Add and manage multiple EV vehicles
  • โฐ Book charging slots in advance
  • ๐Ÿ”‹ Automatic charging time estimation based on vehicle specs
  • โŒ Cancel bookings (with penalty fee if within 2 hours)
  • ๐Ÿ“Š View booking history and status
  • ๐Ÿ’ณ Dummy payment simulation

๐Ÿ”ง Admin Features

  • ๐Ÿข Add, edit, delete charging stations
  • ๐Ÿ”Œ Define number of charging ports per station
  • ๐Ÿ’ฐ Set pricing (price per kWh, per hour)
  • ๐Ÿš™ Add EV car makes and models with specifications
  • ๐Ÿ“ˆ View all bookings and system statistics
  • โš™๏ธ Manage system settings
  • ๐Ÿ’ต Configure cancellation penalty fees

โšก System Features

  • Fixed time slot management (30, 60, 90, 120 minutes)
  • Dynamic slot availability calculation
  • Prevents double booking using triggers
  • Charging estimation based on:
    • Battery capacity
    • Current charge level
    • Target charge level
    • Vehicle charging rate
    • Charging efficiency
  • Audit logging for tracking system events

๐Ÿ›  Technology Stack

Backend

  • Node.js - Runtime environment
  • Express.js - Web framework
  • SQLite3 - Embedded database (no server required!)
  • bcrypt - Password hashing
  • jsonwebtoken - Authentication
  • sqlite3 - Database driver

Frontend

  • HTML5 - Structure
  • CSS3 - Styling (Custom, no frameworks)
  • JavaScript (Vanilla) - Interactivity
  • Fetch API - HTTP requests

Database

  • SQLite - Zero-configuration, file-based, production-ready DBMS
    • Single fluxore.db file
    • No server setup required
    • Perfect for development and testing
    • Easy to backup and share
    • Can migrate to MySQL for production if needed

๐Ÿ—„ Database Design

ER Diagram (Entity Relationships)

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   ROLES     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚ 1
       โ”‚
       โ”‚ N
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   USERS     โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚  AUDIT_LOGS    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜   N   1  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚ 1
       โ”‚
       โ”‚ N
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ USER_VEHICLES   โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”‚ VEHICLE_MODELS     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  N 1 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚                           โ”‚ N
       โ”‚                           โ”‚
       โ”‚                           โ”‚ 1
       โ”‚                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚                  โ”‚  VEHICLE_MAKES    โ”‚
       โ”‚                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚ 1
       โ”‚
       โ”‚ N
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   BOOKINGS      โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  N    1  โ”‚
       โ”‚                     โ”‚
       โ”‚ 1                   โ”‚
       โ”‚                     โ”‚
       โ”‚ N         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚ CHARGING_STATIONS โ”‚
โ”‚  PAYMENTS   โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ”‚ 1
                            โ”‚
                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                  โ”‚ N       โ”‚ 1       โ”‚
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”     โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚TIME_SLOTS  โ”‚     โ”‚    โ”‚  PRICING  โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚ N
                   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                   โ”‚ CHARGING_PORTS    โ”‚
                   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key Tables

1. users

Stores user information with role-based access

  • Primary Key: user_id
  • Foreign Key: role_id โ†’ roles
  • Constraints: UNIQUE(username, email)

2. charging_stations

Stores charging station locations

  • Primary Key: station_id
  • Constraints: CHECK(total_ports > 0)

3. charging_ports

Individual ports at each station

  • Primary Key: port_id
  • Foreign Key: station_id โ†’ charging_stations
  • Constraints: UNIQUE(station_id, port_number)

4. vehicle_models

EV car models with technical specs

  • Primary Key: model_id
  • Foreign Key: make_id โ†’ vehicle_makes
  • Constraints: CHECK(battery_capacity_kwh > 0, charging_rate_kw > 0)

5. bookings

Central table for charging slot bookings

  • Primary Key: booking_id
  • Foreign Keys: user_id, station_id, port_id, user_vehicle_id, slot_id
  • Constraints: CHECK(target > current), CHECK(end_time > start_time)
  • Trigger: Prevents double booking

6. payments

Payment transactions

  • Primary Key: payment_id
  • Foreign Keys: booking_id, user_id
  • Constraints: UNIQUE(transaction_id)

Normalization

First Normal Form (1NF)

  • All tables have atomic values
  • Each column contains single values
  • Each row is unique (primary key)

Second Normal Form (2NF)

  • All non-key attributes fully depend on primary key
  • No partial dependencies
  • Example: vehicle_models depends on model_id, not on make details

Third Normal Form (3NF)

  • No transitive dependencies
  • Example: Pricing is separate from stations to avoid redundancy
  • User vehicles separated from users to handle multiple vehicles

Constraints Implemented

-- Primary Keys
โœ“ Every table has a primary key

-- Foreign Keys  
โœ“ All relationships enforced with CASCADE/RESTRICT

-- Check Constraints
โœ“ Battery capacity > 0
โœ“ Charging rate > 0
โœ“ Efficiency between 50-100%
โœ“ Port number > 0
โœ“ Charge percentages 0-100
โœ“ Target > Current charge

-- Unique Constraints
โœ“ Username, email unique
โœ“ Port numbers unique per station
โœ“ Transaction IDs unique

-- NOT NULL
โœ“ Critical fields marked as required

-- Default Values
โœ“ Timestamps, status fields, booleans

Triggers

  1. trg_prevent_double_booking

    • Prevents overlapping bookings on same port
    • Validates time slot availability
    • Raises error if conflict detected
  2. trg_calculate_charging_estimates

    • Automatically calculates energy needed
    • Computes charging duration
    • Based on vehicle specifications
  3. trg_log_booking_cancellation

    • Creates audit log entry
    • Tracks cancellation events

Views

  1. v_station_availability

    • Shows stations with port counts
    • Active vs available ports
    • Operational status
  2. v_user_booking_history

    • Comprehensive booking details
    • Joins users, stations, vehicles
    • Sorted by date
  3. v_active_pricing

    • Current pricing configuration
    • Station-specific or default
    • Date-range filtered

๐Ÿ“ฆ Installation

Prerequisites

  • Node.js (v14 or higher)
  • MySQL/MariaDB (v5.7 or higher)
  • npm or yarn

Step 1: Clone/Download Project

cd Fluxore-EV-Charging-System

Step 2: Setup Database

# Login to MySQL
mysql -u root -p

# Run schema
mysql -u root -p < database/schema.sql

# Load sample data
mysql -u root -p < database/sample_data.sql

Step 3: Configure Backend

cd backend

# Install dependencies
npm install

# Create .env file
cp .env.example .env

# Edit .env with your database credentials
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=fluxore_db

Step 4: Start Server

# Development mode
npm run dev

# Production mode
npm start

Server will start at http://localhost:3000

Step 5: Access Application

Open browser and navigate to:

http://localhost:3000

๐Ÿš€ Usage

Default Credentials

Admin Login:

  • Username: admin
  • Password: password123

User Login:

  • Username: john_doe
  • Password: password123

User Workflow

  1. Register new account or login
  2. Add your EV vehicle (make, model)
  3. Browse charging stations
  4. Select station and check availability
  5. Book a time slot
  6. Make payment (dummy)
  7. View booking confirmation
  8. Cancel if needed (check penalty)

Admin Workflow

  1. Login with admin credentials
  2. Add new charging stations
  3. Configure ports for each station
  4. Add vehicle makes and models
  5. Set pricing configuration
  6. View all bookings
  7. Manage system settings

๐Ÿ”Œ API Endpoints

Authentication

POST   /api/auth/register    - Register new user
POST   /api/auth/login       - User login

Stations

GET    /api/stations              - Get all stations
GET    /api/stations/:id          - Get station by ID
GET    /api/stations/:id/availability - Check available slots

Vehicles

GET    /api/vehicles/makes                  - Get all makes
GET    /api/vehicles/makes/:id/models       - Get models by make
GET    /api/vehicles/user/:userId           - Get user vehicles
POST   /api/vehicles/user/:userId           - Add vehicle

Bookings

POST   /api/bookings                    - Create booking
GET    /api/bookings/user/:userId       - Get user bookings
GET    /api/bookings/:id                - Get booking by ID
PUT    /api/bookings/:id/cancel         - Cancel booking

Admin (Requires Admin Role)

GET    /api/admin/bookings              - View all bookings
POST   /api/admin/stations              - Add station
PUT    /api/admin/stations/:id          - Update station
DELETE /api/admin/stations/:id          - Delete station
POST   /api/admin/vehicle-makes         - Add vehicle make
POST   /api/admin/vehicle-models        - Add vehicle model
POST   /api/admin/pricing               - Update pricing
GET    /api/admin/settings              - Get settings
PUT    /api/admin/settings/:key         - Update setting
GET    /api/admin/dashboard/stats       - Dashboard statistics

Payments

POST   /api/payments/process            - Process payment
GET    /api/payments/booking/:id        - Get payment by booking
GET    /api/payments/user/:userId       - User payment history

๐Ÿ“š DBMS Concepts Demonstrated

1. Entity Relationships

  • One-to-Many: Users โ†’ Bookings, Stations โ†’ Ports
  • Many-to-One: Bookings โ†’ Users, Models โ†’ Makes
  • One-to-One: Booking โ†’ Payment (in most cases)

2. Referential Integrity

  • All foreign keys enforce relationships
  • CASCADE delete where appropriate
  • RESTRICT to prevent orphaned records

3. Data Integrity Constraints

  • Entity Integrity: Primary keys on all tables
  • Referential Integrity: Foreign key constraints
  • Domain Integrity: Check constraints, data types
  • User-defined Integrity: Business rules via triggers

4. Normalization Benefits

  • โœ… No data redundancy
  • โœ… Consistent updates
  • โœ… Efficient storage
  • โœ… Maintainable structure

5. Transactions (ACID)

  • Atomicity: Booking + Payment as single unit
  • Consistency: Constraints enforced
  • Isolation: Concurrent bookings handled
  • Durability: Committed transactions persisted

6. Indexes

  • Primary key indexes (automatic)
  • Foreign key indexes for joins
  • Custom indexes on frequently queried columns
  • Improves query performance

7. Views

  • Abstraction of complex queries
  • Security (hide sensitive data)
  • Simplified application code

8. Triggers

  • Automated business logic
  • Data validation
  • Audit logging
  • Calculated fields

๐Ÿ“ Project Structure

Fluxore-EV-Charging-System/
โ”‚
โ”œโ”€โ”€ database/
โ”‚   โ”œโ”€โ”€ schema.sql              # Complete database schema
โ”‚   โ””โ”€โ”€ sample_data.sql         # Sample data for testing
โ”‚
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ””โ”€โ”€ database.js         # Database connection
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ”œโ”€โ”€ auth.routes.js      # Authentication
โ”‚   โ”‚   โ”œโ”€โ”€ station.routes.js   # Stations API
โ”‚   โ”‚   โ”œโ”€โ”€ vehicle.routes.js   # Vehicles API
โ”‚   โ”‚   โ”œโ”€โ”€ booking.routes.js   # Bookings API
โ”‚   โ”‚   โ”œโ”€โ”€ admin.routes.js     # Admin API
โ”‚   โ”‚   โ””โ”€โ”€ payment.routes.js   # Payments API
โ”‚   โ”œโ”€โ”€ server.js               # Express server
โ”‚   โ”œโ”€โ”€ package.json            # Dependencies
โ”‚   โ””โ”€โ”€ .env.example            # Environment template
โ”‚
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ css/
โ”‚   โ”‚   โ””โ”€โ”€ style.css           # Complete styling
โ”‚   โ”œโ”€โ”€ js/
โ”‚   โ”‚   โ”œโ”€โ”€ main.js             # Core utilities
โ”‚   โ”‚   โ””โ”€โ”€ user-dashboard.js   # Dashboard logic
โ”‚   โ”œโ”€โ”€ index.html              # Landing page
โ”‚   โ”œโ”€โ”€ login.html              # Login page
โ”‚   โ”œโ”€โ”€ register.html           # Registration
โ”‚   โ””โ”€โ”€ user-dashboard.html     # User dashboard
โ”‚
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ ER_DIAGRAM.md           # ER diagram explanation
โ”‚   โ”œโ”€โ”€ VIVA_QUESTIONS.md       # Common viva questions
โ”‚   โ””โ”€โ”€ DBMS_CONCEPTS.md        # Detailed concepts
โ”‚
โ””โ”€โ”€ README.md                   # This file

๐Ÿ–ผ Screenshots

(Add screenshots after running the application)

  1. Landing Page
  2. User Registration
  3. Login Page
  4. User Dashboard
  5. Station Listing
  6. Booking Form
  7. Available Slots
  8. Booking History
  9. My Vehicles
  10. Admin Dashboard

๐Ÿ”ฎ Future Enhancements

Phase 2 Features

  • Real-time slot availability using WebSockets
  • Google Maps integration for station locations
  • Email/SMS notifications
  • Payment gateway integration (Razorpay, Stripe)
  • Mobile app (React Native)
  • Charging session monitoring
  • Dynamic pricing based on demand
  • Loyalty points and rewards
  • Station reviews and ratings
  • Multi-language support

Advanced DBMS Features

  • Stored procedures for complex operations
  • Database replication for high availability
  • Query optimization and performance tuning
  • Database backup and recovery procedures
  • Data warehousing for analytics
  • Full-text search for stations

๐ŸŽ“ VIVA Questions & Answers

See docs/VIVA_QUESTIONS.md for:

  • Common DBMS concept questions
  • Project-specific questions
  • Technical explanations
  • Database design justifications

๐Ÿ“„ License

This is an educational project for DBMS mini project purposes.

๐Ÿ‘ฅ Contributors

  • SABAREESH S NAIR

๐Ÿ™ Acknowledgments

  • SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
  • Course: Database Management Systems
  • Instructor: [KARTHIKEYAN]
  • Year: 2026

๐Ÿ“ž Support

For any queries or issues:


Built with โค๏ธ for DBMS Mini Project

Demonstrating practical application of database concepts in a real-world scenario

About

Fluxore : An EV Charging Infrastructure Scheduling And Allocation System

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors