u/AdorableHovercraft

When Apple first released its Foundation Models framework, my friend and I were excited about the possibilities of an on-device LLM. We wanted to create a trivia game and thought that might be a great application of the technology. Well, we were quickly disabused of the notion, what with its rampant hallucination and apparently small body of knowledge.

But, even if the model performed better, we also soon realized that such an architecture would not work for a game—which required all players to see the same questions, ensure that questions weren't repeated, etc. Essentially, we needed a full stack.

I had built app back ends previously using PHP running on EC2, and there's nothing wrong with that classic LAMP stack. But for this project, I wanted to embrace a design similar to the ones I had used in my day job as an enterprise software engineer, and that's what lead me to FastAPI running on AWS Lambda. I really enjoyed embracing the separation of concerns that FastAPI embodies: schemas for the interface, routers for the REST API route definitions, crud for the business logic and DB queries, models for the SQLalchemy ORM. Throw in Alembic for DB versioning, pytest for unit testing, and Serverless for IaC, and you have a pretty robust back end. We ended up using OpenAI's gpt-5-nano model, a very cost effective and reasonably performant LLM for our trivia question generation.

The back end will eventually support multiple flavors of our trivia game, but the first is a daily news variant that we just launched on the App Store. Please check it out and let us know what you think. Or if you have questions about or would like me to discuss any aspects of the back end, I'd be happy to. Enjoy!

u/AdorableHovercraft — 12 days ago