A web application that supports authentication, registration, and logic of ordering tickets. booking service based on Hibernate and Spring frameworks using general REST principles.
- register and log in as a user/administrator;
- find movies and cinema halls
- find available movie sessions
- create shopping cart
- add tickets to shopping cart
- view shopping cart
- make an order
- view order history
- create and find movies and cinema halls
- create and find available movie sessions
- find user by email
The project has a Three-Tier Architecture:
Layer | Responsibilities |
---|---|
Presentation layer (Controllers) | Accepts requests from clients and sends results back to them. |
Application logic layer (Service) | Provide logic to operate on the data sent to and from the DAO and the client. |
Data access layer (DAO) | Represents a bridge between the database and the application. |
- Hibernate Core
- Hibernate Validator
- Spring WebMvc
- Spring Context
- Spring Security
- Apache Maven
- MySQL Connector Java
- JWT
- Entities represent columns in the database;
- DTOs represent communication between Presentation and Service layers;
- DTO mappers convert DTOs to entities and vice versa
- BCryptPasswordEncoder is used for password encryption
- Hibernate annotations are used for field validation
- Custom annotations are used for email and password validation
- Jackson API is responsible for converting objects to JSON
- Config package contains classes allow to configure Spring and Hibernate
- Security package contains class, allows to create UserDetails which store user information;
- JWT make this application stateless
- Clone the repo here;
- Install MySQL;
- Use init_db.sql file for creating your local database.
- Open db.properties file and write information about your database.
- db.driver= "YOUR_DRIVER"
- db.url= jdbc:mysql://YOUR_DATABASE_URL/cinema
- db.user= "YOUR_USERNAME"
- db.password= "YOUR_PASSWORD"
- Configure Apache Tomcat version 9.0.50 Artifact: war-exploded artifact, Application context: "/";
- Create connection to DB using Database option (Intellij Idea Ultimate).
- ADMIN: username: [email protected], password: admin123
- USER: username: [email protected], password: user1234
- Use Postman to send some http requests;
- Press debug button.
The application does not have JSP pages, so use Postman to access it. When you start the application, there will already be two users in the database: one with the role of admin and the other with the role of user. You can view their data in the DataInitializer class. When using the program, you can log in using their credentials or register yourself. However, please ensure that your data is valid during the registration process.
Yes, this application follows the REST architectural style, making it stateless. A token will be sent to you upon logging in. Therefore, in the future, you will need to add the token to the 'Authorization-Bearer Token' section in Postman. This token will be included in the header. After that, you can visit and perform actions according to the granted rights (admin or user).
All permissions can be found inside the SecurityConfig class, specifically in the configure method. Additionally, you can find information about the methods (GET, POST, UPDATE, or DELETE) that should be used for each page.