Campus Event Management System in JAVA

 Campus Event Management System

#java #event #fyp #project #source #code #learn #free

1. Introduction

  • Problem Statement: Managing campus events manually can be chaotic and time-consuming. The need for a streamlined digital platform is essential for enhancing user experience and improving event management efficiency.
  • Objective: To create a Java-based Campus Event Management System that allows users to create, manage, and register for campus events seamlessly.
  • Scope: The system will have modules for user registration, event creation, event registration, notifications, and administrative management.

2. Features

  • User Management: Registration, login, and profile management for students and organizers.
  • Event Management: Create, update, delete, and view events.
  • Registration System: Students can register for events, view the status of their registration, and receive notifications.
  • Notification System: Send email or SMS notifications for event updates, cancellations, and reminders.
  • Feedback System: Post-event feedback collection and analysis.

3. System Requirements

  • Software Requirements:
    • JDK 8 or later
    • IDE: Eclipse/IntelliJ IDEA
    • Database: MySQL or PostgreSQL
    • Apache Tomcat for web-based deployment
  • Hardware Requirements:
    • RAM: 4GB minimum
    • Processor: Dual Core Processor or higher
    • Disk Space: 200MB for software and dependencies

4. System Design

  • Architecture: MVC (Model-View-Controller) architecture will be used for the web-based version of the application.
  • UML Diagrams:
    • Use Case Diagram: Illustrates the interaction between users (students, organizers, and admin) and the system.
    • Class Diagram: Shows the classes involved and their relationships.
    • Sequence Diagram: Represents the flow of actions for key functionalities like event registration and notification.
  • Database Design:
    • Tables for Users, Events, Registrations, Notifications, and Feedback.


Project Structure:

  1. Backend (Spring Boot Application)

    • Models
    • Repositories
    • Services
    • Controllers
    • Configuration
  2. Frontend (JavaFX Application)

    • UI Layouts
    • Controllers
    • Utils

1. Backend: Spring Boot Application

Step 1: Create a Spring Boot Project

Use Spring Initializr to generate a new Spring Boot project with the following dependencies:

  • Spring Web
  • Spring Data JPA
  • MySQL Driver
  • Lombok

Step 2: Create Models


user.java


package com.campus.eventmanagement.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;

@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String username;
    private String password;
    private String email;
    private String role;  // "STUDENT", "ORGANIZER", "ADMIN"
}


event.java


package com.campus.eventmanagement.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Date;

@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Event {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long eventId;

    private String eventName;
    private String location;

    @Temporal(TemporalType.DATE)
    private Date eventDate;

    private String organizer;
    private String description;
}


UserRepository.java


package com.campus.eventmanagement.repository;

import com.campus.eventmanagement.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface UserRepository extends JpaRepository<User, Long> {
    User findByUsername(String username);
}



EventRepository.java


package com.campus.eventmanagement.repository;

import com.campus.eventmanagement.model.Event;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface EventRepository extends JpaRepository<Event, Long> {
    // Custom query methods (if needed)
}


UserService.java


package com.campus.eventmanagement.service;

import com.campus.eventmanagement.model.User;
import com.campus.eventmanagement.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserRepository userRepository;

    public User registerUser(User user) {
        return userRepository.save(user);
    }

    public User getUserByUsername(String username) {
        return userRepository.findByUsername(username);
    }

    public List<User> getAllUsers() {
        return userRepository.findAll();
    }
}


EventService.java


package com.campus.eventmanagement.service;

import com.campus.eventmanagement.model.Event;
import com.campus.eventmanagement.repository.EventRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EventService {
    @Autowired
    private EventRepository eventRepository;

    public Event createEvent(Event event) {
        return eventRepository.save(event);
    }

    public List<Event> getAllEvents() {
        return eventRepository.findAll();
    }

    public void deleteEvent(Long eventId) {
        eventRepository.deleteById(eventId);
    }
}


UserController.java

package com.campus.eventmanagement.controller;

import com.campus.eventmanagement.model.User;
import com.campus.eventmanagement.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/users")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/register")
    public User registerUser(@RequestBody User user) {
        return userService.registerUser(user);
    }

    @GetMapping("/{username}")
    public User getUserByUsername(@PathVariable String username) {
        return userService.getUserByUsername(username);
    }

    @GetMapping("/all")
    public List<User> getAllUsers() {
        return userService.getAllUsers();
    }
}


EventController.java


package com.campus.eventmanagement.controller;

import com.campus.eventmanagement.model.Event;
import com.campus.eventmanagement.service.EventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/events")
public class EventController {
    @Autowired
    private EventService eventService;

