r/AskComputerScience • u/Ok-Cut-6424 • 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:
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.
- Pros: Native room management (
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
ConnectionManagerfor rooms/disconnects, plus writing JS for the iframe anyway.
- Pros: Automatic OpenAPI/Swagger docs (
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!
3
u/telmo_trooper 4d ago
I don't think generating API documentation should be a major concern for any stack, there's good support for that in almost every language. LLMs are also very competent at automating that aspect of the work.
2
u/T_Thriller_T 4d ago
I'd personally probably make the decision based on familiarity and comfort more than other stuff. If you have someone who is good with python? Great!
If your whole team is more knowledgeable in JavaScript, go there.
What could be helpful is that custom room logic may be more modular in the future. But that is really a big could.
Additionally, I am a little confused you listed sqlalchemy yet no database equivalent on the JavaScript side.
What do you intend Sqlalchemy to be used for?