# Galaxy Strike Online - Complete Setup Guide

This comprehensive guide will walk you through setting up the entire Galaxy Strike Online project from scratch.

## Table of Contents

1. Prerequisites
2. Project Download
3. Server Setup
4. Client Setup
5. Database Setup
6. Running the Application
7. Testing
8. Troubleshooting

## 1. Prerequisites

### Required Software:

- Node.js 18.0.0 or higher - Download from nodejs.org
- MongoDB - Local installation or MongoDB Atlas account
- Git - For version control (optional but recommended)
- Code Editor - VS Code recommended

Important: Make sure Node.js is version 18.0.0 or higher. Check with `node --version`

## 2. Project Download

### Option A: Clone from Git Repository

    git clone <repository-url>
    cd galaxystrikeonline

### Option B: Download ZIP File

1. Download the project ZIP file
2. Extract to your desired location
3. Navigate to the project directory

## 3. Server Setup

### Step 1: Navigate to Server Directory

    cd Server

### Step 2: Install Dependencies

    npm install

### Step 3: Create Environment File

    cp .env.example .env

### Step 4: Configure Environment Variables

Edit the `.env` file with your configuration:

    PORT=3001
    MONGODB_URI=mongodb://localhost:27017/galaxystrikeonline
    JWT_SECRET=your_jwt_secret_key_here
    CLIENT_URL=http://localhost:3000

Important: Replace `your_jwt_secret_key_here` with a secure random string.

### Step 5: Database Migration

    npm run migrate

### Step 6: Seed Database

    npm run seed

## 4. Client Setup

### Step 1: Navigate to Website Directory

    cd ../Website

### Step 2: Install Dependencies

    npm install

### Step 3: Create Environment File

    cp .env.example .env

### Step 4: Configure Environment Variables

Edit the `.env` file:

    VITE_API_BASE_URL=http://localhost:3001/api
    VITE_SOCKET_URL=http://localhost:3001

## 6. Running the Application

### Step 1: Start MongoDB

- Local: Start MongoDB service
- Atlas: Ensure cluster is running

### Step 2: Start Server

    cd Server
    npm run dev

Server will start on port 3001

### Step 3: Start Client

    cd ../Website
    npm run dev

Client will start on port 3000

### Step 4: Access Application

Open browser and navigate to: http://localhost:3000

## 8. Troubleshooting

### Common Issues:

#### 1. MongoDB Connection Error

- Ensure MongoDB is running
- Check connection string in .env file
- Verify network connectivity

#### 2. Port Already in Use

- Check if ports 3000 or 3001 are occupied
- Use `netstat -ano | findstr :3000`
- Kill conflicting processes

#### 3. Module Installation Errors

- Clear npm cache: `npm cache clean --force`
- Delete node_modules and package-lock.json
- Run `npm install` again

### Success Indicators:

- Server starts without errors on port 3001
- Client starts without errors on port 3000
- Can register and login successfully
- Socket.IO connection established