Skip to content

Latest commit

Β 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Smart Campus Analytics System

🎯 Smart Campus Resource & Energy Analytics System

IIIT Dharwad DA264 Project Β· Full-Stack DBMS with Data Warehouse, ETL Pipeline & Real-Time Analytics

SQL Server Python FastAPI React Star Schema Production Ready MIT License

Overview β€’ Features β€’ Architecture β€’ Dashboard β€’ Database β€’ Quick Start β€’ Highlights


πŸ“‹ Overview

Smart Campus is a production-grade Business Intelligence system that transforms raw campus operational data into real-time, actionable insights. The platform combines:

  • 12 BCNF-normalized OLTP tables capturing live transactions (energy readings, bookings, maintenance, access logs)
  • Star Schema OLAP warehouse (515+ fact rows, 97.7% data quality) optimized for analytics
  • Python ETL pipeline with incremental loading, IQR outlier detection, and surrogate key mapping
  • Real-time React dashboard (9 modules, 28-second auto-refresh) with interactive OLAP operations
  • Complete DBMS mastery demonstration: normalization proofs, transaction management (ACID/2PL), query optimization, data quality enforcement

Live Data: The system monitors 6 campus buildings, 16 rooms, 27 energy meters, 200+ bookings, 109 users with full operational dashboards.


🎯 Problem Statement & Solution

The Challenge

Campuses generate massive amounts of operational dataβ€”energy readings, room bookings, maintenance requests, access logsβ€”but lack a unified system to:

  • 🚫 Track real-time resource utilization across campus
  • 🚫 Detect anomalies (energy spikes, SLA breaches, security risks)
  • 🚫 Analyze historical trends using clean, warehoused data
  • 🚫 Support data-driven campus management

The Solution: Smart Campus

βœ… Single source of truth for all campus operations βœ… Real-time dashboards showing energy consumption, room utilization, maintenance status, security events βœ… Historical analytics via star schema data warehouse with OLAP drilldown βœ… Data quality enforcement with IQR-based anomaly detection (97.7% clean) βœ… Production-grade architecture demonstrating enterprise DBMS patterns


✨ Key Features

πŸ“Š Overview Dashboard

Overview Dashboard

8 Live KPI Cards (auto-refreshing every 28 seconds):

  • Total Energy: 87.3 MWh (+4.2% vs last month)
  • Campus Users: 109 registered (76 students, 15 faculty, 15 staff, 3 admins)
  • Rooms Tracked: 16 monitored spaces across campus
  • Total Bookings: 200 approved bookings (+32 this week)
  • Open Maintenance Tickets: 18 unresolved issues
  • Access Events: 208 total logged entries
  • Active Equipment: 65 devices online
  • Active Meters: 27 energy sensors live

Campus Health Score (82/100) composite metric:

  • Energy Efficiency: 78 (proximity to consumption baselines)
  • Maintenance: 69 (SLA compliance: 20% β€” see maintenance dashboard)
  • Space Utilization: 85 (booking density vs room capacity)

Energy + Booking Weekly Trend: Dual-axis chart showing correlation between energy demand and room usage across 10 weeks (bars = energy in MWh, line = bookings count).


⚑ Energy Analysis

Dashboard: Room-Level Drilldown Energy Analysis Dashboard

Four KPI cards:

  • Total kWh: 1,351 kWh (current period)
  • Est. Cost: β‚Ή11.5K (at β‚Ή8.5/unit, Indian standard)
  • COβ‚‚ Footprint: 1,108 kg (using 0.82 kg COβ‚‚/kWh factor)
  • Avg Voltage: 228.4 V (across all 27 active meters)

Room-Level Energy Breakdown (tagged "DRILL-DOWN"): Ranked by consumption with peak multiplier analysis (SQL LAG window function):

  • Seminar Hall: 311 kWh (100% baseline, peak 1.72Γ—)
  • L301 Computer Lab: 248 kWh (80% baseline, peak 1.71Γ—)
  • L201 Computer Lab: 197 kWh (63% baseline)
  • C202 Classroom: 183 kWh (55% baseline)

Department Energy Roll-Up (tagged "OLAP ROLL-UP"): Using GROUP BY ROLLUP aggregation:

  • Computer Science & Engineering: 524 kWh
  • Electronics & Comm: 281 kWh
  • Data Science & AI: 200 kWh

Room Γ— Hour Energy Heatmap (tagged "IQ MATRIX"): Color grid (8 AM–6 PM, darker red = higher kWh) showing peak usage hours by room location, sourced from OLAP SLICE query.


Building Energy Analysis & Anomalies Energy Analysis Building Breakdown

