Skip to content

Latest commit

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Student Database Viewer

JavaSpring BootSpring SecuritySpring Data JPAHibernateMySQLMavenTomcatThymeleafHTML5CSS3BootstrapJavaScriptJUnitLombok

Table of Contents

Java-based Web Applications

The repository contains the results of the Laboratory Trainings for the course "Java-based Web Applications" (2024) during studies at National Technical University "Kharkiv Polytechnic Institute".

The course provides knowledge to create, debug, and deploy web applications in Java, including Servlets, JSP, JSTL, Hibernate, Spring, authentication, session management, working with cookies, and sending emails through mail services; practice building and deploying web projects with client-server databases.

"Student Database Viewer" App

Overview: Student Admission and Management System

The system manages data for university applicants (entrants/abiturients) and students, with role-based access control to ensure secure CRUD operations on related entities.

The application uses a multi-layered architecture to handle user registration, login, data viewing/editing, and session timeouts. It interacts with a MySQL database and employs Thymeleaf for dynamic HTML rendering.

Project Structure

The project is structured as a series of incremental laboratory works (labs), each building on the previous one, to demonstrate progressive web development skills.

Lab TrainingTopicReportScore
Lab 1Exploring the Java technology stack for creating and deploying web applications using servlets and JSPlab1-report.pdf100
Lab 2Study of the principles of using Hibernate, JPA and HQL to access data in web applicationslab2-report.pdf100
Lab 3Study of the principles of creating complex projects using Spring Boot, Spring Data, Thymeleaflab3-report.pdf100
Lab 4Study of the principles of using Spring Security to implement authentication, authorization and session supportlab4-report.pdf100
Lab 5Study of Java components for organizing email distribution100

Features

  1. User Authentication & Registration: Secure login form with password hashing (BCrypt). Admin-only user creation; self-registration assigns "STUDENT_VIEWER" role.
  2. Role-Based Authorization:
    • ADMIN: Full CRUD on all entities (users, entrants, students).
    • ENTRANT_MANAGER: Full CRUD on entrants; read-only on students.
    • STUDENT_MANAGER: Full CRUD on students; read-only on entrants.
    • ENTRANT_VIEWER: Read-only on entrants.
    • STUDENT_VIEWER: Read-only on students.
  3. Email notification: Automatic sending of an email with a link to reset the password to newly created users by the administrator. Sending an email to reset the password at the user's request.
  4. CRUD Operations: Create, read, update, delete for entrants, students, and users (with foreign key constraints).
  5. Data Management: Filtering, sorting, searching, and pagination for entity tables.
  6. Session Handling: Display logged-in user name/role; automatic logout after inactivity.
  7. Validation: Custom validators for fields (e.g., IDs, birthdays, usernames, emails).
  8. Frontend: Responsive UI with Bootstrap; Thymeleaf templates for dynamic content.
  9. Database Integration: MySQL schema with tables for entrants, students, and users (one-to-one relationship between entrants and students).
  10. Testing: JUnit tests for services and application functionality.
  11. Logging: Configured via Logback.

Technologies Used

Stack

  • Backend: Java 17, Spring Boot 3.x, Spring Security, Spring Data JPA, Hibernate ORM.
  • Database: MySQL 8.0.30.
  • Frontend: Thymeleaf, HTML5, CSS (Bootstrap 5.3), JavaScript.
  • Build Tool: Maven (pom.xml with dependencies like Lombok, JUnit, etc.).
  • Other: Lombok for boilerplate reduction, Custom annotations for validation.

Key technologies:

  • Java for core development.
  • Servlets, JSP for initial web pages and dynamic content.
  • Hibernate for object-relational mapping (ORM) and database interactions.
  • Spring Boot for application framework, including dependency injection, MVC architecture, and RESTful services.
  • Spring Data JPA for repository management.
  • Spring Security for authentication, authorization, and session management.
  • MySQL as the relational database.
  • Maven for build automation.
  • Tomcat as the web/application server.
  • Thymeleaf / HTML, CSS, Bootstrap 5.3, JavaScript for frontend templating (replacing plain JSP in later stages).
  • JUnit for unit testing CRUD operations.

