Cinemate
A social platform for movies, with forums, reviews and watch parties. Then I rebuilt its insides so posting stopped waiting on an AI model.
- Role
- Built the whole backend with one other dev. Then rebuilt and revamped all of it alone.
- Built with
- Spring Boot, PostgreSQL, Kafka, Redis, ONNX, React
- Outcome
- Posting went from 200–2000 ms to about 10 ms. Moderation still lands in under a second, and no request gets lost.
The mess
Cinemate started as a university team project, and another dev and I built the whole backend: movie reviews, Reddit-style forums, and watch parties where friends stay in sync. It worked, but every post sat waiting while an AI model decided if it was toxic. That’s anywhere from 200 ms to 2 seconds of staring at a spinner.
What I saw
The model’s verdict didn’t need to block the person posting. It only needed to be guaranteed to happen. That turned a speed problem into a reliability problem, and reliability problems have well-known shapes.
the part I’m proudest of ↓
What I built
After the course ended, I kept going alone. A post now saves instantly, and in the same transaction it leaves a note saying “check this.” A relay forwards those notes through Kafka to a small fleet of model workers, and their verdicts come back the same way. If anything crashes halfway, the note is still there and gets picked up again.
Along the way, I put a single gateway in front of everything, so the backend never handles a login token. I also folded three databases into one.
What happened
Posting dropped to about 10 ms at the median. Moderation verdicts land in about 0.7 seconds. I measured every number on a real running stack and wrote down what the numbers can’t tell you yet.
Decision log
Every fork in the road, and which way I went.
- 01
Should every post wait for the moderation model?
ruled out: check it before saving- chose: save it now and check right after
Waiting made every post take up to 2 seconds. Checking right after means a toxic post can be visible for about a second before it's removed, which is how big platforms already work.
- 02
Three databases, or one?
ruled out: keep MySQLruled out: MongoDB and Redis- chose: move everything to PostgreSQL
Saving a post and its moderation request together needed a second transaction manager across two databases. With one database it's a single ordinary transaction.
deleting a database felt better than adding one.
- 03
Exactly-once delivery, or at-least-once?
ruled out: Kafka exactly-once- chose: at-least-once and make duplicates harmless
Exactly-once is heavy machinery. Making every step safe to run twice is simpler to build, simpler to reason about, and just as correct here.
- 04
Split everything into microservices?
ruled out: one service per feature- chose: one core app plus services that earn their own
Only the gateway and watch parties had a real reason to stand alone. Everything else shares the same data and traffic, so splitting it would only add ops work.
Things that broke
- benchmark dayModeration looked like it took 9.6 seconds. → The benchmark was wrong, not the system. It sent every post before it started watching. Measure your measurement first.
- the auditIf the moderation check failed, posts went through unchecked. → Decide what "failure" means before it happens, not after.