smogon

Pokemon Showdown architecture

At the highest level, PS is split into three parts:

All three communicate directly with each other.

Game server

The game server is written in TypeScript and runs on Node.js.

Its entry point is server/index.ts, which launches several major components:

Rooms also includes support for battle rooms, which is where the server connects to the game simulator itself. Game simulation code is in sim/.

Client

The client is built in a mix of TypeScript and JavaScript, with a mostly hand-rolled framework built on Backbone. There’s a rewrite to migrate it to Preact but it’s very stalled.

Its entry point is index.template.html

It was written long ago, so instead of a single JS entry point, it includes a lot of JS files. Everything important is launched from js/client.js

Login server

The client’s login server, which handles logins and most database interaction, is written in TypeScript in progress. The backend is split between a MySQL InnoDB database (for most things) and a Postgres database (for Replays).

Its entry point is server.ts.