r/AskComputerScience • • 4d ago

Node.js (Socket.io + Prisma) vs. FastAPI (SQLAlchemy) for an isolated Chat microservice?

Hey folks,

Building an isolated chat microservice consumed by other services in our ecosystem. Auth/users are handled externally by a dedicated Identity service, so our service only handles private topics/rooms, participant access, message history, and an embeddable <iframe> widget.

Stuck choosing between two stacks:

  1. Node.js + Prisma + Socket.io

    • Pros: Native room management (socket.join, io.to().emit), simple single-language codebase for both backend and the iframe widget.

    • Cons: Generating interactive API docs for other teams isn't as seamless out of the box.

  2. Python + FastAPI + SQLAlchemy

    • Pros: Automatic OpenAPI/Swagger docs (/docs) out of the box makes sharing API contracts effortless.

    • Cons: Bare-bones WebSockets mean building a custom ConnectionManager for rooms/disconnects, plus writing JS for the iframe anyway.

Is rolling custom WebSocket room logic in FastAPI a pain compared to Socket.io's battle-tested rooms, or is FastAPI’s clean OpenAPI generation worth the plumbing?

Would love to hear how you'd approach this!

2 Upvotes

Duplicates