    @PostMapping("/create")
    public Event createEvent(@RequestBody Event event) {
        return eventService.createEvent(event);
    }

    @GetMapping("/all")
    public List<Event> getAllEvents() {
        return eventService.getAllEvents();
    }

    @DeleteMapping("/{eventId}")
    public void deleteEvent(@PathVariable Long eventId) {
        eventService.deleteEvent(eventId);
    }
}


Database Configuration


spring.datasource.url=jdbc:mysql://localhost:3306/event_management_db
spring.datasource.username=root
spring.datasource.password=yourpassword
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect



2. Frontend: JavaFX Application

Step 1: Create the JavaFX Project Structure

Use an IDE like IntelliJ IDEA or Eclipse with JavaFX support.

Step 2: Design UI using FXML

Create a basic UI for the JavaFX application using FXML files. For simplicity, we'll focus on the main screens.


Main.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane xmlns:fx="http://javafx.com/fxml" fx:controller="com.campus.eventmanagement.controller.MainController">
    <children>
        <VBox spacing="10">
            <Label text="Campus Event Management System" style="-fx-font-size: 20px;"/>
            <Button text="Register for Event" onAction="#handleRegisterForEvent"/>
            <Button text="View Events" onAction="#handleViewEvents"/>
            <Button text="Create Event" onAction="#handleCreateEvent"/>
        </VBox>
    </children>
</AnchorPane>


MainController.java

package com.campus.eventmanagement.controller;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;

public class MainController {

    @FXML
    private void handleRegisterForEvent(ActionEvent event) {
        // Implementation of registering for an event
        showInfoAlert("Feature Coming Soon!");
    }

    @FXML
    private void handleViewEvents(ActionEvent event) {
        // Implementation of viewing events
        showInfoAlert("Feature Coming Soon!");
    }

    @FXML
    private void handleCreateEvent(ActionEvent event) {
        // Implementation of creating an event
        showInfoAlert("Feature Coming Soon!");
    }

    private void showInfoAlert(String message) {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Information");
        alert.setHeaderText(null);
        alert.setContentText(message);
        alert.showAndWait();
    }
}

MainApp.java
package com.campus.eventmanagement;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class MainApp extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("/Main.fxml"));
        primaryStage.setTitle("Campus Event Management System");
        primaryStage.setScene(new Scene(root));
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Step 5: Build and Run

  • Make sure your JavaFX libraries are properly set up in your IDE.
  • Run the Spring Boot backend by executing MainApp.java to start the JavaFX UI.

Summary

This code provides a comprehensive backend using Spring Boot and a basic frontend using JavaFX. The backend includes CRUD operations for users and events, while the frontend includes basic JavaFX layout and event handlers. 

Project: Smart Home Automation System

Project Title: Smart Home Automation System

Project Description:

The Smart Home Automation System is an advanced Java project designed to simulate and manage a smart home environment. This project integrates various components of object-oriented programming (OOP) concepts, multi-threading, networking, database management, GUI development, design patterns, and more. The system enables users to control and monitor home appliances, manage security systems, and optimize energy consumption through a centralized Java-based application.

Key Features:

  • User Authentication: Secure login and registration system with role-based access control.
  • Device Management: Add, remove, and control various smart devices like lights, fans, thermostats, and security cameras.
  • Real-Time Monitoring: Live data streaming from sensors (temperature, motion, etc.) with instant alerts for anomalies.
  • Energy Management: Track and optimize energy consumption with intelligent suggestions and automation rules.
  • Scheduling and Automation: Create schedules for device operations and automate repetitive tasks using a rules engine.
  • Remote Access: Control and monitor the smart home from anywhere via a networked application or web interface.
  • Database Integration: Store user data, device states, logs, and energy usage metrics using an SQL or NoSQL database.
  • Multithreading: Efficient handling of multiple device operations simultaneously using Java's multithreading capabilities.
  • Design Patterns: Implement design patterns such as Singleton, Factory, Observer, and MVC to structure the project effectively.
  • GUI Development: Build an intuitive user interface using JavaFX or Swing, featuring real-time data visualization and control panels.
  • Networking: Establish communication between devices using sockets, and manage remote connections via REST APIs or WebSockets.
  • Security: Encrypt sensitive data and use secure protocols for communication to protect user privacy and system integrity.
  • Logging and Debugging: Implement logging mechanisms to monitor system activities and troubleshoot issues effectively.

