Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ __pycache__
.idea/
./dice
*.rdb
dice
main
/dice/
/main/
tmp/
vendor/

Expand Down
35 changes: 35 additions & 0 deletions examples/chatroom-java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/*
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
19 changes: 19 additions & 0 deletions examples/chatroom-java/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
9 changes: 9 additions & 0 deletions examples/chatroom-java/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Use OpenJDK 21 base image
FROM openjdk:21-jdk

WORKDIR /app

COPY target/chatroom.jar .

ENTRYPOINT ["java", "-jar", "chatroom.jar"]
CMD []
75 changes: 75 additions & 0 deletions examples/chatroom-java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# DiceDB Java Chatroom

A terminal-based chatroom application built in Java using [DiceDB](https://github.com/DiceDB/dice) and the [DiceDB-Java SDK](https://github.com/bipoool/dicedb-java). Each instance of the application connects to a shared DiceDB backend and communicates in real-time through a simple terminal interface.

---

## ⚙️ Requirements

- Java 21
- Maven (use included `mvnw` wrapper)
- DiceDB running locally on port `7379`

> Make sure DiceDB is up and running before you start the application.
> Refer to [DiceDB README](https://github.com/DiceDB/dice/blob/master/README.md) for setup instructions.

---

## 🚀 Running the Application

### Using JAR

To build and run the JAR:

```bash
# Step 1: Build the jar
./mvnw clean install

# Step 2: Run the jar with a username
java -jar target/chatroom.jar <username1>
java -jar target/chatroom.jar <username2>
```

### Using Docker

To build and run the Container:

```bash
# Step 1: Build the jar
./mvnw clean install

# Step 2: Run DiceDB docker container first
docker-compose up -d dicedb

# Step 3: Run Container for each chatroom session
docker-compose run chatroom username1
docker-compose run chatroom username2
```

### Using IntelliJ (Not in windows)

```text
Just run the `main` method in the `Main` class with your desired username passed as an argument.
```

## 💬 Interface Instructions

```text
1. A popup terminal window will appear.

2. Type your message in the input box.

3. Use the Left Arrow Key to shift focus to the Send button.

4. Press Enter to send the message.

5. Write 'exit' to leave the chatroom.
```

## 📸 Screenshots
![Chatroom Screenshot](assets/chatroom.png)

## Want to contribute?
```
If you have suggestions or improvements, feel free to open an issue or submit a pull request. Your feedback is always welcome!
```
Binary file added examples/chatroom-java/assets/chatroom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions examples/chatroom-java/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.vipulgupta.dice.example</groupId>
<artifactId>chatroom-java</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>me.vipulgupta.dice.example.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>chatroom</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
21 changes: 21 additions & 0 deletions examples/chatroom-java/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3.8'

services:
dicedb:
image: dicedb/dicedb:latest
container_name: dicedb
ports:
- "7379:7379"

chatroom:
build:
context: .
dockerfile: Dockerfile
container_name: chatroom-app
depends_on:
- dicedb
environment:
- DICEDB_HOST=dicedb
- DICEDB_PORT=7379
stdin_open: true
tty: true
Loading