Skip to content

Thoughts on the technology stack #2

@nodeg

Description

@nodeg

AI feedback on the technology stack:

Recommended Technology Stack

Primary Recommendation: Node.js + TypeScript with PostgreSQL

Backend Framework: Node.js with NestJS or Fastify
Database: PostgreSQL 16+
Frontend: Vue 3 or React with TypeScript
Real-time: WebSockets (Socket.io or native WS)
Authentication: Passport.js with bcrypt/argon2

Why This Stack?

  1. Security improvements:
  • Modern ORM (Prisma/TypeORM) prevents SQL injection by design
  • Built-in parameterized queries and input validation
  • Bcrypt/Argon2 password hashing (vs. broken MD5)
  • CSRF tokens, helmet.js security headers out-of-box
  • TypeScript catches type-based vulnerabilities at compile time
  1. Game-specific benefits:
  • Real-time gameplay: WebSockets enable live attack notifications, ranking updates without polling
  • Concurrent actions: Node.js handles multiple simultaneous attacks/upgrades efficiently
  • Queue management: Bull/BullMQ for timed upgrades and scheduled attacks
  • Caching: Redis integration for leaderboards and active session data
  1. Database advantages (PostgreSQL vs MySQL):
  • Proper foreign key constraints (currently missing)
  • JSON columns for flexible game data (PC upgrades, attack logs)
  • Better transaction support for concurrent battles
  • Native full-text search for messaging/boards
  • Row-level security for multi-tenant server support
  1. Developer experience:
  • TypeScript prevents entire classes of bugs
  • Modern tooling (ESLint, Prettier, Vitest)
  • Active ecosystem and security patches
  • Docker deployment simplicity

Alternative Option: Python + FastAPI

If you prefer Python:

  • FastAPI with SQLAlchemy ORM
  • PostgreSQL database
  • Pydantic for data validation
  • Vue/React frontend
  • Redis for caching/queues

Benefits: Excellent type safety, async support, automatic API documentation, strong security libraries (passlib, python-jose)

Migration Strategy

Phase 1: Database migration

  • Export existing MySQL data
  • Redesign schema with proper relationships (foreign keys, indexes)
  • Migrate to PostgreSQL with data transformation scripts

Phase 2: API-first backend

  • Build REST/GraphQL API in NestJS/FastAPI
  • Reimplement game logic with proper validation
  • Add authentication with modern password hashing
  • Implement WebSocket handlers for real-time features

Phase 3: Modern frontend

  • Build SPA with Vue 3/React
  • Real-time updates for attacks, mail, rankings
  • Responsive design for mobile play
  • Progressive enhancement

Phase 4: Game features

  • Port battle mechanics with proper transaction handling
  • Implement upgrade queues with background workers
  • Add rate limiting and anti-cheat measures

Critical Security Fixes Required

Regardless of technology choice, you must address:

  1. ✅ Password hashing: MD5 → Bcrypt/Argon2 with salts
  2. ✅ SQL injection: Deprecated mysql_* → Parameterized queries/ORM
  3. ✅ Session management: Cryptographically secure tokens, proper timeout
  4. ✅ Input validation: Server-side validation for all user inputs
  5. ✅ CSRF protection: Tokens on all state-changing operations
  6. ✅ XSS prevention: Output encoding, Content Security Policy
  7. ✅ Database constraints: Foreign keys, transactions for game actions

Final Verdict

Go with Node.js + TypeScript + NestJS + PostgreSQL if you want:

  • Strong typing and modern JavaScript
  • Real-time game features
  • Large ecosystem and community support
  • Easy Docker deployment

This stack gives you the best balance of security, performance, developer experience, and suitability for a real-time multiplayer browser game. The current PHP 4/5 codebase has fundamental
security flaws that can't be patched—a full rewrite is the right call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions