A web-based card game.
/client: Contains the frontend React application built with Vite./server: Contains the backend Node.js/Express/WebSocket server. Handles game logic, state management, action validation, WebSocket communication, and serves API endpoints.
- Clone the repository (if applicable).
- Install Server Dependencies:
cd server npm install # Installs Express, WebSocket (ws), TypeScript, cors, etc.
- Install Client Dependencies:
cd ../client npm install # Installs React, Vite, GamesFun SDK, etc.
-
Start the Server:
cd server npm run dev # Or 'npm start' depending on your package.json scripts
This will start the Node.js server (usually listening on
http://localhost:3001). It handles game logic and API requests. Check the server console for confirmation. -
Start the Client (Development Mode):
cd ../client # If you are still in the server directory # Or just 'cd client' if you are in the root directory npm run dev
This will start the Vite development server (usually at
http://localhost:5173). Open this URL in your browser to view the game client.
- The server uses TypeScript, configured via
server/tsconfig.json. It uses thecorsmiddleware to allow requests from the client's origin. - The client uses TypeScript, configured via
client/tsconfig.json.
To set up the project for local development, follow these steps:
- Prerequisites:
- Ensure you have Node.js installed (which includes npm). Version 18 or later is recommended.
- You can use
npmoryarnas your package manager. Commands below usenpm.
- Clone the Repository:
- If you haven't already, clone the project repository to your local machine.
- Install Server Dependencies:
- Navigate to the
serverdirectory in your terminal:cd server - Install the required packages:
npm install
- Navigate to the
- Install Client Dependencies:
- Navigate to the
clientdirectory in your terminal:cd ../client - Install the required packages:
npm install
- Navigate to the
- Run the Development Server:
- In the
serverdirectory terminal:npm run dev
- This will start the backend server, typically listening on
http://localhost:3001. It should also watch for file changes and restart automatically.
- In the
- Run the Development Client:
- In the
clientdirectory terminal:npm run dev
- This will start the Vite development server for the frontend, usually accessible at
http://localhost:5173(Vite will output the exact address). It provides features like Hot Module Replacement (HMR).
- In the
- Access the Application:
- Open your web browser and navigate to the address provided by the Vite development server (e.g.,
http://localhost:5173). - The client is configured to automatically connect to the local backend server (
http://localhost:3001) when running in development mode (npm run dev).
- Open your web browser and navigate to the address provided by the Vite development server (e.g.,