Project Structure

The project follows a multi-layered architecture:

  1. Configuration
  2. Controller
  3. Model
  4. Repository
  5. Service
  6. Validation
  7. View and resources

The project architecture is shown below. Project architecture 1Project architecture 2project architecture 3

Database diagram

Database diagram

Tables:

  • entrants: stores applicant data; Entrants Table
  • students: additional student info; Students Table
  • users: user accounts. Users Table

Setup and Installation

Prerequisites

  • Java 17+ JDK
  • Maven 3.x
  • MySQL 8.0+ (create a database named as per application.properties)
  • IntelliJ IDEA or Eclipse (recommended for development)

Steps

  1. Clone the repository:
    git clone https://github.com/yourusername/WebAppsRIVLab4.git cd WebAppsRIVLab4
    
  2. Configure the database:
    • Update application.properties with your MySQL credentials (e.g., username, password, URL).
    • Run the application to auto-generate tables via Hibernate (or import schema manually).
  3. Build the project:
    mvn clean install
    
  4. Run the application:
    mvn spring-boot:run
    

Testing

  • Run unit tests:
    mvn test
    
  • Covers CRUD operations for services.

The structure of the test sets is shown below. EntrantServiceTestStudentServiceTestUserServiceTest

Fake data

User data

Here is the fake user data for demo.

RoleUsernamePasswordEmail
ADMINshavlii_oleksiiPassword123!$shavlii.oleksii@ntu.khpi.edu.ua
ENTRANT_MANAGERburulka-liudmylaPassword123!$burulka.liudmyla@ntu.khpi.edu.ua
STUDENT_MANAGERvoloshkov-tymurPassword123!$voloshkov.tymur@ntu.khpi.edu.ua
ENTRANT_VIEWERkulish.volodymyrPassword123!$kulish.volodymyr@cs.khpi.edu.ua
STUDENT_VIEWERstepova.alinaPassword123!$stepova.alina@cs.khpi.edu.ua

Ethereal credentials

Ethereal credentials for viewing sent emails:

  • login:
    wilmer.ankunding@ethereal.email
    
  • password:
    GVDW5ZTPSSXuAnRh1y
    

Usage

  1. Login/Register:
    • Visit /login for authentication.
    • Admins can add users at /users/add.
    • Self-register at /register (assigns STUDENT_VIEWER role).
  2. Home Page: Redirects based on role; displays navigation menu.
  3. Entity Management:
    • /entrants: View/edit applicants (access varies by role).
    • /students: View/edit students.
    • /users: Manage users (ADMIN only).
  4. Search/Filter/Sort: Available on table views (e.g., search by name, filter by role).
  5. Logout: Automatic after inactivity (configurable in SecurityConfig).

Screenshots of results are below, showing interfaces for different roles.

Web Application Results

1 Registering a New User and Displaying Available Functionality for a Student Viewer

  1. Registration Page with Entered Credentials for a New User Figure 1.1 - Registration Page with Entered Credentials for a New User
  2. Authentication Page with a Message About Successful Registration of a New User Figure 1.2 - Authentication Page with a Message About Successful Registration of a New User
  3. Authentication Page with Entered Credentials of a Registered User Figure 1.3 - Authentication Page with Entered Credentials of a Registered User
  4. Home Page of the Web Application for a Registered Student Viewer Figure 1.4 - Home Page of the Web Application for a Registered Student Viewer
  5. Profile Page of a Registered User with the Student Viewer Role Figure 1.5 - Profile Page of a Registered User with the Student Viewer Role
  6. User Credentials Change Page Figure 1.6 - User Credentials Change Page
  7. User Credentials Change Page with a Message About Successful Update Figure 1.7 - User Credentials Change Page with a Message About Successful Update
  8. Re-authentication Page After Data Change with Updated Credentials for a Student Viewer Figure 1.8 - Re-authentication Page After Data Change with Updated Credentials for a Student Viewer
  9. Home Page for a User with Updated Credentials and the Student Viewer Role Figure 1.9 - Home Page for a User with Updated Credentials and the Student Viewer Role
  10. Students Table Page for a Student Viewer Figure 1.10 - Students Table Page for a Student Viewer

