This project aims to create a chatroom API which allows users to freely join and send messages into chatrooms with other users.
The Room Raiders Chatroom API can:
create / deletenew userscreate / deletenew chatroomssend messagesto chatrooms
Additional API functionality includes:
- enabling users to
post / retrieve imagesto / from thechatroom database adding / removing users from specific chatroomsupdating user information(nameandemail)updating chatroom information( chatroomname)
Our project utilises the following:
- Spring Boot
version: 3.0.6 - Maven
- Packaging:
Jar - Java
version: 17 - Dependencies:
Lombok,Spring Data JPA,Spring Web,Spring Boot DevTools,PostgreSQL Driver IntelliJ IDEA JDK 17,PostgreSQL,Postico&Postmanto help create and visualise our code
-
Create a local database for the chatroom called
chatroom_db. In the terminal run:createdb chatroom_db -
In
resources.application.properties, copy the following code :
spring.datasource.url=jdbc:postgresql://localhost:5432/chatroom_db
spring.datasource.username=
spring.datasource.password=
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
- After running the application, you should be able to view the seeded user, chatroom, and message information from the
DataLoaderin Postman and Postico.
| Route Name | Request Type | RequestBody | Request Path |
|---|---|---|---|
displayAllUsers |
GET | null | /users |
displayUserById |
GET | null | /users/{userId} |
editUser |
GET | null | /users/{userId}/edit |
updateUser |
PUT | UserDTO userDTO (name & email) |
/users/{userId} |
createUser |
POST | User user (name & email) |
/users |
deleteUser |
DELETE | null | /users/{id} |
displayChatroomsByUser |
GET | null | /users/{userId}/chatrooms |
| Route Name | Request Type | RequestBody | Request Path |
|---|---|---|---|
displayAllChatrooms |
GET | null | /chatrooms |
displayChatroomById |
GET | null | /chatrooms/{chatroomId} |
editChatroomName |
GET | null | /chatrooms/{chatroomId}/edit |
updateChatroomName |
PUT | ChatroomDTO chatroomDTO (name) |
/chatrooms/{chatroomId} |
createChatroom |
POST | Chatroom chatroom (name) |
/chatrooms |
deleteChatroom |
DELETE | null | /chatrooms/{chatroomId} |
addUserToChatroom |
PATCH | null | /chatrooms/{chatroomId}/users/{userId}/add |
removeUserFromChatroom |
PATCH | null | /chatrooms/{chatroomId}/users/{userId}/remove |
| Route Name | Request Type | RequestBody | Request Path |
|---|---|---|---|
sendMessage |
POST | MessageDTO messageDTO (message) |
/messages |
deleteMessage |
DELETE | null | /messages/{id} |
retrieveMessagesForChatroom |
GET | null | /messages/{chatroomId} |
| Route Name | Request Type | RequestBody | Request Path |
|---|---|---|---|
uploadImage |
POST | null (used @RequestParam instead. More info given below).** |
/image |
downloadImage |
GET | null | /image/{fileName}/*** |
** uploadImage: the @RequestParam represents the image. See the example below:
POST-> localhost:8080/imageBody->form-data- Within
keytype inimage- Hover your mouse in the top-right corner of the
imagebox and click on the drop-down and selectfileNOTtext- In the
valuebox, select an image file from your Desktop intovalue. For example: an image namedballoons.pngorballoons.jpeg
GET -> localhost:8080/image/balloons.png/
*** CAUTION: You must include the final slash at the end of the path/url, or it will break. If running as it should, you will see your selected image returned to you in the Postman console.
- Build on our image methods/controller to enable a user to send images and videos as messages into chatrooms, rather than them simply being stored/retrieved from the database
- Created user types: participants, moderators and admin
- Added logic to delete the chatroom method so that a chatroom automatically deletes when users no longer exist in the chatroom
- In the front-end, it would be nice to include automated suggestions for text (This can be done by implementing ChatGPT's API)
Sujan Sriram
Sarah Abdulle
Zaynah Sadiq
Natasha Usoh

