Skip to content

Commit fcea5a7

Browse files
committed
feat(article): update article and add links
1 parent 6a71807 commit fcea5a7

File tree

4 files changed

+41
-17
lines changed

4 files changed

+41
-17
lines changed

ARTICLE.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,45 @@ tags: redishackathon, redis, flask, socketio
99

1010
I recreated the game "Red Light, Green Light" using Python, TypeScript and Redis!
1111

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!
1313

1414
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.
1515

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.
1717

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.
2119

2220
The backend application services include:
2321

2422
- Flask server (for API endpoints and Websocket handlers)
2523
- Celery beat task scheduler (for scheduling tasks to change the light color in each room)
2624
- Celery worker (to change the light color for a room and to update that players in that room via Websocket)
2725

26+
![Project Diagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0egpm1igfqyon5kjtujv.png)
27+
28+
Please check out the video below for more details about how the project works.
29+
2830
### Submission Category
2931

3032
Wacky Wildcards
3133

32-
### [Optional: Video Explainer of My Project]
34+
### Redis Light, Green Light YouTube Video
3335

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.)
36+
{ % youtube BoalZKmgoEU %}
3537

3638
### Language Used
3739

38-
Python
40+
Python. Honorable mention for JavaScript.
3941

4042
### Link to Code
4143

4244
{% embed https://github.com/briancaffey/redis-light-green-light-dev-to-hackathon %}
4345

4446
### Additional Resources / Info
4547

46-
[Note:] # Screenshots/demo videos are encouraged!
48+
![Redis Light, Green Light](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m3rqy7eqz40nqk1e04jj.png)
49+
50+
![Redis Light, Green Light gameplay](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wkmgiz8wtq484rn6dmfc.png)
4751

4852
- - -
4953

Makefile

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
# for local development if not using docker-compose to star the backend services
1+
# docker-compose
2+
3+
# start the backend services (flask, celery, celerybeat, redis-stack)
4+
docker-compose:
5+
@docker-compose up --build
6+
7+
# start the client
8+
nuxt:
9+
@cd client && npm i && npm run dev
10+
11+
# for local development if not using docker-compose to stat the backend services
212

313
# check versions of locally installed tools
414
check:
@@ -7,9 +17,11 @@ check:
717
@python3 --version; echo
818
@echo Node `node -v`; echo
919

20+
# stand up only redis stack
1021
redis-stack-up:
1122
@docker-compose -f redis-stack.yml up
1223

24+
# install dependencies in a python virtual environment
1325
install_dev:
1426
@rm -rf app/.env
1527
@python3 -m venv app/.env
@@ -18,27 +30,30 @@ install_dev:
1830
@pip install -r app/requirements.txt
1931
@pip install -r app/requirements_dev.txt
2032

33+
# delete the python virtual environment
2134
clean:
2235
@rm -rf .env
2336

37+
# start the flask app (api and websockets)
2438
flask:
2539
@. app/.env/bin/activate
2640
@cd app && gunicorn -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 wsgi:app --reload
2741

42+
# start the celery worker
2843
celery:
2944
@. app/.env/bin/activate
3045
@cd app && celery --app app.celery worker --loglevel=info
3146

47+
# start the celerybeat process
3248
celerybeat:
3349
@. app/.env/bin/activate
3450
@cd app && celery --app app.celery beat --loglevel=info
3551

36-
nuxt:
37-
@cd client && npm i && npm run dev
38-
52+
# delete all keys from all redis databases
3953
flushall:
4054
@docker exec -it redis redis-cli flushall
4155

56+
# count lines of code
4257
cloc:
4358
cloc \
4459
--exclude-dir=$$(tr '\n' ',' < .clocignore) \

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ SUM: 33 454 122 1432
4343

4444
Here's a short video that explains the project and how it uses Redis:
4545

46-
[[ Coming soon ]]
46+
<iframe width="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>
4747

4848
## How it works
4949

@@ -66,7 +66,7 @@ class Position(HashModel):
6666
room: uuid.UUID = Field(index=True)
6767
```
6868

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:
7070

7171
**Creating a new room**: `CREATE operation` on `Room` hash
7272

@@ -301,3 +301,5 @@ Configuration ->
301301
Before starting `celerybeat`, make sure that you have deleted a file called `celerybeat-schedule.db`.
302302

303303
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.

marketplace.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
"redis_features": ["queue", "messaging", "streams"],
1414
"redis_modules": ["RedisSearch"],
1515
"app_image_urls": [
16+
"https://res.cloudinary.com/practicaldev/image/fetch/s--391EQ1p1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m3rqy7eqz40nqk1e04jj.png",
17+
"https://res.cloudinary.com/practicaldev/image/fetch/s--ezf1ssyt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0egpm1igfqyon5kjtujv.png",
18+
"https://res.cloudinary.com/practicaldev/image/fetch/s--uD8xn_Xp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wkmgiz8wtq484rn6dmfc.png"
1619
],
17-
"youtube_url": "",
18-
"special_tags": ["Hackathon", "RedisOM"],
20+
"youtube_url": "https://www.youtube.com/watch?v=BoalZKmgoEU",
21+
"special_tags": ["Hackathon", "Redis OM"],
1922
"verticals": ["Gaming"],
2023
"markdown": "https://raw.githubusercontent.com/briancaffey/redis-light-green-light-dev-to-hackathon/main/README.md"
2124
}

0 commit comments

Comments
 (0)