2 Available Functionality for an Entrant Viewer

  1. Authentication Page with Credentials of an Entrant Viewer Figure 2.1 - Authentication Page with Credentials of an Entrant Viewer
  2. Home Page of the Web Application for an Entrant Viewer Figure 2.2 - Home Page of the Web Application for an Entrant Viewer
  3. Profile Page of an Entrant Viewer Figure 2.3 - Profile Page of an Entrant Viewer
  4. Entrants Table Page for an Entrant Viewer Figure 2.4 - Entrants Table Page for an Entrant Viewer

3 Available Functionality for an Entrant Manager

  1. Authentication Page with Credentials of an Entrant Manager Figure 3.1 - Authentication Page with Credentials of an Entrant Manager
  2. Home Page of the Web Application for an Entrant Manager Figure 3.2 - Home Page of the Web Application for an Entrant Manager
  3. Profile Page of an Entrant Manager Figure 3.3 - Profile Page of an Entrant Manager
  4. Entrants Table Page for an Entrant Manager Figure 3.4 - Entrants Table Page for an Entrant Manager
  5. Entrant Editing Page by an Entrant Manager Figure 3.5 - Entrant Editing Page by an Entrant Manager
  6. Students Table Page for an Entrant Manager Figure 3.6 - Students Table Page for an Entrant Manager

4 Available Functionality for a Student Manager

  1. Authentication Page with Credentials of a Student Manager Figure 4.1 - Authentication Page with Credentials of a Student Manager
  2. Home Page of the Web Application for a Student Manager Figure 4.2 - Home Page of the Web Application for a Student Manager
  3. Profile Page of a Student Manager Figure 4.3 - Profile Page of a Student Manager
  4. Entrants Table Page for a Student Manager Figure 4.4 - Entrants Table Page for a Student Manager
  5. Students Table Page for a Student Manager Figure 4.5 - Students Table Page for a Student Manager
  6. Student Editing Page by a Student Manager Figure 4.6 - Student Editing Page by a Student Manager

5 Available Functionality for a Administrator

  1. Authentication Page with Administrator Credentials Figure 5.1 - Authentication Page with Administrator Credentials
  2. Home Page of the Web Application for an Administrator Figure 5.2 - Home Page of the Web Application for an Administrator
  3. Profile Page of an Administrator Figure 5.3 - Profile Page of an Administrator
  4. Page for Creating a New User by an Administrator Figure 5.4 - Page for Creating a New User by an Administrator
  5. User Editing Page by an Administrator with a Message About Successful Creation of a New User Figure 5.5 - User Editing Page by an Administrator with a Message About Successful Creation of a New User
  6. User Editing Page by an Administrator with a Message About Successful Update of Existing User Data Figure 5.6 - User Editing Page by an Administrator with a Message About Successful Update of Existing User Data
  7. Users Table Page for an Administrator Figure 5.7 - Users Table Page for an Administrator
  8. User Deletion Page by an Administrator with a Confirmation Prompt Figure 5.8 - User Deletion Page by an Administrator with a Confirmation Prompt
  9. Users Table Page for an Administrator with a Message About User Deletion Figure 5.9 - Users Table Page for an Administrator with a Message About User Deletion
  10. Users Table Page for an Administrator with Applied Search, Filtering, and Sorting Figure 5.10 - Users Table Page for an Administrator with Applied Search, Filtering, and Sorting

© Inessa Repeshko. 2024

About

The "Student Database Viewer" is a Java-based web application designed to manage and display data for university entrants and students, providing role-based access control for secure CRUD operations.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages