UniversityCms is a comprehensive MVC project designed for managing university courses, students, groups, schedules and staff. Built using Spring Boot, it leverages a range of technologies to provide a robust and secure platform. The application is containerized using Docker and can be easily deployed using Docker Compose.
- Spring Boot
- Spring Web
- Spring Data JPA
- Spring Security
- Thymeleaf
- Bootstrap
- Flyway
- PostgreSQL
- Validation
- Lombok
- TestContainers
- Logback
- Docker
- Welcome Page: Publicly accessible, providing an overview of the institution and necessary navigation links.
- Authentication and Authorization:
- Authenticated users can access specific sections like groups and courses ect.
- Main page is accessible to all users.
- Admin panel is restricted to administrators ("admin"), allowing them to delete groups, courses, and other entities. Also allows them to change roles to users.
- Users with "staff" and "admin" roles can perform edit operations, while regular users have read-only access.
- Group Management: View groups, brief descriptions, and lists of students. Links to student profiles.
- Course Management: View courses, descriptions, and instructor details. Links to instructor profiles.
- Professor Management: View teachers and the courses they teach. Links to course pages.
- Student Management: Student profiles show their groups and courses. Links to their group and course pages.
- Schedule Management: Displays course schedules with start and end times, group, course, and instructor details.
- CRUD Operations: Role-dependent CRUD operations.
- User Profiles: Users can view and edit their profile information.
- Pagination, Sorting, and Search: Implemented across various sections for efficient data management.
- Security: Basic Authentication. Passwords are encrypted using BCrypt.
- Docker installed on your machine.
-
Clone the repository:
git clone https://github.com/avecoss/university-cms.git cd university-cms -
Build and run the services using Docker Compose:
docker-compose up --build
-
Access the application:
- UniversityCms: http://localhost:8080
- Adminer: http://localhost:8090
ADMIN role
ADMIN role
STAFF role
ADMIN role
STAFF role
USER role
The application uses Docker for containerization. The docker-compose.yml file defines the setup:
- cms_service: The main application service.
- db_pg: The PostgreSQL database service.
- adminer: A database management tool.
name: u-cms
services:
cms_service:
image: university-cms:lasted
build:
context: ./UniversityCms
dockerfile: Dockerfile
restart: always
ports:
- "8080:8080"
depends_on:
- db_pg
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://db_pg:5432/university_database
container_name: "university-cms"
db_pg:
image: postgres:16-alpine
restart: always
environment:
POSTGRES_DB: university_database
POSTGRES_USER: your_username
POSTGRES_PASSWORD: your_password
ports:
- "5433:5432"
container_name: "db-pg"
adminer:
image: adminer
restart: always
ports:
- "8090:8080"
container_name: "adminer"The Dockerfile is used to build the Docker image:
# Stage 1: Build the application
FROM maven:3.9.4-eclipse-temurin-21-alpine AS build
# Copy the source files and the pom.xml file into the container
COPY src src
COPY pom.xml pom.xml
# Execute the Maven build command without running tests
RUN mvn clean package -DskipTests
# Stage 2: Creating the final image
FROM openjdk:21-ea-31-slim
# Define the JAR_FILE argument that will be used to copy the file
ARG JAR_FILE=target/university-cms*.jar
# Set the working directory
WORKDIR /app
# Open port 8080 for the application
EXPOSE 8080
# Copy the assembled JAR file from the previous step
COPY --from=build ${JAR_FILE} app.jar
# Define the application launch command
ENTRYPOINT ["java", "-jar", "app.jar"]Update the application.yml file with your PostgreSQL credentials and other configurations as needed.
spring:
application:
name: UniversityCms
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5433/university_database
username: your_username
password: your_password
flyway:
locations: db/migration
baselineOnMigrate: true
baselineVersion: 1
baselineDescription: Base migration
schemas:
- public
- university
jpa:
show-sql: true
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
jdbc:
batch_size: 10
order_updates: true
order_inserts: trueSecurity Configuration: The SecurityConfig class configures Spring Security for role-based access control.
@Configuration
@EnableWebSecurity
@EnableMethodSecurity
@RequiredArgsConstructor
public class SecurityConfig {
private final PersonDetailsService personDetailsService;
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http
.authorizeHttpRequests(authorize ->
authorize
.requestMatchers("/webjars/**", "/css/**", "/icons/**", "/img/**").permitAll()
.requestMatchers("/login", "/error", "/registration", "/home", "/courses").permitAll()
.requestMatchers(RegexRequestMatcher.regexMatcher("/courses/\\d+")).permitAll()
.requestMatchers("/admin/**").hasRole("ADMIN")
.anyRequest().authenticated())
.formLogin(login ->
login
.loginPage("/login")
.defaultSuccessUrl("/home", true)
.failureUrl("/login?error"))
.logout(logout ->
logout
.logoutSuccessUrl("/login?logout")
.deleteCookies("JSESSIONID")
.logoutSuccessHandler(logout.getLogoutSuccessHandler()))
.build();
}
@Bean
public AuthenticationProvider authenticationProvider() {
DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
authProvider.setUserDetailsService(personDetailsService);
authProvider.setPasswordEncoder(passwordEncoder());
return authProvider;
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}