Building Energy Roll-Up (from warehouse):

  • E Block (Academic): 4,820 kWh (highest, 55%)
  • PI Block (Admin+Research): 1,230 kWh (14%)
  • B Block (Boys Hostel): 980 kWh (11%)
  • G Block (Girls Hostel): 860 kWh (10%)
  • H Block (Gym+Canteen): 540 kWh (6%)
  • M Block (Sports): 320 kWh (4%) Peak ratio: 58% peak hours (9 AM–12 PM class startup, 3 PM afternoon peak)

Meter Type Distribution (donut):

  • Electricity: 11 meters (primary)
  • Solar: 7 meters (renewable)
  • Water: 4 meters (utility)
  • Gas: 5 meters (cooking)

24-Hour Energy Profile (line chart): Double-peak pattern:

  • Morning peak (~9 AM): Class startup, computer labs boot
  • Afternoon peak (~3 PM): Afternoon sessions, lab usage

Anomaly Detection & Equipment Status Energy Anomaly Detection

Solar vs Grid Energy β€” Monthly (6-month bar chart):

  • Grid (blue): Primary source, ~350–450 kWh/month
  • Solar (orange): Renewable, ~100–150 kWh/month (23% coverage)
  • 6-Month Solar Generation: 811 kWh total

COβ‚‚ Footprint Trend (area chart):

  • Total COβ‚‚: 2,238 kg (6-month period)
  • vs Last Year: -12% improvement (sustainability effort tracking)

Anomaly Detection β€” LAG Window Analysis (table): Using SQL LAG() to compare each reading against previous reading for same meter:

  • M-4 (03:00): 8.7 kWh β†’ 9.2 kWh (+3.6 delta) β†’ πŸ”΄ SPIKE DETECTED
  • M-14 (12:00): 9.5 kWh β†’ 9.5 kWh (+5.6 delta) β†’ πŸ”΄ SPIKE DETECTED
  • M-9 (16:00): 9.5 kWh β†’ 9.5 kWh (+4.2 delta) β†’ πŸ”΄ SPIKE DETECTED
  • Other readings: Normal status (grey)

Equipment Status & Asset Registry (donut + bar):

  • Active: 65 devices (green)
  • Inactive: 27 devices (grey)
  • Under Repair: 18 devices (red) Equipment types breakdown by count.

🏒 Infrastructure

Campus Buildings Overview Infrastructure Campus Buildings

6 Campus Buildings (each card shows floors, rooms, build year, utilization bar):

  • PI Block (Admin+Research): 3 floors, 4 rooms, 2019, 68% util
  • E Block (Academic): 5 floors, 16 rooms, 2020, 91% util β€” HIGHEST πŸ”΄
  • M Block (Sports): 2 floors, 42% util
  • B Block (Boys Hostel): 4 floors, 78% util
  • G Block (Girls Hostel): 4 floors, 74% util
  • H Block (Gym+Canteen): 2 floors, 55% util

Room Type Distribution:

  • 6 Computer Labs
  • 6 Classrooms
  • 3 ECE Labs
  • 3 Seminar Halls Total: 16 monitored rooms

Room Capacity Overview (bars):

  • Total Seats: 1,860 across campus
  • Average: 116 seats/room
  • Largest Room: 240 seats (Seminar Hall)

Equipment Analytics & IoT Network Equipment IoT Network Summary

Equipment Analytics (ASSET REGISTRY): Horizontal bar by count + installed power capacity breakdown:

  • Air Conditioners: 42.0 kW
  • GPU Servers: 24.0 kW
  • Solar Inverters: 75.0 kW
  • Projectors: 5.0 kW
  • Desktop PCs: 6.3 kW
  • Other: Additional infrastructure Total Installed Capacity: 165 kW

Smart Sensors Network (4 KPI cards):

  • 27 Energy Meters (Electricity, Solar, Water, Gas monitoring)
  • 16 Access Readers (RFID + Biometric + PIN multi-factor auth)
  • 12 HVAC Sensors (Temperature + Humidity control)
  • 24 IP Cameras (24Γ—7 surveillance, all green online status)

πŸ“… Room Bookings

Booking Status & Trends Room Bookings Dashboard

Status KPI Cards (from BOOKING table GROUP BY status):

  • Approved: 7 bookings βœ…
  • Pending: 1 booking ⏳
  • Cancelled: 1 booking ❌
  • Rejected: 1 booking ❌
  • Completed: 2 bookings βœ”οΈ

Monthly Booking Trend (6-month grouped bar chart): Approval patterns across 6 months:

  • Green (Approved) dominates
  • Amber (Pending) small bars
  • Red (Rejected) minimal
  • Grey (Cancelled) rare Shows consistent ~75% approval rate.

