This project is a ticketing system application built with Spring Boot and Redis. It allows users to generate tickets and verify their validity using Redis as the data store.
- Ticket Generation: Users can generate tickets which are stored in Redis.
- Ticket Verification: Ability to check if a ticket is valid by querying Redis.
To get a local copy up and running, follow these simple steps.
Make sure you have the following installed:
- Java Development Kit (JDK)
- Maven
- Git
- Docker (optional, for running Redis)
This class implements ApplicationContextAware from Spring, allowing access to the application context from Spring-unmanaged classes. This is useful for accessing Spring beans from non-Spring managed classes like utilities or configuration classes.
REST controller class that handles requests related to the drawing service. It provides two main endpoints:
/status: Returns the current server status in JSON format, including server date and time./getticket: Returns a generated ticket, usingTicketRepositoryto store and retrieve tickets.
MVC configuration setting up access routes for different views, such as the home page (/index) and login page (/login). This allows controlling navigation flow without additional controllers.
Spring configuration for connecting and setting up Redis as the data store for the application. It uses Lettuce as the Redis client, configuring the connection through properties defined in application.properties.
Component responsible for ticket generation and management using Redis as storage. It uses StringRedisTemplate to interact with Redis and ListOperations to handle a list of tickets stored in Redis. It also implements methods for ticket generation and verification.
Security configuration for the application using Spring Security. Defines authorization rules for different endpoints and configures the custom login form (/login). Additionally, it provides a UserDetailsService defining in-memory users with user and admin roles for authentication.
WebSocket endpoint class handling drawing actions using the WebSocket protocol. Manages open WebSocket sessions, message processing, and error handling.
send(String msg): Method to send a message to all connected WebSocket clients except the sender.processPoint(String message, Session session): Handles incoming messages from WebSocket clients. Verifies and accepts tickets before sending messages.openConnection(Session session): Manages WebSocket connection opening, registering the session in the session queue.closedConnection(Session session): Manages WebSocket connection closure, removing the session from the queue and deleting the associated ticket.error(Session session, Throwable t): Handles WebSocket errors, logging errors and removing the session from the queue.
Configuration class for WebSocket server endpoint and scheduling. Enables exporting of WebSocket server endpoint using ServerEndpointExporter.
serverEndpointExporter(): Bean definition forServerEndpointExporter, enabling registration of WebSocket server endpoint.
Main class of the Spring Boot application. Annotated with @SpringBootApplication, it indicates the main entry point for the Spring Boot application.
main(String[] args): Main method starting the Spring Boot application.
Function that checks and resumes the audio context if suspended.
Function that calculates and returns the WebSocket service URL (wss://) based on the current host.
Function that calculates and returns the REST service URL for obtaining tickets based on the current host.
Function that calculates and returns the base URL (ws://) for the current host.
Function that calculates and returns the base URL (http:// or https://) for the current host.
JavaScript class handling WebSocket connection logic, including connection opening, message reception, and error handling.
React component representing the drawing canvas, using the p5.js library to render and send drawing points to the WebSocket server.
Main React component displaying the drawing canvas (BBCanvas) and other UI elements.
Clone the repository:
git clone https://github.com/JohannBulls/REDISWebServicesdocker run --name some-redis -p 45000:6379 -d rediscd REDISWebServices
mvn spring-boot:runNow open a browser and go to the following link to login: Login page
After logging in you access the board to start drawing Execution
You can also open a browser and go to the following link to access the project on AWS:
The application will be accessible at:
https://localhost:8444
-
Access the status endpoint to check server status:
GET https://localhost:8444/status -
Generate a new ticket:
GET https://localhost:8444/getticket
- DrawingServiceController.java: REST controller for handling status and ticket generation.
- MvcConfig.java: Configuration for MVC views.
- WebSecurityConfig.java: Configuration for Spring Security.
- RedisConfig.java: Configuration for Redis connection.
- TicketRepository.java: Repository handling ticket generation and verification using Redis.
- Spring Boot - Backend framework
- Redis - In-memory data store
- Maven - Dependency management
- Johann Amaya Lopez - @JohannBulls
This project is licensed under the GNU License - see the LICENSE.txt file for details.


