Development Setup Getting Started
Overview
CS2Inspect consists of two components that work together:
- CS2Inspect Web Application (this repository) - The web interface for managing loadouts
- CS2Inspect Plugin (GitHub Repository) - The CounterStrikeSharp plugin that applies loadouts in-game
Plugin Required
The CS2Inspect web application requires the CS2Inspect Plugin to be installed on your CS2 server. Both components share the same database. The web application stores loadout configurations, and the plugin reads from the database to apply them in-game.
Prerequisites
Important
Before setting up the CS2Inspect development environment, ensure you have the following installed:
Required Software
Node.js: Version 20.x or higher Required
bashnode --version # Should be v20.0.0 or higherBun: Version 1.x or higher (recommended package manager) Recommended
bashbun --version # Install from https://bun.shPackage Manager
This project uses Bun as the primary package manager for faster installs and better performance. npm is also supported but Bun is recommended.
MariaDB: Version 11 or higher Required
- Alternative: Docker (for containerized database)
Git: Latest version Required
bashgit --version
Optional Software
- Docker & Docker Compose: For containerized development Recommended
- Visual Studio Code: Recommended IDE with extensions:
- Volar (Vue Language Features)
- ESLint
- Tailwind CSS IntelliSense
- TypeScript Vue Plugin
Installation Steps
1. Clone the Repository
git clone https://github.com/sak0a/cs2inspect-web.git
cd cs2inspect-web2. Install Dependencies
Using Bun (Recommended):
bun installUsing npm (Alternative):
npm installWhat gets installed?
This will install all required packages including:
- Nuxt 4 framework
- Vue 3 and TypeScript
- Naive UI components
- Tailwind CSS
- Database drivers
- Testing frameworks
- And more...
3. Database Setup
Option A: Using Docker (Recommended for Development) Recommended
# Start MariaDB container for local development
docker run -d --name cs2inspect-db \
-e MYSQL_ROOT_PASSWORD=rootpassword \
-e MYSQL_DATABASE=cs2inspect \
-e MYSQL_USER=cs2inspect \
-e MYSQL_PASSWORD=password \
-p 3306:3306 \
mariadb:11Option B: Using Local MariaDB/MySQL
Install MariaDB:
bash# Ubuntu/Debian sudo apt-get install mariadb-server # macOS brew install mariadb # Windows # Download from https://mariadb.org/download/Start MariaDB:
bashsudo systemctl start mariadbCreate Database:
bashmysql -u root -psqlCREATE DATABASE csinspect CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'csinspect'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON csinspect.* TO 'csinspect'@'localhost'; FLUSH PRIVILEGES; EXIT;Database Schema:
Automatic Migrations
The application uses Drizzle ORM for database migrations. The schema is applied automatically when you start the server for the first time. You can also push the schema manually with
bun run db:push.The migration system will:
- Create all required tables automatically
- Track applied migrations in the
__drizzle_migrationstable - Run any new migrations on subsequent starts
- Skip already-applied migrations
4. Install CS2Inspect Plugin (Required)
Plugin Installation Required
The CS2Inspect web application requires the CS2Inspect Plugin to be installed on your CS2 server. The plugin reads loadout configurations from the shared database and applies them in-game.
Plugin Repository: https://github.com/sak0a/CS2Inspect-Plugin
Plugin Installation Steps
Clone the Plugin Repository:
bashgit clone https://github.com/sak0a/CS2Inspect-Plugin.git cd CS2Inspect-PluginBuild the Plugin:
bashdotnet build -c ReleaseInstall to CS2 Server:
- Copy
bin/Release/net8.0/CS2Inspect.dllto your CS2 server:game/csgo/addons/counterstrikesharp/plugins/CS2Inspect/ - Copy configuration files to the plugin directory
- Copy
Configure Plugin Database Connection:
The plugin must use the same database as the web application. Update the plugin's
config.json:json{ "DatabaseHost": "localhost", "DatabasePort": 3306, "DatabaseUser": "csinspect", "DatabasePassword": "your_database_password", "DatabaseName": "csinspect", "Website": "https://your-website.com" }Verify Plugin Installation:
- Restart your CS2 server
- Check server logs for plugin initialization
- Connect to the server and test plugin commands (e.g.,
!cs2inspect)
Plugin Documentation
For detailed plugin installation, configuration, and usage instructions, see the CS2Inspect Plugin README.
5. Environment Configuration
Copy the example environment file:
bashcp .env.example .envEdit
.envfile with your configuration:Security Notice
Make sure to generate a secure JWT token and use strong passwords for production!
env########## Server Configuration ########## PORT=3210 HOST=127.0.0.1 ########## JWT API Configuration ########## # Generate a random secret key JWT_TOKEN=your_random_secret_key_here_min_32_characters JWT_EXPIRY=7d ########## Database Configuration ########## DATABASE_HOST=127.0.0.1 DATABASE_PORT=3306 DATABASE_USER=csinspect DATABASE_PASSWORD=your_database_password DATABASE_NAME=csinspect DATABASE_CONNECTION_LIMIT=5 ########## Steam API Configuration ########## # Get your Steam API key: https://steamcommunity.com/dev/apikey STEAM_API_KEY=your_steam_api_key_here ########## Steam Account Configuration (Optional) ########## # Required for unmasked inspect URLs # Use a separate Steam account (Steam Guard not currently supported) STEAM_USERNAME=your_steam_username STEAM_PASSWORD=your_steam_password ########## Logging (Optional) ########## LOG_API_REQUESTS=trueGenerate a secure JWT token:
bash# Using Node.js node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" # Or using OpenSSL openssl rand -hex 32
6. Verify Configuration
Check that your configuration is correct:
# Push schema to database (verifies connection)
bun run db:push
# Or manually test the connection:
mysql -h 127.0.0.1 -u csinspect -p csinspect -e "SHOW TABLES;"System Integration
The web application and plugin work together through a shared database:
- Web Application: Players configure loadouts through the web interface, which saves to the database
- Plugin: When players join the server, the plugin reads their loadout from the database and applies it in-game
- Real-Time Sync: Changes made on the web are immediately available to the plugin
Database Configuration
Both components must use the same database (same host, port, name, user, and password). The database schema is created automatically by the web application migrations. The plugin reads from these tables:
wp_player_loadouts- Loadout configurationswp_player_rifles,wp_player_pistols,wp_player_smgs,wp_player_heavys- Weapon configurationswp_player_knifes- Knife configurationswp_player_gloves- Glove configurationswp_player_agents- Agent selectionswp_player_pins- Pin collections
Running the Application
Development Mode
Start the development server with hot-reload:
Using Bun (Recommended):
bun run devUsing npm (Alternative):
npm run devThe application will be available at:
- Local: http://localhost:3210
- Network: http://YOUR_IP:3210
- Health Status: http://localhost:3210/status
First Startup:
- Database migrations run automatically
- Health check sampling starts automatically
- Check console for migration progress
- Monitor startup health at
/api/health/details
Production Build
Build the application for production:
Using Bun:
bun run buildUsing npm:
npm run buildPreview the production build:
bun run preview
# or
npm run previewDocker Development
Run the database container for local development:
# Start database container
docker start cs2inspect-db
# View logs
docker logs -f cs2inspect-db
# Stop database container
docker stop cs2inspect-dbTIP
If you haven't created the container yet, see the Database Setup section above for the docker run command.
Database Management
Drizzle ORM Migrations
The project uses Drizzle ORM for database schema management and migrations.
Migration files are stored in server/database/drizzle/ (auto-generated by Drizzle Kit).
Available Commands:
# Push schema directly to database (good for development)
bun run db:push
# Generate migration files from schema changes
bun run db:generate
# Run pending migrations
bun run db:migrateHow it works:
- Migrations run automatically on app startup via
server/database/migrate.ts - Tracked in the
__drizzle_migrationstable - Skips already-applied migrations
- The auto-migration system handles both fresh databases and databases previously set up with
db:push(it seeds the journal if needed)
Development Workflow
During development, bun run db:push is the fastest way to sync your schema to the database. Use bun run db:generate and bun run db:migrate when you need versioned migration files (e.g., for production deployments).
Backup database:
mysqldump -u csinspect -p csinspect > backup_$(date +%Y%m%d).sqlRestore database:
mysql -u csinspect -p csinspect < backup_20240101.sqlDatabase Schema
The main tables are:
# Core Application Tables
wp_player_loadouts - User loadout configurations
wp_player_weapons - Weapon customizations
wp_player_knifes - Knife customizations
wp_player_gloves - Glove customizations
wp_player_agents - Agent selections
wp_player_pins - Pin collections
# System Tables
__drizzle_migrations - Migration tracking (Drizzle ORM)View migration files in server/database/drizzle/ directory.
Testing
Run All Tests
Using Bun:
bun testUsing npm:
npm testRun Tests in Watch Mode
bun test --watch
# or
npm run test:watchRun Tests with Coverage
bun test --coverage
# or
npm run test:coverageTest Structure
tests/
├── unit/ # Component and utility tests
├── integration/ # API integration tests
└── e2e/ # End-to-end testsLinting and Code Quality
Run Linter
Using Bun:
bun run lintUsing npm:
npm run lintAuto-fix Linting Issues
bun run lint -- --fix
# or
npm run lint -- --fixESLint Configuration
The project uses ESLint with:
- Nuxt recommended rules
- TypeScript support
- Vue 3 rules
- Tailwind CSS rules
Configuration: eslint.config.mjs
Development Workflow
1. Feature Branch Workflow
# Create feature branch
git checkout -b feature/my-new-feature
# Make changes
# ...
# Commit changes
git add .
git commit -m "Add new feature"
# Push to remote
git push origin feature/my-new-feature
# Create pull request on GitHub2. Component Development
When creating a new component:
- Create component file in
components/ - Use TypeScript for type safety
- Follow existing naming conventions
- Add to component documentation if major feature
- Write unit tests if applicable
Example:
<script setup lang="ts">
import { ref } from 'vue'
interface Props {
title: string
active?: boolean
}
const props = withDefaults(defineProps<Props>(), {
active: false
})
const emit = defineEmits<{
(e: 'click'): void
}>()
</script>
<template>
<div>
<!-- Component template -->
</div>
</template>3. API Development
When creating a new API endpoint:
- Create file in
server/api/ - Use TypeScript interfaces
- Implement authentication if needed
- Add error handling
- Document in API reference
- Write integration tests
Example:
// server/api/myendpoint.ts
import { defineEventHandler, readBody } from 'h3'
export default defineEventHandler(async (event) => {
try {
const body = await readBody(event)
// Your logic here
return {
success: true,
data: result
}
} catch (error) {
return {
success: false,
error: error.message
}
}
})Troubleshooting
Common Issues
1. Database Connection Errors
Error: ECONNREFUSED 127.0.0.1:3306
Solution:
# Check if MariaDB is running
sudo systemctl status mariadb
# Start MariaDB
sudo systemctl start mariadb
# Or with Docker
docker start cs2inspect-db2. Steam Authentication Issues
Error: Steam API key invalid
Solution:
- Verify your Steam API key at https://steamcommunity.com/dev/apikey
- Ensure
STEAM_API_KEYin.envis correct - Check that your IP is not blocked by Steam
3. Port Already in Use
Error: Port 3210 is already in use
Solution:
# Find process using port 3210
lsof -i :3210
# Kill the process
kill -9 <PID>
# Or use a different port
PORT=3212 npm run dev4. Missing Dependencies
Error: Cannot find module 'xyz'
Solution:
# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm install5. TypeScript Errors
Error: Type 'X' is not assignable to type 'Y'
Solution:
# Regenerate type definitions
npm run postinstall
# Or restart TypeScript server in your IDE6. Steam Client Connection Issues
Error: Steam client disconnected or GC timeout
Solution:
- Check that
STEAM_USERNAMEandSTEAM_PASSWORDare correct - Ensure Steam Guard is disabled on the account (not currently supported)
- Wait a few minutes and retry (Steam may be rate limiting)
- Check Steam server status: https://steamstat.us/
7. Inspect URL Processing Fails
Error: Invalid inspect URL format
Solution:
- Verify the URL format (see API documentation)
- For unmasked URLs, ensure Steam account is configured
- Check that the item still exists (not deleted from inventory)
Development Tools
Useful Commands
# Generate static site
npm run generate
# Analyze bundle size
npm run build -- --analyze
# Update dependencies
npm update
# Check for outdated packages
npm outdated
# Clean build artifacts
rm -rf .nuxt .output node_modules/.cacheCLI Tools
The project includes interactive CLI tools for common operations:
Project CLI
bun run cliFile: scripts/project-cli.ts
Interactive menu-driven CLI with categorized commands:
- Development: Start dev server, build, preview, generate
- Database: Push schema, generate/run migrations, open Drizzle Studio
- Testing & Quality: Run tests, watch mode, coverage, lint, typecheck
- Deployment: Create releases, manage Docker images
- Health: Check application health status
Setup Wizard
bun run setupFile: scripts/setup-wizard.ts
Interactive first-time configuration wizard:
- Prompts for server configuration (port, host, environment)
- Generates secure JWT token automatically
- Configures database connection and tests connectivity
- Sets up Steam API key
- Writes
.envfile with all configured values
Environment Validator
bun run validate-envFile: scripts/validate-env.ts
Validates your .env file against required variables:
- Checks for missing required variables
- Validates format and types with Zod schemas
- Reports errors, warnings, and suggestions
VS Code Settings
Create .vscode/settings.json:
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"typescript.tsdk": "node_modules/typescript/lib",
"files.associations": {
"*.css": "tailwindcss"
}
}Recommended VS Code Extensions
{
"recommendations": [
"Vue.volar",
"dbaeumer.vscode-eslint",
"bradlc.vscode-tailwindcss",
"Vue.vscode-typescript-vue-plugin"
]
}Next Steps
After setting up your development environment:
- Read the Architecture documentation
- Explore the Components guide
- Review the API Reference
- Check out How It Works
Production Deployment
For production environment variables and deployment configurations, see the Deployment Guide which includes complete environment variable references for all platforms.
Getting Help
- Documentation: Check other docs in the
docs/directory - Issues: Report bugs on GitHub Issues
- Discord: Join the community Discord (if available)
- Stack Overflow: Tag questions with
cs2inspect
Related Documentation
- Architecture - System architecture
- API Reference - API documentation
- How It Works - User flows
- Deployment - Production deployment and environment variables
- Contributing - Contribution guidelines