Room Booking Status PIVOT Table (tagged "SLICE & DICE"): SQL PIVOT cross-tabulation (rooms Γ— status):

  • Seminar Hall: 12 total, 57% util
  • C101: 8 total, 62% util (highest)
  • L301: 10 total, 49% util
  • C202: 7 total, 44% util
  • L201: 9 total, 64% util
  • L101: 5 total, 36% util

Booking Split (donut): 75% approval rate

Peak Booking Hours (bar chart): Shows demand by hour across day (peak during 10 AM–1 PM lecture hours).


Full Booking Registry Room Booking Registry

Booking Registry (ALL RECORDS table, 200+ rows): Every booking with:

  • Date: Apr 7–11 visible
  • Time: 08:00–09:00, 09:00–10:00, etc.
  • Room: C101, C201, L201, Seminar Hall, C202, L101, Mini, C104
  • Department: CSE, ECE, DSAI
  • Booked By: Dr Rao, Dr Sharma, Dr Mehta, Arjun Kumar, Priya Singh, Rahul Pathi, Gopal Gupta, Neha Verma
  • Purpose: DBMS Lecture, Signals Class, ML Lab, Project Review, DSA Lecture, ECE Lab Practice, Seminar Presentation, Group Study, Workshop, Morning Briefing, Data Science Lab, Hackathon Prep
  • Status Badge: Color-coded (Green=Approved, Amber=Pending, Red=Rejected, Grey=Cancelled, Blue=Completed)

πŸ”§ Maintenance

Maintenance Dashboard & SLA Analytics Maintenance Dashboard Overview

Status KPI Cards:

  • Open: 3 unresolved tickets
  • In Progress: 5 being worked on
  • Resolved: 2 fixed
  • Total: 10 tickets

Mean Time To Resolve (MTTR) β€” SLA Performance (bars per priority): Computed using AVG(DATEDIFF(hour, raised_at, resolved_at)) per priority tier:

  • Critical: 8.4h avg ⚠️ (target 4h, 4.4h over)
  • High: 18.2h avg ⚠️ (target 10h, 8.2h over)
  • Medium: 36.8h avg ⚠️ (target 24h, 12.8h over)
  • Low: 72.1h avg ⚠️ (target 48h, 24.1h over)

Ticket Aging Analysis (bar chart):

  • 0–7 days (green): Few tickets
  • 8–14 days (amber): Some aging
  • 15–30 days (orange): Moderate aging
  • >30 days (red): Critical aging, largest bar

Maintenance Ticket Queue & Priority Maintenance Ticket Queue Priority

Maintenance Ticket Queue (LIVE QUEUE tag): Open/in-progress tickets as color-coded cards:

  1. GPU Server overheating in L301 (Critical, In Progress) πŸ”΄
  2. Lights flickering in classroom (Critical, Open) πŸ”΄
  3. Water leakage near server rack in L303 (Critical, In Progress) πŸ”΄

Priority Distribution (bar chart):

  • Critical: 3 tickets πŸ”΄
  • High: 4 tickets 🟠
  • Medium: 2 tickets 🟑
  • Low: 1 ticket 🟒

SLA Compliance (gauge): 20% (only 2 of 10 tickets resolved within SLA window)

Hotspot Rooms (list): Preventive maintenance priority:

  • Seminar Hall: 2 tickets
  • L101: 2 tickets
  • L301: 1 ticket
  • C202: 1 ticket
  • L303: 1 ticket

πŸ” Access & Security

Access Security Dashboard Access Security Dashboard

KPI Cards:

  • Total Entries: 8 logged access attempts
  • Unique Users: 7 distinct individuals
  • Avg Duration: 103 minutes average stay
  • After-Hours: 1 flagged entry ⚠️

Security Risk Score (radial gauge, 87/100): Real-time assessment rewarding multi-factor auth, penalizing after-hours entries, flagging high-frequency sensitive room access.

Auth Methods Split (donut):

  • RFID: 3 entries
  • Biometric: 1 entry
  • PIN: 3 entries
  • Manual: 1 entry

Most Accessed Rooms (list):

  • L201: 4 entries (highest)
  • C301: 1 entry
  • L101: 1 entry
  • C201: 1 entry
  • C102: 1 entry

After-Hours Alerts:

  • Ravi Desai late-night L201 entry flagged 🚨

Access Log Entries (ANTI-SUIT TRACKING table): Each row: user, room, auth method, entry time, duration (minutes)

  • Keya Reddy, L201, RFID, 12:31, 155 min
  • Ankur Shah, L201, Biometric, 12:45, 173 min
  • Priyanka K., L201, PIN, 16:43, 84 min
  • Anand Reddy, C301, RFID, 10:31, 71 min
  • Madhav Nair, L101, Manual, 13:31, 84 min
  • Ashok Shah, C201, PIN, 12:45, 88 min
  • Ravi Desai, C102, RFID, 22:21, 88 min 🚨
  • Panya Desai, L201, PIN, 10:43, 172 min

