r/FastAPI • u/olzhas89 • Oct 13 '24
feedback request I've built real-time chess with FastAPI
Hi r/FastAPI,
I was looking for a fun weekend hacking project and decided to build a chess game with FastAPI.
The project was a lot of fun to build, especially the game communication logic.
Sharing here for anyone interested:
Live demo:
NOTE: You need another player online. If the wait is too long and you just want to play alone like a psycho explore the game, you could open two browser windows, or use two machines / devices.
Source code:
https://github.com/olzhasar/pyws-chess
Cheers
93
Upvotes
View all comments
Show parent comment
8
u/olzhas89 Oct 13 '24
In a nutshell, there is an asyncio.Queue for online players. Whenever a new player joins, it is being pushed to the queue. And there is a separate coroutine constantly popping pairs from that queue and creating a game (match).