Skip to main content

Prerequisites

Before installing Elemental Battlecards, ensure you have the following installed on your system:
  • Node.js version 14 or higher
  • npm (comes with Node.js)
  • Git for cloning the repository
  • A modern web browser (Chrome, Firefox, or Edge recommended)
For local LAN play, you can use SQLite instead of PostgreSQL. This allows you to skip database setup and get started quickly.

Cloning the Repository

First, clone the Elemental Battlecards repository to your local machine:
git clone <repository-url>
cd elemental-battlecards
The project structure includes two main directories:
  • Backend/ - Node.js server with Express and Socket.io
  • Frontend/ - Phaser-based game client with Vite

Backend Installation

1

Navigate to Backend Directory

cd Backend
2

Install Dependencies

Install all required npm packages:
npm install
This will install the following key dependencies:
  • express - Web server framework
  • socket.io - Real-time bidirectional communication
  • sequelize - ORM for database management
  • jsonwebtoken - JWT authentication
  • bcryptjs - Password hashing
  • cors - Cross-origin resource sharing
  • dotenv - Environment variable management
3

Configure Environment Variables

Create a .env file in the Backend/ directory by copying the example file:
cp .env.example .env
PORT=3000
DB_HOST=127.0.0.1
DB_PORT=5432
DB_NAME=elemental
DB_USER=postgres
DB_PASS=postgres_password
JWT_SECRET=your_jwt_secret_key_here
Make sure to change JWT_SECRET to a strong, random string. Never commit your .env file to version control.
Using DB_USE_SQLITE=true enables an in-memory SQLite database, perfect for local testing without PostgreSQL setup. Note that data won’t persist after server restart.

Frontend Installation

1

Navigate to Frontend Directory

Open a new terminal window and navigate to the frontend:
cd Frontend
2

Install Dependencies

Install all required npm packages:
npm install
This will install:
  • phaser ^3.90.0 - Game framework
  • socket.io-client ^4.7.2 - Client-side Socket.io
  • vite ^5.4.21 - Fast development server and build tool

Database Setup (Optional)

Skip this section if you’re using SQLite (DB_USE_SQLITE=true) for local play.
If you want to use PostgreSQL for persistent data storage:
1

Install PostgreSQL

Download and install PostgreSQL from postgresql.org
2

Create Database

Connect to PostgreSQL and create a database:
CREATE DATABASE elemental;
3

Update Configuration

Update your Backend/.env file with your PostgreSQL credentials:
DB_HOST=127.0.0.1
DB_PORT=5432
DB_NAME=elemental
DB_USER=your_postgres_user
DB_PASS=your_postgres_password
4

Database Migrations

The database tables will be created automatically when you start the backend server for the first time. Sequelize will handle the schema synchronization.

Network Configuration for LAN Play

For playing over a local network, ensure the following:
1

Check Port Availability

Verify that ports 3001 (Backend) and 5173 (Frontend) are available and not blocked by other applications.
2

Configure Firewall (Windows)

If you’re hosting on Windows, allow traffic through the firewall:
# Allow Backend port
netsh advfirewall firewall add rule name="Elemental Battlecards Backend" dir=in action=allow protocol=TCP localport=3001

# Allow Frontend port
netsh advfirewall firewall add rule name="Elemental Battlecards Frontend" dir=in action=allow protocol=TCP localport=5173
3

Find Your Local IP

You’ll need your local IP address for other players to connect.
ipconfig
Look for the IPv4 address (e.g., 192.168.1.100) on your active network adapter.

Verification

Once installation is complete, verify your setup:
1

Check Node.js Version

node --version
Should output v14.0.0 or higher
2

Verify Backend Dependencies

cd Backend
npm list --depth=0
3

Verify Frontend Dependencies

cd Frontend
npm list --depth=0

Next Steps

Now that you have everything installed, proceed to the Quickstart Guide to launch your first game!

Build docs developers (and LLMs) love