Peak Access Times (bar chart): 12h noon highlighted orange (high-risk simultaneous-access hour, multiple users entering at once). Other hours blue (normal).


πŸ‘₯ User Analytics

User Analytics Dashboard User Analytics Dashboard

Role Distribution KPIs:

  • Students: 76 (70%) πŸ‘¨β€πŸŽ“
  • Faculty: 15 (14%) πŸ‘¨β€πŸ«
  • Staff: 15 (14%) πŸ‘·
  • Admins: 3 (3%) πŸ‘¨β€πŸ’Ό Total: 109 users

Department-wise Activity (grouped bar chart, OLAP DRILL-DOWN): Comparing bookings, logins, access events across 3 departments via JOIN:

  • CSE: ~45 bookings, ~60 logins, ~75 access events
  • ECE: ~35 bookings, ~50 logins, ~60 access events
  • DSAI: ~30 bookings, ~40 logins, ~50 access events

User Engagement Quadrant (scatter plot): x-axis = bookings, y-axis = access events

  • Faculty cluster (top-right): High booking, high access
  • Students (spread): Wide variance in engagement
  • Staff (left): Typically low-booking, high-access

User Role Distribution (donut): Proportional arcs for all 4 roles.

Most Active Users Leaderboard (ACTIVITY RANKING): Composite score = 0.4Γ—bookings + 0.3Γ—access + 0.3Γ—energy_rank

  1. Dr Rao (Faculty, CSE): 12 bookings, 8 access, score 94 πŸ₯‡
  2. Dr Sharma (ECE): 10 bookings, 7 access, score 88 πŸ₯ˆ
  3. Dr Mehta (DSAI): 9 bookings, 6 access, score 84 πŸ₯‰
  4. Gopal Gupta (Student, DSAI): 5 bookings, 4 access, score 62
  5. Keya Reddy (Student, CSE): 4 bookings, 9 access, score 71
  6. Ankur Shah (Student, CSE): 4 bookings, 9 access, score 71
  7. Arjun Kumar (Student, CSE): 4 bookings, 3 access, score 58
  8. Ashok Shah (Staff): 3 bookings, 10 access, score 65

πŸ“¦ Data Warehouse

ETL Pipeline & Run History ETL Pipeline Monitor

Data Warehouse KPI Cards:

  • Fact Rows: 515 rows loaded into star schema
  • Dim Rows: 47 dimension records (date, room, meter aggregations)
  • ETL Runs: 9 successful since Jan 2025
  • Data Quality: 97.7% (rows passing IQR filter)

ETL Pipeline β€” OLTP β†’ Data Warehouse (5-step flow):

  1. OLTP Source β†’ Extract new ENERGY_READING rows via watermark
  2. Watermark Check β†’ Avoids duplicates (tracks max date)
  3. IQR Cleaning β†’ Q1βˆ’1.5Γ—IQR to Q3+1.5Γ—IQR (removes sensor errors)
  4. Transform β†’ Surrogate key mapping (room/meter β†’ dim keys)
  5. Warehouse Load β†’ Bulk append to fact_energy_consumption

ETL Run History (AUDIT LOG):

  • ETL-009: 148 extracted, 141 loaded, 14.2s, βœ… Success
  • ETL-008: 132 extracted, 128 loaded, 12.8s, βœ… Success
  • ETL-007: 156 extracted, 149 loaded, 15.1s, βœ… Success
  • ETL-006: 121 extracted, 118 loaded, 11.8s, βœ… Success
  • ETL-005: 0 extracted, 0 loaded, 2.1s, βœ… "No New Data" (watermark matched)
  • ETL-004: 163 extracted, 0 loaded, 18.9s, ❌ "Failed" (IQR rejected all rows as outliers)
  • ETL-003: 144 extracted, 138 loaded, 13.9s, βœ… Success

Star Schema & OLAP Operations Star Schema OLAP Explorer

Star Schema Diagram (DATA WAREHOUSE DESIGN):

  • Central Fact Table: fact_energy_consumption (515 rows)

    • Measures: kwh_consumed, peak_flag, avg_voltage
    • Foreign keys to 4 dimensions
  • Dimension Tables:

    • dim_date: 365 rows (full 2025 calendar)
    • dim_room: 16 rows (all monitored spaces)
    • dim_meter: 27 rows (all energy sensors)
    • Snowflake extension: dim_building, dim_department (hierarchical normalization)

OLAP Operations Explorer (5 interactive tabs):

Tab 1: Roll-Up

