Go back and forth with rhymes instead of a ping pong ball and see if you can have the last word! The application uses inputs of previous players to come up with its rhymes as a response to yours.
The rhythm and flow of most poems, sometimes felt like a game of ping pong to me, which became the inspiration behind the simple game, Rhyme Ping Pong. π
This application tries to come up with a rhyme for each sentence entered and simultaneously builds up its knowledge by storing each unique sentence entered so that it can be used as a rhyme in the future.
Here's a short video that explains the project and how it uses Redis:
New sentences input by the user are stored along with the word ending of the sentenceβs final word, which is then used to query for a rhyming sentence each time a user inputs a new sentence. The word ending consists of the final 2 (or 3 if the 2nd to last letter is a consonant) letters of the last word in a sentence.
The data (sentences received) is stored in as a JSON data structure and a sentence is stored according to the the following schema:
- sentenceString - String
- wordEnding - String
- Checking for duplicates first,
const duplicate = await sentenceRepository
.search()
.where("sentenceString")
.equals(req.body.string)
.return.first();- Then saving the sentence if no duplicates were found.
wordEndingcontains the word ending of the final word of that senetnce.
if (duplicate === null) {
const sentence = sentenceRepository.createEntity(req.body.string);
sentence.sentenceString = req.body.string;
sentence.wordEnding = req.body.wordEnding;
const id = await sentenceRepository.save(sentence);
res.send(id);
}RediSearch was used for querying, and data was accessed in the follwong ways, where sentenceRepository creates the main access point for reading and writing entities on Redis.:
- Searching for a rhyming sentence
- Sentences are checked for how well they rhyme by querying the
wordEndingattribute - Then the record with a sentence identical to the user input sentence is removed if available, to avoid repeating the same sentence in the case of a user sending a sentence that is already n the database.
- A random sentence is picked to be displayed from the retrieved list to avoid displaying the same rhyming sentence each time.
- Sentences are checked for how well they rhyme by querying the
const rhymes = await sentenceRepository
.search()
.where("wordEnding")
.equals(req.params.word)
.and("sentenceString")
.not.equals(req.params.sentence)
.return.all();- Retrieving all stored sentences
const allSentences = await sentenceRepository.search().returnAll();- Node - version ">=14.17.0"
- Open a terminal in the root of the project folder.
- Run
cd frontendto enter the folder. - Run
npm install. - After package installation completes, run
npm start. - Open
http://localhost:3000/in your browser.
- Open a terminal in the root of the project folder.
- Run
cd backendto enter the folder. - Run
npm install. - Create a free account on Redis Cloud and create your database.
- Create a new user for the database.
- In a
.envfile in the root of/backendfolder, add the values for:
REDIS_DB_ENDPOINT=<Public endpoint>
REDIS_USER=<Database user's name>
REDIS_PWD=<Database user's password>
- Run
npm start.
Here some resources to help you quickly get started using Redis Stack. If you still have questions, feel free to ask them in the Redis Discord or on Twitter.
- Sign up for a free Redis Cloud account using this link and use the Redis Stack database in the cloud.
- Based on the language/framework you want to use, you will find the following client libraries:
- Redis OM .NET (C#)
- Watch this getting started video
- Follow this getting started guide
- Redis OM Node (JS)
- Watch this getting started video
- Follow this getting started guide
- Redis OM Python
- Watch this getting started video
- Follow this getting started guide
- Redis OM Spring (Java)
- Watch this getting started video
- Follow this getting started guide
- Redis OM .NET (C#)
The above videos and guides should be enough to get you started in your desired language/framework. From there you can expand and develop your app. Use the resources below to help guide you further:
- Developer Hub - The main developer page for Redis, where you can find information on building using Redis with sample projects, guides, and tutorials.
- Redis Stack getting started page - Lists all the Redis Stack features. From there you can find relevant docs and tutorials for all the capabilities of Redis Stack.
- Redis Rediscover - Provides use-cases for Redis as well as real-world examples and educational material
- RedisInsight - Desktop GUI tool - Use this to connect to Redis to visually see the data. It also has a CLI inside it that lets you send Redis CLI commands. It also has a profiler so you can see commands that are run on your Redis instance in real-time
- Youtube Videos
- Official Redis Youtube channel
- Redis Stack videos - Help you get started modeling data, using Redis OM, and exploring Redis Stack
- Redis Stack Real-Time Stock App from Ahmad Bazzi
- Build a Fullstack Next.js app with Fireship.io
- Microservices with Redis Course by Scalable Scripts on freeCodeCamp



