System Architecture: Wiring the Stack Together
See how a proxy server, an LLM server, a vector database, a document database, and an MLOps tracking server fit together into one movie-recommendation app — and how count vectorization plus cosine similarity power the 'similar movies' feature.
One Client, One Server It Talks To
Every piece from the last two modules — Ollama, ChromaDB, MLflow — is a separate running service. A mobile or web frontend shouldn’t have to know about all of them individually, negotiate with each one directly, and handle each one’s own failure modes. Instead, the frontend talks to exactly one server, and that server fans requests out to whichever backend service actually needs to handle them.
That single point of contact is a proxy & API server, and it’s the piece that makes the rest of this architecture tractable.
Trace each request type through this diagram:
- Chat — frontend → ExpressJS → Ollama (Gemma) → streamed back to the frontend. This is the RAG pipeline from Module 3, fronted by the proxy.
- Search / list movies — frontend → ExpressJS → MongoDB Atlas, a straightforward document lookup.
- Recommend — frontend → ExpressJS → the FastAPI ML server, which loads the current best model from MLflow (Module 4) and returns a prediction. That same FastAPI server also owns the Chroma vector database, populated ahead of time from PDF documents by the population script from Module 3.
One proxy, three very different backends, and the frontend never needs to know any of that — it only ever talks to ExpressJS.
Why a Proxy Server at All
It would be technically possible to have the frontend call Ollama, MongoDB, and FastAPI directly. Almost nobody builds it that way, for a few concrete reasons:
- One thing to configure. The client only ever needs to know one server’s address, not four.
- A place for cross-cutting logic. Auth checks, rate limiting, logging — all live in one layer instead of being duplicated across every backend service.
- Backend services can change independently. Swap Ollama for a different LLM server, or move the vector database to a different host, and the frontend’s contract with ExpressJS never has to change.
”Similar Cast and Genre” — Count Vectorization + Cosine Similarity
Not every feature in this app needs an LLM. “Show me movies with a similar cast or genre” is a much simpler retrieval problem, solved with the classic ML techniques from Module 2 rather than a language model:
- Count vectorization — for a selected movie, build a vector out of how often each genre or cast member appears across the movie catalog, the same basic idea as counting word frequency in a sentence.
- Cosine similarity — compare that movie’s vector against every other movie’s vector, and rank by similarity score.
This is deliberately not a job for an LLM call. It’s fast, fully deterministic, needs no retrieval or generation step, and the earlier lessons already gave you both pieces it’s built from: vectors and cosine similarity from Module 2, applied here to genres and cast lists instead of language tokens.
Common mistake: once a chat pipeline exists, reaching for it to power every feature — including ones with no need for natural language generation at all, like “find similar movies.”
An LLM call is slower, more expensive, and less deterministic than a direct similarity computation. “Similar cast and genre” has a clean, well-defined answer computable with count vectorization and cosine similarity in milliseconds — running that through an LLM instead adds latency and cost for no real benefit, and introduces the possibility of a hallucinated or inconsistent result where a deterministic algorithm would have given the same answer every time.
A teammate suggests routing the 'similar cast and genre' feature through the chat LLM instead of the existing count-vectorizer + cosine-similarity function, arguing it would be 'more flexible.' What's the strongest counterargument from this lesson?
Reveal Answer & Explanation
The current approach is fast, deterministic, and already solves the problem cleanly — an LLM call would add latency, cost, and the risk of an inconsistent or hallucinated result for a feature that has one clean, well-defined answer.
“Similar cast and genre” isn’t a language-understanding problem — it’s a numerical similarity computation over count vectors, exactly the kind of task classic ML techniques handle better than a generative model. Flexibility is a real advantage of LLMs elsewhere in this app (the chat feature genuinely benefits from generation), but it’s not a benefit here, because there’s no ambiguity in the task for an LLM’s flexibility to help with — only cost the deterministic version doesn’t pay.
Up Next
Diagram understood — now make it real. The final lesson wires up the ExpressJS proxy’s streaming response, the FastAPI /chat endpoint, and a frontend chat interface that decodes that stream chunk by chunk, and walks through running the whole system end to end.