SELECT YEAR(full_date), QUARTER(full_date), MONTH(full_date), SUM(kwh_consumed)
FROM fact_energy_consumption
GROUP BY GROUPING SETS (YEAR(full_date), ...)

Results:

  • 2025-Mar: 524.8 kWh
  • 2025 Total: 1,006.2 kWh
  • Grand Total: 1,006.2 kWh

Tab 2: Drill-Down Campus β†’ Building β†’ Floor β†’ Room level analytics

Tab 3: Slice Filter year = 2025, show all rooms and meters

Tab 4: Dice Multi-dimensional filter (Q1 2025 + Computer Labs + Electricity meters simultaneously)

Tab 5: Pivot Buildings as columns, months as rows, kWh as values


πŸ”„ Live Operations

Live Operations Center Live Operations Center

Real-time data entry console with 28-second auto-refresh countdown and green "Live" indicator.

4 Real-Time Forms (each executes direct SQL INSERT via FastAPI):

Form 1: Log Energy Reading

  • Meter dropdown (from ENERGY_METER)
  • kWh Consumed (numeric, e.g., 4.75)
  • Voltage (V) (pre-filled 230Vβ€”Indian standard)
  • Peak Hour (Yes/No toggle β†’ peak_flag BIT)
  • Button: "Insert Reading β†’ SQL Server"

Form 2: Create Room Booking

  • User dropdown
  • Room dropdown
  • Start Time (datetime picker)
  • End Time (datetime picker)
  • Purpose (free text)
  • Conflict detection via stored procedure usp_AddBooking
  • Button: "Submit Booking β†’ SQL Server"

Form 3: Raise Maintenance Ticket

  • Room dropdown (FK, NOT NULL β€” weak entity constraint)
  • Reported By dropdown (USERS)
  • Priority (Critical/High/Medium/Low)
  • Description (free text)
  • Button: "Create Ticket β†’ SQL Server"

Form 4: Log Access Event

  • User dropdown
  • Room dropdown
  • Auth Method (RFID/Biometric/PIN/Manual)
  • Auto-detected after-hours flag if entry_time > 22:00
  • Button: "Log Access β†’ SQL Server"

Bonus: Trigger ETL Pipeline

  • Green "Run ETL Now" button
  • Executes Python script: watermark β†’ extract β†’ clean β†’ transform β†’ load
  • Updates Data Warehouse tab with new run

πŸŽ› Normalization & ACID

OLTP vs OLAP Comparison OLTP OLAP Comparison

Metric OLTP (SmartCampusDB) OLAP (Warehouse)
Query Type Short INSERT/UPDATE/SELECT Complex aggregations
Schema Normalized 3NF/BCNF Star / Snowflake (denorm)
Data Volume Current days/weeks Historical months/years
Concurrent Users Many (100s) Few analysts
Update Frequency Continuous real-time Nightly ETL batch
Response Time Milliseconds Seconds to minutes
Optimization Write-optimized Read-optimized (indexes)
Example Query INSERT INTO BOOKING ... GROUP BY GROUPING SETS ...

Snowflake Extension β€” Normalized Dimensions:

  • dim_room references dim_building (1:M)
  • dim_building references dim_department (1:M)
  • Drill-down hierarchy: Campus β†’ Dept β†’ Building β†’ Floor β†’ Room

