CodeMate
Local Flask and Transformers Coding Assistant
Overview
A self-hosted Flask web assistant backed by PyTorch and Hugging Face transformers that answers coding and debugging questions with local inference, user accounts and saved conversation history.
The problem
Developers lose focus switching between the editor, documentation and search tabs while debugging, and hosted assistants raise privacy questions for proprietary code.
The solution
Built a Flask application with flask-login authentication and SQLAlchemy persistence that runs transformer inference locally. Users sign in, ask coding questions, and keep a history of past answers, all without an external API key.
Project gallery
Technical architecture
Flask web app with local transformer inference and user-scoped storage
Auth & Accounts
flask-login sessions with hashed credentials and per-user conversation isolation.
Inference Service
Loads a Hugging Face model through PyTorch and serves generation requests with input length limits.
Conversation Store
SQLAlchemy models persist prompts and answers so users can revisit earlier debugging sessions.
Web Interface
Server-rendered templates with a code-friendly reading layout and copy-to-clipboard answers.
Methodology
- Chose a small instruction-tuned model that could run without a dedicated GPU
- Added prompt length limits and timeouts so a long request cannot stall the server
- Scoped every conversation row to the signed-in user
- Kept answers in a readable code layout rather than raw model output
Results & impact
Key impact
- Gave developers a private assistant for proprietary code questions
- Demonstrated full-stack delivery around a local ML model
- Produced a reusable auth plus inference pattern for later projects
Challenges & solutions
CPU-Only Inference
Limited context length and streamed tokens so responses stayed responsive without a GPU
Model Output Quality
Added instruction templates and a system preamble tuned for code explanation