Demonstrates how one Agentic runtime backend (src/mvc/model.py), is used in multiple frontends:
- CLI in the Terminal
- Web UI in the Browser
- Telegram Bot via Telegram App
git clone git@github.com:HassanAlgoz/chatbot.git chatbotor
git clone https://github.com/HassanAlgoz/chatbot.git chatbotuv synccp .env.example .env- Get
OPENROUTER_API_KEY MODLE_NAME=Select LLM
In The MVC Design Pattern one decouples the how the interface looks from how it logically processes inputs. This is not always possible, because some features are inherently visual. But, most of the code can be decoupled for reuse across frontends, using this pattern.
model.pyincludes the workflow; the state of the program and the read-write operations- Modify to change the LLM logic
main.pyis the app's entrypoint- Modify when you add new components
config.pyensures we have set all environment variables- Modify when keys are modified in
.env
- Modify when keys are modified in
services/is used for external I/Oservices/llm.pyis the openrouter provider for LLMs
Frontends file structure below.
You notice we have frontends/ folder (s for plural). In general, they control how the program looks and reacts to inputs, and how outputs are rendered (to the extent that the UI allows it).
We have provided three frontends in this repository:
Firstly the Command-line interface in frontends/cli/view.py. You'll notice it contains import textual which is a Terminal UI library.
Secondly, the frontends/web/app.py which is a chainlit web application, ready-made for chatbots such as ours.
Thirdly, the frontends/telegram/bot.py to interface with the Telegram API and App. Find setup instructions below.
uv run python -m mvc.frontends.cli.mainYou should see this in your Terminal:
uv run chainlit run src/mvc/frontends/web/app.py -w-wis for hot-reloading (automatic restart when code updates are saved)
You should see this in your Browser at localhost:8000:
Based on the "From BotFather to 'Hello World'" Tutorial on Telegram.
The Telegram Bot would look like this:
- Open @BotFather.
- Run
/newbotand follow the prompts. - Save the bot token securely.
- Open @BotFather.
- Go to
/mybots-> Your bot ->Edit Bot->Edit Commands. - Add:
start - Start the assistantreset - Reset conversation history
Start the bot process:
uv run python -m mvc.frontends.telegram.main- Send a message to your bot in Telegram to generate updates.
- Test:
/start- Ask a history question and verify model response
- Ask a follow-up question to verify chat memory
/reset- Ask a new question and verify history is reset
- Package your project for deployment.
- Provision a VPS (or equivalent always-on machine).
- Upload project files to the server (e.g., with
scp). - Install runtime dependencies on server.
- Run the bot process on the server.
- The tutorial notes that Telegram does not store processed updates for you.
- If your bot needs persistent state (users/settings/history), add storage (serialization/database).


