An injured animal. A tipped trash can. And a polluted hotspot. Most of us are likely to have come across one of these in our local community. But knowing how to react quickly to these scenarios can be a challenge. Who do I contact? What’s the process for reporting a health hazard? How much time will this take out of my day?
Not knowing the answer to any of these questions could be the difference between action and inaction. What it boils down to is that community is everything, and if we’re able to report community issues with ease then we could promote a healthier, safer, and greener planet.
Taking on this challenge is Bryon Rosas Salguero. Through his innovative application, Helplanet, individuals can instantly report local risks or accidents from just a few taps on their phone. But for this application to function, data had to be transmitted in real time to keep up with events that were happening in real life.
Redis was crucial to achieving this and it enabled Byron’s innovations to come to life. Let’s take a look at how he was able to put this app together. But before we get down to the nitty gritty of it all, we’d like to let you know that we have a diverse range of interesting applications for you to check out on the Redis Launchpad.
So don’t forget to check them out after this post!
You’ll build an application that allows people to report social issues in their community. These can include:
Below we’re going to walk you through each step of the application building process and highlight the components you’ll need along with their functionality.
Ready to get started? Ok, let’s dive straight in.
Clone this project or download as zip
git clone https://github.com/byronrosas/helplanet.git
Exec redis (https://github.com/RedisLabsModules/redismod)
docker run -p 6379:6379 --name myredis redislabs/redismod
sudo docker start myredis
cd helplanet/server
npm install
cd help-planet
npm install
npm install -g @ionic/cli
npm install @ionic-native/core@4 --save
cd helplanet-support
npm install
npm install -g @angular/cli
(Open three terminals)
First start server (start services) with this commands:
cd ..
cd server
npm run build
npm run dev
Second start ionic app (http://localhost:8100)
cd help-planet
ionic serve
Third start web angular app (http://localhost:4200)
cd helplanet-support
ng serve
Below are the RediSearch CLI commands for each of the services
Redis utils
FT.DROPINDEX usersIdx
FT.DROPINDEX notificationsIdx
FT.CREATE usersIdx ON HASH PREFIX 1 hpa:users: SCHEMA username TEXT password TEXT email TAG status NUMERIC role NUMERIC
FT.CREATE notificationsIdx ON HASH PREFIX 1 hpa:notifications: SCHEMA geo GEO userId TAG userOrg TAG
SET hpa:session:byron@hotmail.com "xyaszTOKENsdsjlvj" EX 24*60*60
DEL hpa:session:byron@hotmail.com
GET hpa:session:byron@hotmail.com
HSET "hpa:notifications:1621188142413-0" userId "byron@reporter.com" level "0" text "trash" situation "garbage" geo "-78.62285039999999,-1.2543408"
And
EXPIRE "hpa:notifications:1621188142413-0" 172800
HDEL "hpa:notifications:1621188142413-0" userOrg dateAttention
HSET "hpa:notifications:1621188142413-0" userId "byron@reporter.com" level "0" text "trash" situation "garbage" geo "-78.62285039999999,-1.2543408" serOrg x@hotmail.com dateAttention new Date()
DEL "hpa:notifications:1621188142413-0"
FT.SEARCH notificationsIdx * LIMIT 0 10
FT.SEARCH notificationsIdx @userId:{email/@hotmail/.com} LIMIT 0 10
XADD hpa:report MAXLEN 30 * userId "user@x.com" level "0" situation "garbage" lat "-7.54545" lon "-0.4545" text "trash"
XRANGE hpa:report 1621188142413 1621188142413
XRANGE hpa:report 1621188142413-0 + COUNT 1
HGETALL "hpa:notifications:1621188142413-0"
FT.SEARCH notificationsIdx @geo:[ "-0.4545" "-7.54545" 15 m]
HSET hpa:users:byron@hotmail.com username "byronman" password "encryptpassword" email "byron@hotmail.com" role "0"
FT.SEARCH usersIdx @email:{email@x.com}
HGETALL hpa:users:byron@hotmail.com
HSET hpa:users:byron@hotmail.com username "byronman" password "encryptpassword" email "byron@hotmail.com" role "0"
FT.SEARCH usersIdx @email:{email@x.com}
FT.SEARCH * LIMIT 0 10
XREAD COUNT 1 BLOCK 5000 STREAMS hpa:report $
Middleware is also used for each of the routes:
If somebody comes across a hazard or a social concern in their community, they can report it via the Helplanet application. Users simply have to open the app and they’ll then be faced with a number of options (see below).
The user will then select the option that best describes the issue or concern they’ve come across. Much like Facebook Messenger, a chat will appear where they’ll be able to provide more detail about the incident they’re reporting (see below).
Note: Everything will be reported in real time thanks to Redis.
The organization will receive notifications from all incidents that have been reported by members of the public. They’ll be able to gain a holistic view of all reported incidents on their dashboard (see below).
From here, an organization can select an incident and view it in more detail. The information that will be provided about the incident will include:
Organizations can filter everything based on location. This will allow them to get a quick insight as to where every instant is on the map (see below).
An organization can also view a user’s personal details if they want to get in touch with them in a different form of communication e.g email (see below).
Society thrives on individuals who bear the responsibility of reporting issues that pose a threat to their local community. But with so many different organizations and professionals to contact, the entire reporting process can be just as unclear as tedious.
Byron’s application was able to eliminate these barriers by creating a powerful application that made the entire process easy and simple. Yet for this app to function effectively and promote a seamless experience, data needed to be transmitted in real time.
Thanks to Redis, components in the application’s architecture became more interconnected where data transmission was both seamless and hyper-efficient.
If you want to discover more about how Helplanet was created, then make sure to watch the YouTube video here.
We also have a variety of other breakthrough applications that you can check out on the Redis Launchpad. Here you’ll get an insight into how Redis can be used to create exciting apps that are having an impact on everyday life around the world.
So what can you build with Redis?
Byron is a highly innovative software engineer who works independently as a freelancer. Make sure to keep up to date with all of his activity by visiting his GitHub page.