πŸ— Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              SMART CAMPUS ANALYTICS SYSTEM                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚             REACT VITE FRONTEND (Port 3000)              β”‚  β”‚
β”‚  β”‚  9 Dashboard Pages (Overview, Energy, Infrastructure,    β”‚  β”‚
β”‚  β”‚  Bookings, Maintenance, Access, Analytics, DW, Ops)     β”‚  β”‚
β”‚  β”‚  Real-time KPI cards β€’ Interactive charts β€’ Forms        β”‚  β”‚
β”‚  β”‚  28-second auto-refresh via JWT-authenticated API        β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                             ↓ JWT Auth (HS256)                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚            FASTAPI BACKEND (Port 8000)                   β”‚  β”‚
β”‚  β”‚  REST Endpoints β€’ CRUD operations on 12 OLTP tables     β”‚  β”‚
β”‚  β”‚  OLAP warehouse queries (Star + Snowflake)              β”‚  β”‚
β”‚  β”‚  Role-based access control (Admin/Viewer)               β”‚  β”‚
β”‚  β”‚  ETL pipeline trigger endpoint                          β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                             ↓ SQL Server Driver (pyodbc)         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚           SQL SERVER 2022 (OLTP + OLAP)                   β”‚ β”‚
β”‚  β”‚                                                            β”‚ β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚ β”‚
β”‚  β”‚  β”‚    OLTP Database     β”‚  β”‚   OLAP Data Warehouse    β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  (12 BCNF Tables)    β”‚  β”‚   (Star + Snowflake)     β”‚  β”‚ β”‚
β”‚  β”‚  β”‚                      β”‚  β”‚                          β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  Live Transactions:  β”‚  β”‚  Dimension Tables (47):  β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ DEPARTMENT        β”‚  β”‚  β€’ dim_date (365 rows)   β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ BUILDING, FLOOR   β”‚  β”‚  β€’ dim_room (16 rows)    β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ ROOM (16)         β”‚  β”‚  β€’ dim_meter (27 rows)   β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ ENERGY_METER      β”‚  β”‚  β€’ dim_building          β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ ENERGY_READING    β”‚  β”‚  β€’ dim_department        β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ USERS (109)       β”‚  β”‚                          β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ BOOKING (200+)    β”‚  β”‚  Fact Table:             β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ MAINTENANCE       β”‚  β”‚  β€’ fact_energy_consump.  β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ ACCESS_LOG        β”‚  β”‚    (515 rows, 97.7% QA)  β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ AUDIT_TRAIL       β”‚  β”‚                          β”‚  β”‚ β”‚
β”‚  β”‚  β”‚                      β”‚  β”‚  OLAP Operations:        β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  Constraints:        β”‚  β”‚  β€’ Roll-up, Drill-down   β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ 26 Foreign Keys   β”‚  β”‚  β€’ Slice, Dice, Pivot    β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ 5 CHECK           β”‚  β”‚  β€’ GROUP BY ROLLUP       β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ Indexes:          β”‚  β”‚                          β”‚  β”‚ β”‚
β”‚  β”‚  β”‚    (meter_id, ts)    β”‚  β”‚  5 Composite Indexes     β”‚  β”‚ β”‚
β”‚  β”‚  β”‚    (room_id, time)   β”‚  β”‚  Clustered on PKs        β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ 3 Triggers        β”‚  β”‚                          β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ 2 Stored Procs    β”‚  β”‚                          β”‚  β”‚ β”‚
β”‚  β”‚  β”‚                      β”‚  β”‚                          β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  ACID Properties:    β”‚  β”‚                          β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ Isolation Lvls    β”‚  β”‚                          β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ 2PL Locking       β”‚  β”‚                          β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β€’ Deadlock Handling β”‚  β”‚                          β”‚  β”‚ β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚ β”‚
β”‚  β”‚                                                            β”‚ β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚
β”‚  β”‚  β”‚      Python ETL Pipeline (Incremental Load)        β”‚ β”‚ β”‚
β”‚  β”‚  β”‚  β€’ Watermark-based extraction (avoids duplicates)  β”‚ β”‚ β”‚
β”‚  β”‚  β”‚  β€’ IQR outlier detection & cleaning                β”‚ β”‚ β”‚
β”‚  β”‚  β”‚  β€’ Surrogate key mapping (room/meter β†’ dims)      β”‚ β”‚ β”‚
β”‚  β”‚  β”‚  β€’ Bulk append to star schema                      β”‚ β”‚ β”‚
β”‚  β”‚  β”‚  β€’ Audit trail: 9 successful runs (Jan 2025)      β”‚ β”‚ β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ›  Tech Stack

Component Technology Purpose
Frontend React 18 + Vite + Tailwind CSS Real-time dashboard (9 pages, 28-sec refresh)
Backend FastAPI (Python) REST API (port 8000), JWT auth, CRUD endpoints
Database SQL Server 2022 OLTP (12 tables, BCNF) + OLAP (Star/Snowflake)
ETL Python + Pandas + SQLAlchemy Incremental load, IQR cleaning, surrogate mapping
Auth JWT HS256 Role-based access control (Admin/Viewer)
Visualization Recharts, Chart.js KPI cards, area/bar/heatmap/donut charts
Version Control Git + GitHub Repository, CI/CD ready

πŸ“Š Key Metrics & KPIs

KPI Value Source
Total Energy 87.3 MWh SUM(kwh_consumed) from ENERGY_READING
Campus Users 109 COUNT(*) from USERS
Active Rooms 16 COUNT(DISTINCT room_id) from ROOM
Total Bookings 200+ COUNT(*) from BOOKING
Open Tickets 18 COUNT(*) where status='Open'
Access Events 208 COUNT(*) from ACCESS_LOG
Active Equipment 65 Equipment status = 'Active'
Active Meters 27 Energy sensors online
Campus Health Score 82/100 Weighted: 40% Energy, 30% Maintenance, 30% Utilization
Booking Approval Rate 75% Approved / Total
SLA Compliance 20% Resolved within window / Total
Data Quality 97.7% Rows passing IQR filter / Total
ETL Success Rate 89% 8 of 9 runs successful

πŸŽ“ Learning Outcomes Demonstrated

