How nnboru/mathbot works
Project Type & Purpose
• Mathbot is a full-stack, Flask-based web application.
• Purpose: provide an interactive chatbot in the CS domain, plus two external utilities (CSV Analyser and Equation Plotter hosted separately).
File Structure
• Top-level files:
• app.py – Flask application entrypoint and request router
• scrap.py – web-scraping logic
• nn/ – scripted-bot logic (neural-net or rule-based responses)
• requirements.txt, Procfile, run.bat – deployment/build configs
• Front-end assets:
• static/ – CSS & JS (botbase.css/js, index.css/js)
• templates/ – HTML views (index.html, update.html)
Key Architecture Insights from README
• Three logical “layers” inside the backend:
1. Scripted bot layer (handles basic chat & updates)
2. Math evaluator layer (parses/calculates expressions)
3. Scraper layer (search & scrape from Google, GeeksforGeeks, CP-Algorithms)
Main Components & Interactions
a. Frontend
• Browser: HTML/JS/CSS delivered from static/ & templates/
• Two views: Chat interface (index.html) and Update interface (update.html)
b. Backend (Flask app.py)
• Routes requests to the correct layer based on input type
c. Core Processing Layers
1. Scripted Bot (nn/ folder)
2. Math Evaluator (in app.py or a helper module)
3. Scraper (scrap.py using requests & BeautifulSoup)
d. External Services
• Google search (HTTP API by scraping search results)
• GeeksforGeeks & CP-Algorithms (scrape sub-sites)
• Separate micro-apps: CSV Analyser & Equation Plotter (hosted externally)
Architectural Patterns & Tech
• Layered architecture: Presentation → Business Logic → Integration
• MVC-style separation:
• Views (templates/)
• Controllers (Flask routes in app.py)
• Models/Services (nn/, math parser, scrap.py)
• Technologies: Python 3.x, Flask, requests, BeautifulSoup, HTML/CSS/JS