# mahirqt/askly architecture

> Architecture diagram of the GitHub repository mahirqt/askly, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mahirqt/askly
- Repository: https://github.com/mahirqt/askly

## Overview

##### Project type and purpose
- This is a full-stack, Flask-based web application (“Askly-doubt-solving-platform”) that allows students to post doubts (text/images), routes them through an AI/NLP logic layer for parsing/classification, persists them to a database (SQLite by default, optional MongoDB), and renders HTML/CSS-based pages for users and teachers.

##### File structure
- Top level:
- app.py – Flask application entrypoint (all routes, AI integration, database access)
- instance/database.db – SQLite DB file (persisted data)
- requirements.txt – Python dependencies
- .gitignore
- Directories:
- templates/ – Jinja2 HTML templates for views (ask_doubt, chat, dashboard, etc.)
- static/ – CSS, JS, uploaded images
- No separate “frontend” or “backend” repos; it’s a monolithic Flask web server serving both API and UI.

##### Key insights from README
- Tech stack: Python/Flask backend, SQLite or MongoDB, HTML/CSS front-end, NLP-based AI logic, Postman for API testing.
- Features: ask doubts (text/image), AI-powered responses, categorization, real-time tracking, mentor connection (future).

##### Main components
a. Client (Web Browser) – end-user interface (students, teachers)
b. Flask Web Server – app.py:
- Routing & Controllers (HTTP endpoints for ask, solve, chat, library, dashboards)
- Business Logic / AI Layer (NLP message parser, classification, smart response generator)
- File-upload handler (static/uploads)
c. Database – SQLite (instance/database.db) or MongoDB
d. Static File Store – CSS, JS, uploaded images
e. (Optional) External AI Service or Microservice – if NLP is offloaded to a separate service or 3rd-party API
f. (Future) Mentor matching service or Notification subsystem

##### Relationships & interactions
- Within Flask:
- Controller calls AI Logic module → returns parsed/question classification → persists to DB
- Controller reads/writes to database
- Controller renders Jinja template + static assets → HTTP response back to Browser
- File uploads: Browser → Flask upload endpoint → Static/uploads folder
- (Optional) Flask → External AI API over HTTPS → AI response

##### Architectural patterns & design principles
- Monolithic MVC:
- Models: DB schemas (doubts, users)
- Views: Jinja templates + static resources
- Controllers: Flask route handlers
- Separation of concerns: routing, business logic (AI), persistence, presentation
- Future extensibility: extract AI logic into microservice; swap SQLite for MongoDB

##### Relevant technologies & frameworks
- Flask (WSGI server, routing, Jinja templating)
- SQLite / MongoDB driver (pymongo or SQLAlchemy)
- Python NLP libraries or external AI API (e.g., spaCy, custom model, OpenAI)
- HTML/CSS for UI; Postman for API testing

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Web Browser (Students/Teachers)"]:::client

    %% Server Layer
    subgraph "Flask Application" 
        direction TB
        Routing["Routing & Controllers"]:::backend
        AI["AI/NLP Engine"]:::backend
        Persistence["Persistence"]:::backend
        Templates["Jinja Templates"]:::backend
        StaticAssets["Static Assets"]:::backend
        Uploads["File Upload Handler\n(static/uploads/)"]:::backend
    end

    %% Data Stores
    Database["SQLite Database\n(instance/database.db)"]:::datastore
    ExternalAI["External AI Service\n(Optional)"]:::external

    %% Flows
    Browser -->|"HTTP GET/POST"| Routing
    Routing -->|"AI classify(doubt_text)"| AI
    AI -->|"classification/result"| Routing
    Routing -->|"INSERT/SELECT"| Database
    Routing -->|"renders with Templates + Static"| Browser
    Browser -->|"POST /upload"| Uploads
    Uploads -->|"store files"| StaticAssets
    Routing -->|"optional API call"| ExternalAI
    ExternalAI -->|"AI response"| Routing

    %% Click Events
    click Routing "https://github.com/mahirqt/askly/blob/main/app.py"
    click Database "https://github.com/mahirqt/askly/blob/main/instance/database.db"
    click StaticAssets "https://github.com/mahirqt/askly/blob/main/static/style.css"
    click Uploads "https://github.com/mahirqt/askly/tree/main/static/uploads/"
    click Templates "https://github.com/mahirqt/askly/tree/main/templates/"
    click BaseHTML "https://github.com/mahirqt/askly/blob/main/templates/base.html"
    click AskDoubt "https://github.com/mahirqt/askly/blob/main/templates/ask_doubt.html"
    click SolveDoubt "https://github.com/mahirqt/askly/blob/main/templates/solve_doubt.html"
    click DoubtDetail "https://github.com/mahirqt/askly/blob/main/templates/doubt_detail.html"
    click DoubtLibrary "https://github.com/mahirqt/askly/blob/main/templates/doubt_library.html"
    click Chat "https://github.com/mahirqt/askly/blob/main/templates/chat.html"
    click StudentCommunity "https://github.com/mahirqt/askly/blob/main/templates/student_community.html"
    click TeacherDashboard "https://github.com/mahirqt/askly/blob/main/templates/teacher_dashboard.html"
    click Login "https://github.com/mahirqt/askly/blob/main/templates/login.html"
    click Register "https://github.com/mahirqt/askly/blob/main/templates/register.html"
    click Redeem "https://github.com/mahirqt/askly/blob/main/templates/redeem.html"
    click Dobby "https://github.com/mahirqt/askly/blob/main/templates/dobby.html"

    %% Styles
    classDef client fill:#D0E6FF,stroke:#0366D6,color:#0366D6;
    classDef backend fill:#E6FFE6,stroke:#28A745,color:#28A745;
    classDef datastore fill:#FFF4E6,stroke:#D97706,color:#D97706;
    classDef external fill:#F3E6FF,stroke:#6F42C1,color:#6F42C1;
```
