How dinakar-s/linguamentor works
Main Components
• Frontend: The Streamlit interface (ui.py) where users interact with the chatbot.
• Backend API: The FastAPI server (app.py) managing API endpoints and core logic.
• Database: The SQLite database (mistakes.db) along with db.py that handles all database operations (logging user mistakes, retrieval for feedback).
• AI Integration: The external language model services (e.g., OpenRouter AI or DeepSeek) used for processing language and generating feedback.
• Prompt Template Module: The prompt_templates.py file, which centralizes the construction of prompts or dialogues that interface with the external AI.
Out Relationships and Interactions
• User Interaction: Users interact with the chatbot via the Streamlit UI.
• Data Flow: The UI captures user inputs and sends them to the backend API.
• API Processing: The FastAPI server receives requests, utilizes the prompt_templates module to generate appropriate queries, and interfaces with the external AI service (via the Requests library) for language understanding and mistake correction.
• Database Logging: Any user mistakes detected or session data required for progress tracking is stored or retrieved from the SQLite database (managed by db.py and persisted in mistakes.db).
• Response Flow: Corrected responses or expert feedback is then returned through the API and rendered in the UI.
Architectural Patterns and Design Principles
• Separation of Concerns: Clearly split between frontend (Streamlit UI), backend (FastAPI server), and database (SQLite). Each component has a distinct responsibility.
• API-Centric Communication: The UI uses API calls to interact with the FastAPI backend, which in turn orchestrates interactions with external service APIs.
• Integration Layer: The prompt_templates serve as a middleware/component to standardize the prompts for the language model.
Relevant Technologies/Frameworks
• Backend: FastAPI.
• Frontend: Streamlit.
• Database: SQLite.
• External Services: OpenRouter AI/DeepSeek.
• Additional Libraries: Requests (for API communication), along with any Python runtime configurations seen in requirements.txt.
• Use clear labels for each component (e.g., “Streamlit UI”, “FastAPI Backend”, “SQLite Database”, “External AI Service”, “Prompt Templates”).
• From the user to the Streamlit UI,
• From the UI to the FastAPI backend,
• From FastAPI to both the external AI service (for processing corrections) and the database (for logging and retrieval),
• Rectangles for core components (UI, API, Database),