You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recreated the game "Red Light, Green Light" using Python, TypeScript and Redis!
11
11
12
-
One day in early August I was browsing Dev.to while re-watching MrBeast's Squid Game recreation video in the background when I cam across the DEV article about the Redis Hackathon. Then I got a crazy idea: **Redis Light, Green Light**! I became determined to create my own online, real-time, multi-player version of Red Light, Green Light powered by Redis and submit it to the Wacky Wildcard project category for my chance to win the hackathon!
12
+
One day in early August I was browsing DEV while re-watching MrBeast's Squid Game recreation video in the background when I cam across the DEV article about the Redis Hackathon. Then I got a crazy idea: **Redis Light, Green Light**! I became determined to create my own online, real-time, multi-player version of Red Light, Green Light powered by Redis and submit it to the Wacky Wildcard project category for my chance to win the hackathon!
13
13
14
14
I used my favorite languages and frameworks for rapid prototyping: Python with Flask to power the backend and TypeScript with the Nuxt.js framework to build the frontend components for my game.
15
15
16
-
For real-time communication I added the `Flask-SocketIO` library to my Flask app and the `socket.io-client` library to my Nuxt app. I also added celery for scheduling and processing async tasks (more on this later). Redis was used as the message queue for websocket messages and it was also used as the broker for celery tasks.
16
+
For real-time communication I added the `Flask-SocketIO` library to my Flask app and the `socket.io-client` library to my Nuxt app. I also added celery for scheduling and processing async tasks. Redis was used as the message queue for websocket messages and it was also used as the broker for celery tasks.
17
17
18
-
`redis-py` was used to get and set hash values that kept track of live game data in Redis. Redis streams were used as a way to track all events for a historical record of every action in every game.
19
-
20
-
Like I do with most of my projects, I used `docker-compose` to set up the backend application services and database and I used Nuxt's `npm run dev` command to work on the UI.
18
+
This was my first project working with Redis Stack and Redis OM and I really liked using these tools. I stored most of my data in hashes, and the Redis OM library is perfect for using this data type. I also used Redis streams for the first time which was a lot of fun.
21
19
22
20
The backend application services include:
23
21
24
22
- Flask server (for API endpoints and Websocket handlers)
25
23
- Celery beat task scheduler (for scheduling tasks to change the light color in each room)
26
24
- Celery worker (to change the light color for a room and to update that players in that room via Websocket)
Please check out the video below for more details about how the project works.
29
+
28
30
### Submission Category
29
31
30
32
Wacky Wildcards
31
33
32
-
### [Optional: Video Explainer of My Project]
34
+
### Redis Light, Green Light YouTube Video
33
35
34
-
[Note]: #(This is where you can embed the optional bonus video you created to accompany your submission. Ensure your video is published publicly to YouTube and you’ve used the embed tag here to share it with us. By opting to include a video, you will be eligible for BONUS prizes. Learn more in the announcement post.)
Copy file name to clipboardExpand all lines: README.md
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ SUM: 33 454 122 1432
43
43
44
44
Here's a short video that explains the project and how it uses Redis:
45
45
46
-
[[ Coming soon ]]
46
+
<iframewidth="560"height="315"src="https://www.youtube.com/embed/BoalZKmgoEU"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"allowfullscreen></iframe>
47
47
48
48
## How it works
49
49
@@ -66,7 +66,7 @@ class Position(HashModel):
66
66
room: uuid.UUID= Field(index=True)
67
67
```
68
68
69
-
RedisOM is used to perform CRUD (create, read, update and delete) operations on these hashes in API requests, websocket handlers and celery tasks. Here are some examples:
69
+
Redis OM is used to perform CRUD (create, read, update and delete) operations on these hashes in API requests, websocket handlers and celery tasks. Here are some examples:
70
70
71
71
**Creating a new room**: `CREATE operation` on `Room` hash
72
72
@@ -301,3 +301,5 @@ Configuration ->
301
301
Before starting `celerybeat`, make sure that you have deleted a file called `celerybeat-schedule.db`.
302
302
303
303
The client runs on `http://localhost:3000`. It makes API and websocket connections with the backend which runs on `http://localhost:8000`.
304
+
305
+
Please see the [Makefile](/Makefile) for a full list of commands for running the application locally.
0 commit comments