The backend server for an online multiplayer drawing and guessing game (Pictionary) built with modern web technologies.
The Doodle server powers the real-time, multiplayer gameplay of the Doodle app. It handles communication between players using Socket.IO, ensures synchronization of the game state, and implements core game logic.
The client side code can be found at https://github.com/Experimentf/doodle-client
- ⚡ Real-time Communication: Leverages Socket.IO for real-time, low-latency interactions between clients.
- 🔄 Game State Management: Handles game room setups, player turns, drawing events, and scores.
- ✅ Scalable Architecture: Built with Node.js and TypeScript for clean, efficient, and maintainable code.
- 🔒 Environment Configuration: Securely configures sensitive data with
.env
files. - ⚙️ Customizable Events: Easily extendable Socket.IO event handlers for custom logic.
A modern backend stack powers the server:
- Node.js: Runtime environment for the server.
- TypeScript: Strongly typed programming for reliability and maintainability.
- Socket.IO: Enables bidirectional communication between the client and server.
- dotenv: Manages configuration via environment variables.
Here’s an overview of the folder structure within the server:
/src
│
├── constants/ # Socket.IO events, default configuration values, etc
│
├── controllers/ # Contains logic for socket event handling and delegating actions to responsible services
│
├── models/ # Models for game, rooms, doodlers, etc.
│
├── services/ # Room, Doodler, Game and Socket services that manage their own responsbilities
│
├── utils/ # Utility functions and helpers
│
├── types/ # Typescript type definitions
│
└── app.ts # Entry point for the server
Ensure you have the following installed:
- Node.js (>= 16.x): Download here
- npm (Comes with Node.js)
-
Clone the repository:
git clone https://github.com/Experimentf/doodle-server.git cd doodle-server
-
Install dependencies:
npm install
-
Create a
.env
file in the root of the project to configure the server environment:PORT=5000 DOODLE_CLIENT_URL=http://localhost:3000
Replace
http://localhost:3000
with the actual client URL if needed. -
Start the development server:
npm run dev
-
The server will be up and running at
http://localhost:5000
.
The server facilitates real-time communication between multiple clients through Socket.IO.
- All the socket events being handled are specified here
The Socket.IO event system is modular and supports creating custom events to extend functionality.
Variable | Description | Default Value |
---|---|---|
PORT |
Port the server runs on | 5000 |
DOODLE_CLIENT_URL |
The URL of the client application | http://localhost:3000 |
Add these variables to a .env
file in the root directory for local development.
To build the server for production:
npm run build
The compiled files will be output to the dist/
directory.
After building the project, start the server using:
npm run dev
Contributions are welcome! If you’d like to improve the project, follow these steps:
- Fork the repository.
- Create your feature branch (
git checkout -b feature/awesome-feature
). - Commit your changes (
git commit -m 'Add awesome feature'
). - Push to the branch (
git push origin feature/awesome-feature
). - Open a pull request!
This project is licensed under the MIT License. See the LICENSE file for details.
![]() @divyanshf |
Enjoy building and contributing to Doodle Server! 🎉