Technologies Used:

  • Java SE 11+
  • JavaFX or Swing
  • MySQL / MongoDB
  • Multithreading and Concurrency
  • Socket Programming
  • REST API / WebSocket
  • Design Patterns (Singleton, Factory, Observer, MVC)
  • Encryption and Security Protocols

#JavaProject #SmartHomeAutomation #ObjectOrientedProgramming #Multithreading #JavaFX #Swing #Networking  #DatabaseManagement #DesignPatterns #HomeSecuritySystem #EnergyManagement #IoT #RealTimeMonitoring #JavaCoding #AdvancedJava #JavaSE #JavaDevelopment #JavaGUI #RESTAPI #WebSocket

Here is a comprehensive implementation of a Smart Home Automation System in Java, covering various advanced concepts like multithreading, OOP, GUI, database management, and networking.

Requirements:

  • Java SE 11 or later
  • JavaFX SDK (for GUI)
  • MySQL or MongoDB (for database)
  • Maven (for dependency management)
  • IntelliJ IDEA / Eclipse (for development)
  • JDBC Driver (for MySQL, if using MySQL)

Project Structure:

  1. Model Layer: Contains classes for devices, users, and other entities.
  2. Controller Layer: Manages the system's logic.
  3. View Layer: Handles GUI interactions.
  4. Database Layer: Manages database operations.
  5. Networking Layer: Manages communication between devices and clients.

1. Model Layer: Device, User, and Sensor Classes


package com.smarthome.model; public abstract class Device { private String id; private String name; private boolean status; public Device(String id, String name) { this.id = id; this.name = name; this.status = false; } public String getId() { return id; } public String getName() { return name; } public boolean isStatus() { return status; } public void setStatus(boolean status) { this.status = status; } public abstract void operate(); } class Light extends Device { public Light(String id, String name) { super(id, name); } @Override public void operate() { setStatus(!isStatus()); System.out.println(getName() + " turned " + (isStatus() ? "ON" : "OFF")); } } class Thermostat extends Device { private double temperature; public Thermostat(String id, String name) { super(id, name); this.temperature = 22.0; } public double getTemperature() { return temperature; } public void setTemperature(double temperature) { this.temperature = temperature; System.out.println(getName() + " set to " + temperature + "°C"); } @Override public void operate() { // Custom operation for Thermostat } } class User { private String username; private String password; private String role; public User(String username, String password, String role) { this.username = username; this.password = password; this.role = role; } public String getUsername() { return username; } public String getPassword() { return password; } public String getRole() { return role; } } class Sensor { private String id; private String type; private double value; public Sensor(String id, String type) { this.id = id; this.type = type; } public String getId() { return id; } public String getType() { return type; } public double getValue() { return value; } public void setValue(double value) { this.value = value; } }

2. Controller Layer: SmartHomeController


package com.smarthome.controller; import com.smarthome.model.Device; import com.smarthome.model.User; import java.util.HashMap; import java.util.Map; public class SmartHomeController { private Map<String, Device> devices; private Map<String, User> users; public SmartHomeController() { devices = new HashMap<>(); users = new HashMap<>(); } public void addDevice(Device device) { devices.put(device.getId(), device); } public void addUser(User user) { users.put(user.getUsername(), user); } public void operateDevice(String deviceId) { Device device = devices.get(deviceId); if (device != null) { device.operate(); } else { System.out.println("Device not found"); } } public User authenticate(String username, String password) { User user = users.get(username); if (user != null && user.getPassword().equals(password)) { return user; } return null; } public void listDevices() { devices.values().forEach(device -> { System.out.println(device.getName() + " is " + (device.isStatus() ? "ON" : "OFF")); }); } }

3. View Layer: JavaFX GUI


package com.smarthome.view; import com.smarthome.controller.SmartHomeController; import com.smarthome.model.Light; import com.smarthome.model.Thermostat; import com.smarthome.model.User; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.layout.GridPane; import javafx.stage.Stage; public class SmartHomeApp extends Application { private SmartHomeController controller; public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { controller = new SmartHomeController(); controller.addUser(new User("admin", "admin123", "admin")); controller.addDevice(new Light("1", "Living Room Light")); controller.addDevice(new Thermostat("2", "Living Room Thermostat")); primaryStage.setTitle("Smart Home Automation System"); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); Label userLabel = new Label("Username:"); TextField userTextField = new TextField(); grid.add(userLabel, 0, 0); grid.add(userTextField, 1, 0); Label passLabel = new Label("Password:"); PasswordField passField = new PasswordField(); grid.add(passLabel, 0, 1); grid.add(passField, 1, 1); Button loginButton = new Button("Login"); grid.add(loginButton, 1, 2); loginButton.setOnAction(e -> { User user = controller.authenticate(userTextField.getText(), passField.getText()); if (user != null) { showDashboard(primaryStage); } else { showAlert("Invalid credentials"); } }); Scene scene = new Scene(grid, 300, 200); primaryStage.setScene(scene); primaryStage.show(); } private void showDashboard(Stage stage) { GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); Label deviceLabel = new Label("Devices:"); grid.add(deviceLabel, 0, 0); ListView<String> deviceList = new ListView<>(); controller.listDevices().forEach(device -> deviceList.getItems().add(device.getName())); grid.add(deviceList, 1, 0); Button operateButton = new Button("Operate"); grid.add(operateButton, 1, 1); operateButton.setOnAction(e -> { String selectedDevice = deviceList.getSelectionModel().getSelectedItem(); controller.operateDevice(selectedDevice); }); Scene dashboardScene = new Scene(grid, 400, 300); stage.setScene(dashboardScene); } private void showAlert(String message) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setContentText(message); alert.showAndWait(); } }

