This application is a school project for a Java course.
PawsitiveQuotes is a Java Spring Boot application designed to boost employee morale by providing a platform for them to express their concerns and receive inspirational quotes in return. It consists of two main components:
- PawsitiveAPI: A Spring Boot API that provides random inspirational quotes from a database.
- PawsitiveChat: A Spring Boot application with a conversation page and a user/conversation history page.
- Conversation Interface: Users can enter their name and message on a conversation page.
- Inspirational Quotes: An API provides random "quotes inspirantes" from a database, offering motivational support to users.
- Data Persistence: User conversations are saved to a database, including the username, message, quote, and timestamp.
- User and Conversation History: A dedicated page displays a list of users who have posted, along with the ability to view their conversation history.
- API Integration: The main application calls the quote API using RestTemplate.
sequenceDiagram
participant User
participant PawsitiveChat
participant PawsitiveAPI
participant Database
User->>PawsitiveChat: Sends a message
PawsitiveChat->>PawsitiveAPI: Requests a quote
PawsitiveAPI-->>PawsitiveChat: Returns a quote
PawsitiveChat->>Database: Records the conversation
PawsitiveChat-->>User: Displays the response
Follow these steps to set up and run the project:
-
Clone the Repository:
git clone [repository URL] cd PawsitiveQuotes
-
Configure Application Properties:
-
For both the
PawsitiveAPI
andPawsitiveChat
, you will find a file namedapplication.properties.example
. -
Copy this file and rename the copy to
application.properties
in the respective directory (PawsitiveAPI
andPawsitiveChat
). -
Edit each
application.properties
file to configure the database connection and other settings. Here's an example of the contents of theapplication.properties.example
file:spring.application.name=PawsitiveChat spring.jpa.hibernate.ddl-auto=update spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/PawsitiveQuotes spring.datasource.username=root spring.datasource.password=<YOUR_PASSWORD> spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver server.port=8080
- Note: You can use a single database for both the API and the main application by using the same database name (
PawsitiveQuotes
in the example). If you prefer, you can use separate databases by specifying different database names for each application. Make sure to configure thespring.datasource.url
,spring.datasource.username
, andspring.datasource.password
properties accordingly.
- Note: You can use a single database for both the API and the main application by using the same database name (
-
-
Build and Run PawsitiveAPI:
cd PawsitiveAPI mvn clean install mvn spring-boot:run
-
Build and Run PawsitiveChat:
cd ../PawsitiveChat mvn clean install mvn spring-boot:run
-
Access the Application:
- Open your web browser and go to
http://localhost:8080
to access the conversation page. (forPawsitiveChat
) - Open your web browser and go to
http://localhost:8181/api/quote
to access the quote (forPawsitiveAPI
) - Visit
http://localhost:8080/users
to see the list of users and their conversations.
- Open your web browser and go to