βœ… Unit I: ER Modeling & Normalization

  • Entity classification (strong, weak, subtype, associative)
  • All cardinality types (1:1, 1:N, M:N)
  • Identifying vs non-identifying relationships
  • Functional dependencies documented
  • BCNF compliance proof across all 12 OLTP tables

βœ… Unit II: SQL & Advanced Queries

  • DDL (CREATE TABLE with constraints, ALTER TABLE)
  • DML (INSERT, UPDATE, DELETE via stored procedures)
  • Complex SELECT with JOINs, window functions (LAG), aggregations
  • Stored procedures for business logic (usp_AddBooking, usp_UpdateBookingStatus)
  • Triggers for audit trail and anomaly prevention
  • Indexes for query optimization

βœ… Unit III: Transaction Management & Concurrency

  • ACID properties demonstrated with live SQL Server demos
  • Isolation levels: READ COMMITTED blocking scenario
  • Deadlock construction and victim selection
  • Two-Phase Locking (2PL) with HOLDLOCK/UPDLOCK hints
  • Transaction log and durability verification

βœ… Unit IV: Data Warehousing & ETL

  • Star Schema design (1 fact + 4 dimensions)
  • Snowflake extension (normalized building & department sub-dims)
  • OLAP operations (Roll-up, Drill-down, Slice, Dice, Pivot)
  • Incremental ETL pipeline with watermark
  • Data quality enforcement (IQR outlier detection)
  • Surrogate key mapping and bulk load

πŸš€ Quick Start

Prerequisites

  • SQL Server 2022 (or Express Edition β€” FREE)
  • Python 3.10+
  • Node.js 18+
  • Git

Step 1: Clone Repository

git clone https://github.com/Rakhal06/DBMS_SMART_CAMPUS_ANALYTICS_SYSTEM.git
cd DBMS_SMART_CAMPUS_ANALYTICS_SYSTEM

Step 2: Set Up Database

# Open SQL Server Management Studio (SSMS)
CREATE DATABASE SmartCampusDB;
USE SmartCampusDB;
GO

# Execute database schema scripts
-- Run: database/DBMS.sql (12 OLTP tables)
-- Run: database/OLAP_warehouse.sql (6 warehouse tables)
-- Run: database/seed_data.sql (1000+ sample rows)

Step 3: Set Up Backend

cd backend
python -m venv venv
source venv/bin/activate  # macOS/Linux: or venv\Scripts\activate on Windows
pip install -r requirements.txt

# Configure .env
SQLSERVER_SERVER=localhost\SQLEXPRESS
SQLSERVER_DATABASE=SmartCampusDB
SQLSERVER_USER=sa
SQLSERVER_PASSWORD=YourPassword
JWT_SECRET_KEY=your_secret_key

python main.py
# Backend on http://localhost:8000

Step 4: Set Up Frontend

cd ../frontend
npm install
npm run dev
# Frontend on http://localhost:5173

Step 5: Login

  • Demo Credentials:
    • Username: rakhal | Password: password123
    • Or: student1 | password123

πŸ† Recruiter Highlights

What This Project Demonstrates

1. Production-Ready Database Design

  • 12 normalized OLTP tables (BCNF compliance)
  • Zero anomalies (insertion, update, deletion)
  • Scalable to thousands of records

2. Advanced SQL Expertise

  • Window functions (LAG for anomaly detection)
  • PIVOT cross-tabulation
  • Composite indexes for performance
  • Stored procedures with transaction control

3. Full-Stack Architecture

  • Separation of concerns (Frontend / Backend / Database)
  • REST API with JWT authentication
  • Role-based access control
  • CORS-enabled cross-origin requests

4. Data Warehouse Mastery

  • Star + Snowflake schema design
  • Incremental ETL with data quality
  • OLAP operations on real data
  • 515+ fact rows, 97.7% data quality

5. Real-Time Dashboarding

  • 9 comprehensive dashboard pages
  • 28-second auto-refresh
  • Interactive charts (Recharts, Chart.js)
  • KPI cards with color-coded status
  • Live data entry with conflict detection

6. System Design & Problem-Solving

  • End-to-end data flow (OLTP β†’ ETL β†’ OLAP β†’ Dashboard)
  • Anomaly detection using IQR statistical method
  • SLA tracking and compliance analysis
  • Security scoring with multi-factor auth

πŸ“ Repository Structure

