
Explore building an online chess game with login or register, lobby matchmaking, rooms and passwords, a timer, play moves and captures, plus depth features, chat, cookies, and user profile management.
Create and run a basic express server for the online chess game by wiring server.js on port 5000 and a get / route that returns hello from express.
Learn to use nodemon for automatic server restarts and manage env variables with dotenv by creating a .env file, configuring process.env in development, and dynamically setting ports.
Set up a MySQL database and connect your backend by creating the database and configuring host, user, password, and port. Export a database connection for the app.
Create a Redis client in a config file, configure localhost and default port, handle connections and errors, export/import the client for reuse, and prep next video on view engine.
Configure the view engine with ejs to render front-end components in express, set up views and public folders, register routes, and serve static assets for the online chess game.
Develop a register and login page for an online chess game by building reusable header and form components and wiring them to a register API.
Create users and user_info tables in database with primary key id, unique username, password, rank enum, default points, and a foreign key cascade; implement a stored procedure to create users.
Create an api register controller for an online chess game by setting up jwt-based authentication, input validation with express validator, and cookie-based session handling.
Implement a response methods component to display form error messages for user registration, parse URL search parameters, and apply danger or success styling with API integration.
Create login controller and API to register and log in, handling errors, querying the database, validating passwords, issuing a JWT token payload with a secret, and redirecting to the lobby.
Upgrade the lobby page by integrating header, footer, and response messages, and build room listings with rank filters (beginner to expert) linking to game search by rank.
Connect the client to the server with socket.io and log the successful connection. Check login cookies and tokens, redirect unauthenticated users, and manage lobby events between the front end.
Create functions to join as a user and disconnect from the lobby and game, using a Redis-stored user object and room tracking to manage total users.
Fetch and render current user info from the server using JWT and cookies, retrieving username, rank, and points via a get request to /user-info, updating the lobby UI and indicating loading.
Create a loading spinner and its behavior, wiring show and hide logic from the lobby to the server, then add the death component to enable cultural chat during play.
Implement a lobby chat interface with a message input and time-stamped messages. Broadcast messages to all players except the sender and verify across two browsers.
Create the games page by setting up the lobby, a games folder and index, and building a join and create flow with room passwords, random joins, and game time options.
Grab DOM elements for the games list and create room form, and wire inputs and join controls. Add fetch callbacks to load user data and rooms, and manage loading states.
Develop and expose functions to create and manage game rooms, track two players, moves, time, and optional password, and handle room joining and updates within an online chess game.
Create and display chess game rooms by emitting room and user events, filtering rooms by rank and players, and rendering join buttons to enter a room on the games page.
Enhance the games page by implementing a great room form to create rooms, handle show/hide states, submit room data with optional password, and enter the room for gameplay.
Add password-protected room functionality to the games page, enabling secure join flows, password validation, and server checks to control access and test join scenarios.
Implement and polish the games page by adding random room handling, player join and disconnect logic, room creation and removal, and game finish with scoring updates.
Create an online chess game room page featuring a centered 8x8 chessboard with 64 squares, labeled coordinates, and white and black pieces, plus a 15-minute timer and join waiting UI.
Learn how to initialize online chess game variables by organizing project folders, importing required scripts, and defining state like turn, timer, and game details.
Create an array of chess pieces with icons and positions, load assets, and render both white and black pieces on the board to display the chess game setup.
Manage the user-connected event to join rooms, validate passwords, handle room status (open, full, started), and emit or fetch game details to synchronize players and start the chess game.
Create and wire the receive event for start details, initialize game state for players, and implement a timer and cursor management to start the game.
Build an online chess game that implements pawn movement logic and displays all possible moves when a pawn is selected, using click interactions and move highlighting.
Learn to implement chess piece movements in an online chess game, including move validation, captures, check logic, and preparing puzzle moves for bishops, knights, rooks, kings, and queens.
Identify rook moves by iterating along x and y axes, checking top, bottom, left and right collisions, and collecting valid positions to generate all rook possible moves.
Develop a bishop move generator by looping through four diagonals, checking collisions and bounds, handling blocks and enemy pieces, and constructing all legal moves for an online chess game.
Implement a knight move function that computes all legal L-shaped moves on the board, checks bounds and captures, and displays possible moves for interactive gameplay.
Develop a function to compute king and queen moves, with the queen using bishop and rook moves, and filter moves to avoid king being attacked.
Continue with move logic, implement helper functions, check king safety and detect checks, save moves, and compute legal moves for pieces like bishop, knight, rook, and queen.
Implement checkmate logic by evaluating every piece's possible moves, simulating each move, and confirming the enemy king has no safe moves; return true for checkmate, otherwise false.
Implement server-side events to display chess moves to the other player, handling move submission, promotion, castling, and checkmate feedback for real-time gameplay.
Finish the move function, handle capture and promotion, update piece positions and game state, and test multiplayer play across two browsers while debugging player and room setup.
Implement and test the chess timer by completing the timer function, tracking current player, minutes and seconds, and starting and stopping the interval with update timer events.
Update the in-game timer to display accurate minutes and seconds by wiring timer updates on the server, invoking the update stamina function, and testing in a room.
Fix the timer error and debug piece capture by testing the server, joining the game, and validating piece movement. Then implement castling and pawn promotion to enable advanced chess moves.
Implement castling in an online chess game by updating rook and king positions, validating moves, and syncing with the server to ensure castling works correctly.
Finish the room page design by adding a fixed container with a hidden game over area, displaying the winner and scores, and a lobby link; set up toasts for promotion.
Implement pawn promotion in the online chess game by setting up promotion options, creating the promote function, handling color variants, duplicating promotable pieces, and checking end-of-board positions.
Explore how to implement pawn promotion in an online chess game, including detecting promotion, selecting a promoted piece, and updating the game state.
Implement a king under attack warning in an online chess game by adding a check status function and displaying a warning block to guide the king’s response.
Explore implementing en passant in an online chess game, including post-move checks, determining eligible captures, updating pawn positions, and handling the capture logic and state.
Implement en passant in the online chess game by computing possible moves, validating captures, updating move state, and preparing visuals and future draw functionality.
Implement draw detection in the online chess game by adding a draw-check function, counting pieces, and triggering end-game behavior with a draw message and room-based server support.
Create a database procedure to update scores and user ranks in an online chess game, handling points and ranks from beginner to expert while syncing with the users table.
Finish implementing all socket events on the server to manage rooms, track players, handle game outcomes (winner, loser, draw), and update Redis-stored scores after each match.
Test and finish the online chess game by validating checkmate and timer end, fixing a for loop and player switching, and enabling room creation with move tracking.
Design a games controller to fetch the user played games via the api and implement caching. Implement middleware to verify jwt, authorize the user id, and return the game data.
Create a stats page for the online chess game by wiring a data-driven table of played games, moves, and timers, with links to view each game's moves via server data.
Finish the games controller, implement the get game moves function, handle errors, and prepare replay data for played games using the api.
Design the play games page by building a moves table and wiring a callback to display each move with from, to, time, and piece.
Learn to finish the user controller by validating input, handling username changes, email updates, and password updates, checking for taken usernames, issuing tokens, and clearing cookies on logout.
Design and implement a profile page for the online chess game, creating the profile folder and index, and enabling username display with change password while integrating backend API routes.
Add comprehensive profile page functionality for an online chess game, enabling username, email, and password updates, toggleable inputs and cancel actions, fetch-based submissions, toast feedback, and account deletion.
deploy and host the online chess game on a Digital Ocean droplet using Docker and Docker Compose, configure the database and server, then verify the live game runs.
In this course we are going to create from scratch a complete online chess game. Also we are going to setup a MySQL database to store the users info (username, email, score, played games etc.) and we are going to use also Redis. We are going to set up a basic express server, and for our view engine we are gonna use ejs. For our server we are going to use different routes to displaying the pages and different routes for the api. We are going to use a lot of socket events so by the end of this course you'll have mastered SocketIO. I will provide all the styling in the resources folder in the first section because this isn't going to be a CSS tutorial, because I want this tutorial to help you focus on your javascript skills. What you will learn in this course:
How to create a server with nodejs
How to connect to your MySQL database from your nodejs server
How to connect to a Redis client from your nodejs server
How to use SocketIO for client-server communication
How to use VanillaJs to create or update DOM Elements
How to create a complete chess game using javascript
How to setup a MySQL database for your game
How to create and use MySQL procedures
How to create middlewares to authenticate users
How to store cookies
How to use jwt authentication
How to hash user passwords
*************************************************************************************************
Since some of the npm packages may have updated when you take this course, it would be better if you used the same versions with me. Also you should have locally installed MySQL and Redis. I use MySQL 8 and Redis 3.0.5 (I used msi installer for redis), but you can use newer versions for redis.
*************************************************************************************************