4. Database Layer: Database Connection


package com.smarthome.database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DatabaseConnection {
    private static final String URL = "jdbc:mysql://localhost:3306/smarthome";
    private static final String USER = "root";
    private static final String PASSWORD = "password";

    public static Connection getConnection() throws SQLException {
        return DriverManager.getConnection(URL, USER, PASSWORD);
    }
}

5. Networking Layer: Socket Communication

package com.smarthome.networking;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class SmartHomeServer {
    private ServerSocket serverSocket;

    public SmartHomeServer(int port) throws IOException {
        serverSocket = new ServerSocket(port);
    }

    public void start() {
        while (true) {
            try {
                Socket clientSocket = serverSocket.accept();
                new ClientHandler(clientSocket).start();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static class ClientHandler extends Thread {
        private Socket clientSocket;
        private BufferedReader in;
        private PrintWriter out;

        public ClientHandler(Socket socket) {
            this.clientSocket = socket;
        }

        public void run() {
            try {
                in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                out = new PrintWriter(clientSocket.getOutputStream(), true);

                String inputLine;
                while ((inputLine = in.readLine()) != null) {
                    // Process input and send response
                    out.println("Received: " + inputLine);
                }
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    in.close();
                    out.close();
                    clientSocket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void main(String[] args) {
        try {
            SmartHomeServer server = new SmartHomeServer(8080);
            server.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Setting Up the Project:

  1. Install Java SE 11+: Ensure that you have Java Development Kit (JDK) 11 or later installed.

  2. Set Up JavaFX: Download and configure JavaFX SDK for your IDE (IntelliJ IDEA or Eclipse).

  3. Install MySQL: Install MySQL server and create a database named smarthome. Use the provided DatabaseConnection class for managing connections.

  4. Configure JDBC Driver: Ensure that the MySQL JDBC driver is added to your project’s classpath.

  5. Run the Application:

    • Start the SmartHomeServer to listen for incoming client connections.
    • Run the SmartHomeApp to launch the GUI and start controlling the smart devices.
  6. Maven Dependencies: If using Maven, include the following dependencies in your pom.xml:


<dependencies>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.26</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>16</version>
    </dependency>
</dependencies>


Expanding the Project:

  • Add More Devices: Implement additional device types (e.g., security cameras, smart locks).
  • Enhance Networking: Develop a mobile app or web client to remotely access the smart home system.
  • Improve Security: Implement more sophisticated encryption and user management features.
  • Integrate AI: Incorporate machine learning models to optimize energy usage or predict user behavior.

Featured Post

Day 41 — BGP Confederations: Sub-AS Design, External View and Migration

1. Opening Confederations are another way to scale BGP inside a large administrative domain. They divide the domain into member autonomous systems while presenting a single confederation identifier to external peers. They are powerful, but their operational model is more complex than simply 'using private ASNs inside.' The engineering goal is not to memorize another BGP command. It is to understand what information each speaker is allowed to propagate, what path information can be hidden, and what failure domain is created by the chosen control-plane architecture . 2. Concept and standards behavior RFC 5065 defines AS_CONFED_SEQUENCE and AS_CONFED_SET and how member-AS relationships are represented. Confederation external sessions have eBGP-like properties inside the confederation, while the confederation is presented externally as one AS. Modern guidance must also account for the fact that RFC 9774 prohibits new origination of AS_SET/AS_CONFED_SET in ordinary aggregation c...