DBMS_SMART_CAMPUS_ANALYTICS_SYSTEM/
β”œβ”€β”€ README.md                              # This file
β”œβ”€β”€ LICENSE                                # MIT License
β”‚
β”œβ”€β”€ assets/
β”‚   └── images/                            # 18 dashboard screenshots
β”‚       β”œβ”€β”€ hero-banner.png
β”‚       β”œβ”€β”€ overview-dashboard.png
β”‚       β”œβ”€β”€ energy-analysis-dashboard.png
β”‚       β”œβ”€β”€ energy-analysis-building-breakdown.png
β”‚       β”œβ”€β”€ energy-anomaly-detection.png
β”‚       β”œβ”€β”€ infrastructure-campus-buildings.png
β”‚       β”œβ”€β”€ equipment-iot-network-summary.png
β”‚       β”œβ”€β”€ room-bookings-dashboard.png
β”‚       β”œβ”€β”€ room-booking-registry.png
β”‚       β”œβ”€β”€ maintenance-dashboard-overview.png
β”‚       β”œβ”€β”€ maintenance-ticket-queue-priority.png
β”‚       β”œβ”€β”€ access-security-dashboard.png
β”‚       β”œβ”€β”€ user-analytics-dashboard.png
β”‚       β”œβ”€β”€ etl-pipeline-monitor.png
β”‚       β”œβ”€β”€ star-schema-olap-explorer.png
β”‚       β”œβ”€β”€ oltp-olap-comparison.png
β”‚       └── live-operations-center.png
β”‚
β”œβ”€β”€ database/
β”‚   β”œβ”€β”€ DBMS.sql                           # 12 OLTP tables (BCNF)
β”‚   β”œβ”€β”€ OLAP_warehouse.sql                 # 6 warehouse tables
β”‚   β”œβ”€β”€ seed_data.sql                      # 1000+ sample rows
β”‚   β”œβ”€β”€ transactions_demo.sql              # ACID, deadlock, 2PL demos
β”‚   β”œβ”€β”€ OLAP_queries.sql                   # Roll-up, Drill-down, etc.
β”‚   β”œβ”€β”€ indexes_performance.sql            # Composite indexes
β”‚   └── etl_pipeline.py                    # Python ETL script
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py                            # FastAPI entry point
β”‚   β”œβ”€β”€ requirements.txt                   # Python dependencies
β”‚   β”œβ”€β”€ database.py                        # SQL Server connection
β”‚   β”œβ”€β”€ models.py                          # Pydantic schemas
β”‚   β”œβ”€β”€ auth.py                            # JWT authentication
β”‚   └── routes/
β”‚       β”œβ”€β”€ energy.py
β”‚       β”œβ”€β”€ bookings.py
β”‚       β”œβ”€β”€ maintenance.py
β”‚       β”œβ”€β”€ access.py
β”‚       β”œβ”€β”€ analytics.py
β”‚       └── auth.py
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ vite.config.js
β”‚   β”œβ”€β”€ index.html
β”‚   └── src/
β”‚       β”œβ”€β”€ App.jsx
β”‚       β”œβ”€β”€ api.js
β”‚       β”œβ”€β”€ pages/
β”‚       β”‚   β”œβ”€β”€ Overview.jsx
β”‚       β”‚   β”œβ”€β”€ EnergyAnalysis.jsx
β”‚       β”‚   β”œβ”€β”€ Infrastructure.jsx
β”‚       β”‚   β”œβ”€β”€ RoomBookings.jsx
β”‚       β”‚   β”œβ”€β”€ Maintenance.jsx
β”‚       β”‚   β”œβ”€β”€ AccessSecurity.jsx
β”‚       β”‚   β”œβ”€β”€ UserAnalytics.jsx
β”‚       β”‚   β”œβ”€β”€ DataWarehouse.jsx
β”‚       β”‚   └── LiveOperations.jsx
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ KPICard.jsx
β”‚       β”‚   β”œβ”€β”€ Chart.jsx
β”‚       β”‚   └── Table.jsx
β”‚       └── index.css
β”‚
└── docs/
    β”œβ”€β”€ ARCHITECTURE.md
    β”œβ”€β”€ DATABASE_DESIGN.md
    └── INSTALLATION_GUIDE.md

πŸ”— Key Links & Resources


πŸ“ž Support & Contact

For questions about the project:


πŸ“œ License

This project is licensed under the MIT License β€” see LICENSE file for details.


Acknowledgments

  • Microsoft SQL Server: Database platform
  • FastAPI & React: Open-source frameworks
  • Python Community: pandas, SQLAlchemy, pyodbc libraries

Made with ❀️ for Database Excellence

⭐ If you found this project helpful, please consider starring the repository!

View on GitHub β€’ Report Issue β€’ Contact Me

Last Updated: January 2025 | Version: 1.0.0 | Status: Production Ready βœ…

About

Smart Campus Resource & Energy Analytics System built with SQL Server, FastAPI, React, and ETL pipelines. Features OLTP & OLAP architecture, analytics dashboards, resource management, energy monitoring, reporting, and data warehousing.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages