DEV Community

InterSystems Developer for InterSystems

Posted on • Originally published at community.intersystems.com

Mastering Conversations: A Guide to Building and Using a Java-Based Chat (StarChat) with IRIS Cloud SQL.

Intro

In a fast-paced digital era, effective communication is crucial. This article introduces a Java-based chat project, combining the strength of IRIS database and ChatGPT intelligence. Built on Java, it goes beyond real-time messaging, leveraging IRIS and ChatGPT for an enhanced chat experience. Also, the name of the project references the cultural classic - Star Wars.

Building Application

Building our dynamic chat application involves a seamless integration of key components and technologies. Java serves as the heart that drives server-side logic and business operations. Complementing it is Spring WebSocket, facilitating real-time messaging with configured endpoints. JQuery and HTML collaborate for an engaging user interface, with JQuery simplifying client-side scripting. IRIS Cloud SQL takes center stage as the database, ensuring reliable storage of critical data.

Running Application

To launch the dynamic chat application, configure essential environment variables for the IRIS database connection. You can use both IRIS Cloud SQL or local. If IRIS is local, utilize the provided docker-compose.yaml.  If you are using the local storage - Liquibase will handle database migrations, but in case of Cloud SQL - run migration manually using the .sql provided inside the project. Start the application and access the chat platform on port 3000 (customizable in application.properties file) by navigating to http://localhost:3000 your web browser.

Using StarChat

As with almost all software products, StarChat requires signing up:

Image description
 

and authorization:

Image description


After successful login, the user will be redirected to the main page of the chat. There the user will be able to create new chat rooms and chat with friends.

Key Features

Creating a chat room with another user
For the current moment, there is a possibility to create a chat room with 2 people. To create it there is a need to specify the chat room`s topic and email of the signed-up user:
  

Image description

Real-time messaging with friends
When your friends log in, the chat application prioritizes their experience by displaying the most recently updated chat at the top of the list. This design ensures that users are immediately connected to the latest conversations:

Image description

AI integration
Also, there was added the capability to interact with ChatGPT directly within the chat. Seamlessly pose questions, seek information, or simply enjoy a chat powered by the intelligence of ChatGPT. To get the answer from ChatGPT, there is a need to write a question in a format like '/chatgpt + space + your question':

Image description

Uploading files to the chat
Additionally, there is a possibility to upload the multimedia of a different type. The security features include forbidding double and dangerous extensions, preventing potential security risks associated with certain file types:

Image description

Conclusion

We've reached the end of our journey with this Java-based chat application! We've integrated advanced technologies to enable real-time messaging, secure data handling, and user-friendly features.

You may explore the application in more detail here.

Top comments (0)