{"slug": "how-i-built-a-local-ai-powered-combined-maths-solver-for-my-a-l-preparation", "title": "How I Built a Local AI-Powered Combined Maths Solver for My A/L Preparation", "summary": "A Sri Lankan student preparing for the G.C.E. Advanced Level Combined Mathematics exam built a local, AI-powered problem solver tailored to the national syllabus. The web-based application uses FastAPI for the backend and Google's GenAI SDK for mathematical reasoning, with an SQLite database caching responses to avoid redundant cloud API calls. By caching solved problems locally, the system returns instant answers for repeated queries while only calling the cloud model for new questions.", "body_md": "Hey everyone! 👋\n\nI am a student from Sri Lanka currently preparing to step into the highly intense G.C.E. Advanced Level (A/L) Combined Mathematics stream. Balancing school studies with a passion for programming can be tricky, so I decided to bridge the two worlds.\n\nInstead of just solving math problems on paper, I built a local web-based Combined Mathematics AI Problem Solver tailored to our local syllabus.\n\nBecause this is my very first technical article, I want to pull back the curtain on how I designed the architecture, how the components talk to each other, and why I built it locally on my PC.\n\nStandard AI models are great at general math, but local examinations like the Sri Lankan A/Ls require steps to be structured in a very specific way to match local marking schemes.\n\nMy goal was to create a tool where a student could input a problem, and the application would return a step-by-step breakdown that feels familiar to an A/L student. To make it highly responsive and optimized, I didn't want it relying entirely on slow, repetitive cloud API calls every single time.\n\nHere is the high-level map of how data moves through the system:\n\nInstead of writing one massive, tangled file, I broke the project down into three distinct, manageable layers:\n\nI chose FastAPI to build the engine of this platform. It is lightweight, incredibly fast, and handles asynchronous requests brilliantly. FastAPI acts as the traffic cop it accepts the question from the frontend, packages it securely with specific system instructions, and sends it out.\n\nFor the heavy mathematical reasoning, I hooked the backend up to cloud based Large Language Models using the Google GenAI SDK. To ensure the output matches the local syllabus requirements, the backend injects context like syllabus guidelines and past paper structures directly into the prompt before it hits the AI.\n\nThis is my favorite part of the build. When you are studying, you often re-run or review the exact same math problems. Making an external API call to a cloud model every single time takes seconds and wastes network bandwidth.\n\nTo solve this, I wired up an SQLite database to handle response caching:\n\nWhen a question comes in, FastAPI checks SQLite first.\n\nCache Hit: If the exact problem has been solved before, it pulls the answer instantly from the local database.\n\nCache Miss: If it's a completely new question, it calls Gemini, saves the fresh solution into SQLite for next time, and returns the answer.\n\nAs a student developer, building this was a massive learning curve.\n\nDecoupling Logic: At first, trying to make the web framework, the database queries, and the API requests handle asynchronous paths together felt overwhelming.\n\nThe \"Mysterious Code\" Phenomenon: Looking back at my scripts a few weeks later, I realized how quickly code can become complex! Even when your own syntax starts looking a bit like a foreign language to you, understanding the structural design how data goes in and comes out of your modules is what keeps the project alive.\n\nBuilding this tool taught me that you don't need a massive team or a cloud budget to create something highly functional. By combining a fast Python backend like FastAPI with local SQLite caching, a single developer can build responsive, AI-powered applications right on their own local machine.\n\nThis project is just the beginning for me. While my immediate focus is handling my upcoming academic streams, I plan to keep this local platform as my private playground to test new optimization techniques, learn more about database management, and sharpen my Python skills.\n\nIf you are a student developer building tools to solve your own everyday problems, or if you have any tips on backend optimization, I’d love to hear your thoughts in the comments below! 🚀", "url": "https://wpnews.pro/news/how-i-built-a-local-ai-powered-combined-maths-solver-for-my-a-l-preparation", "canonical_source": "https://dev.to/kulaja_kithsahan36/how-i-built-a-local-ai-powered-combined-maths-solver-for-my-al-preparation-3lo3", "published_at": "2026-05-29 16:56:26+00:00", "updated_at": "2026-05-29 17:12:17.468592+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-tools", "ai-products", "natural-language-processing", "large-language-models"], "entities": ["FastAPI", "G.C.E. Advanced Level", "Sri Lanka"], "alternates": {"html": "https://wpnews.pro/news/how-i-built-a-local-ai-powered-combined-maths-solver-for-my-a-l-preparation", "markdown": "https://wpnews.pro/news/how-i-built-a-local-ai-powered-combined-maths-solver-for-my-a-l-preparation.md", "text": "https://wpnews.pro/news/how-i-built-a-local-ai-powered-combined-maths-solver-for-my-a-l-preparation.txt", "jsonld": "https://wpnews.pro/news/how-i-built-a-local-ai-powered-combined-maths-solver-for-my-a-l-preparation.jsonld"}}