# stefantudor/on-school-web-application architecture

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

- Interactive diagram: https://gitdiagram.com/stefantudor/on-school-web-application
- Repository: https://github.com/stefantudor/on-school-web-application

## Overview

##### Project Type and Overall Purpose
- This project is a full-stack web application that serves as a digital classroom solution.
- It has multiple modules aimed at different user groups (for example, general presentation vs. school-specific functionality) and even incorporates an intelligent chatbot component (implemented in Python) to assist in some interactions.
- The README hints at a digital classroom system, so expect functionalities like user logins, schedules, news, chat, and potentially education management features.

##### Key Directories and File Structure
- There are two main “apps” modules:
- The “apps/presentation” module appears designed for general site presentation. It follows an MVC-like pattern with dedicated files for controllers (data, registration), models, and viewers (templates including header, footer, homepage, and registration pages).
- The “apps/school” module is a more specific application area (likely for school administrative tasks, teacher/parent interfaces, and student functionalities). It also uses an MVC pattern, with multiple controllers for roles such as login, teacher, parent, and a wide range of viewers providing different layouts and partial views (e.g., different menus and footers).
- The “chatbotBrain” directory contains Python scripts and files that appear to handle chatbot functionalities. This includes:
- Training scripts (train.py, searchWiki.py, ask.py) – which indicate machine learning model training and query handling.
- Model files generated by TensorFlow/TFLearn (model.tflearn.*) and associated training data (train.labels, train.words).
- A server file (server.py) that could act as an independent microservice.
- Other important folders:
- “assets” contains static resources such as CSS, JavaScript, and images for the frontend.
- “includes” provides common PHP functions (functions.php and a JSON file for intents) shared across the application.
- The root index.php likely serves as the front controller or landing page tying everything together.

##### Main Components and Their Interactions
- Client/Web Browser: Initiates requests via the root (index.php) and interacts with frontend assets.
- Presentation Module (apps/presentation):
- Handles general public views and user registrations.
- Utilizes controllers for data handling and registration.
- Renders content through viewers and partial template files (header, footer, etc.).
- School Module (apps/school):
- Provides more specialized interfaces for school-related operations (login, calendar, note viewing, teacher/parent portals, etc.).
- Contains API endpoints (e.g., api-chatbot.php, api-train-chatbot.php) to integrate with external functionality – likely connecting to or invoking the chatbotBrain service.
- Follows the MVC pattern similarly to the presentation module.
- Chatbot Service (chatbotBrain):
- A distinct service built in Python, handling chatbot interactions.
- Responsible for processing natural language queries, training models, and replying to API calls from the main PHP application.
- May interact with external resources (like Wikipedia via searchWiki.py) for enriched responses.
- Shared Components:
- “includes” offer common functions and configurations.
- “assets” are statically served to ensure consistency in UI/UX across modules.

##### Instructing Specific Elements
- If possible, annotate any communication protocols or key integration points (e.g., HTTP REST calls between server and chatbot microservice).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    Browser["Web Browser"]:::frontend
    indexPhp["PHP Front Controller"]:::php

    Browser --> indexPhp

    %% Shared Components
    Assets["Static Assets"]:::shared
    Includes["Common Utilities"]:::shared

    indexPhp --> Assets
    indexPhp --> Includes
    Browser --> Assets

    %% Presentation Module Subgraph
    subgraph "Presentation Module (apps/presentation)"
        direction TB
        Pres_Controllers["Controllers"]:::php
        DataCtrl["Data Controller"]:::php
        RegisterCtrl["Register Controller"]:::php
        Pres_Model["Model"]:::php
        Pres_Viewers["Viewers/Templates"]:::php
        Homepage["Homepage"]:::php
        Inregistrare["Registration"]:::php
        Header["Header"]:::php
        FooterSlim["Footer Slim"]:::php
    end

    %% Connections in Presentation Module
    indexPhp --> Pres_Controllers
    Pres_Controllers --> DataCtrl
    Pres_Controllers --> RegisterCtrl
    Pres_Controllers --> Pres_Model
    Pres_Controllers --> Pres_Viewers
    Pres_Viewers --> Homepage
    Pres_Viewers --> Inregistrare
    Pres_Viewers --> Header
    Pres_Viewers --> FooterSlim
    Pres_Model --> Includes

    %% School Module Subgraph
    subgraph "School Module (apps/school)"
        direction TB
        School_API["API Endpoints"]:::php
        API_Chatbot["Chatbot API"]:::php
        API_Train["Train Chatbot API"]:::php
        School_Controller["Controllers"]:::php
        LoginCtrl["Login Controller"]:::php
        ParinteCtrl["Parinte Controller"]:::php
        ProfesorCtrl["Profesor Controller"]:::php
        DataCtrl_School["Data Controller"]:::php
        School_Model["Model"]:::php
        School_Viewers["Viewers/Templates"]:::php
        LoginView["Login View"]:::php
        CalendarView["Calendar View"]:::php
        ChatPartial["Chat Partial Views"]:::php
    end

    %% Connections in School Module
    indexPhp --> School_Controller
    School_Controller --> LoginCtrl
    School_Controller --> ParinteCtrl
    School_Controller --> ProfesorCtrl
    School_Controller --> DataCtrl_School
    School_Controller --> School_Model
    School_Controller --> School_Viewers
    School_Viewers --> LoginView
    School_Viewers --> CalendarView
    School_Viewers --> ChatPartial

    School_API --> API_Chatbot
    School_API --> API_Train
    School_Model --> Includes

    %% Link between School Module and Chatbot Service
    API_Chatbot -->|"HTTPREST"| Python_Server
    API_Train -->|"HTTPREST"| Python_Server

    %% Chatbot Service Subgraph
    subgraph "Chatbot Service (chatbotBrain)"
        direction TB
        Python_Train["train.py"]:::python
        Python_Ask["ask.py"]:::python
        Python_Server["server.py"]:::python
        Python_Search["searchWiki.py"]:::python
        Python_Model["TFLearnModelArtifacts"]:::python
        Python_TrainingData["TrainingDataFiles"]:::python
    end

    %% Click Events for Presentation Module
    click indexPhp "https://github.com/stefantudor/on-school-web-application/blob/master/index.php"
    click DataCtrl "https://github.com/stefantudor/on-school-web-application/blob/master/apps/presentation/controllers/data_controller.php"
    click RegisterCtrl "https://github.com/stefantudor/on-school-web-application/blob/master/apps/presentation/controllers/register_controller.php"
    click Pres_Model "https://github.com/stefantudor/on-school-web-application/blob/master/apps/presentation/models/model.php"
    click Homepage "https://github.com/stefantudor/on-school-web-application/blob/master/apps/presentation/viewers/homepage.php"
    click Inregistrare "https://github.com/stefantudor/on-school-web-application/blob/master/apps/presentation/viewers/inregistrare.php"
    click Header "https://github.com/stefantudor/on-school-web-application/blob/master/apps/presentation/viewers/_parts/header.php"
    click FooterSlim "https://github.com/stefantudor/on-school-web-application/blob/master/apps/presentation/viewers/_parts/footer-slim.php"

    %% Click Events for School Module
    click LoginCtrl "https://github.com/stefantudor/on-school-web-application/blob/master/apps/school/controllers/login_controller.php"
    click ParinteCtrl "https://github.com/stefantudor/on-school-web-application/blob/master/apps/school/controllers/parinte_controller.php"
    click ProfesorCtrl "https://github.com/stefantudor/on-school-web-application/blob/master/apps/school/controllers/profesor_controller.php"
    click DataCtrl_School "https://github.com/stefantudor/on-school-web-application/blob/master/apps/school/controllers/data_controller.php"
    click School_Model "https://github.com/stefantudor/on-school-web-application/blob/master/apps/school/models/model.php"
    click API_Chatbot "https://github.com/stefantudor/on-school-web-application/blob/master/apps/school/api-chatbot.php"
    click API_Train "https://github.com/stefantudor/on-school-web-application/blob/master/apps/school/api-train-chatbot.php"

    %% Click Events for Chatbot Service
    click Python_Train "https://github.com/stefantudor/on-school-web-application/blob/master/chatbotBrain/train.py"
    click Python_Ask "https://github.com/stefantudor/on-school-web-application/blob/master/chatbotBrain/ask.py"
    click Python_Server "https://github.com/stefantudor/on-school-web-application/blob/master/chatbotBrain/server.py"
    click Python_Search "https://github.com/stefantudor/on-school-web-application/blob/master/chatbotBrain/searchWiki.py"

    %% Click Events for Shared Components
    click Assets "https://github.com/stefantudor/on-school-web-application/tree/master/assets"
    click Includes "https://github.com/stefantudor/on-school-web-application/blob/master/includes/functions.php"

    %% Styles
    classDef frontend fill:#fce,stroke:#333,stroke-width:2px;
    classDef php fill:#ccf,stroke:#333,stroke-width:2px;
    classDef python fill:#cfc,stroke:#333,stroke-width:2px;
    classDef shared fill:#ffc,stroke:#333,stroke-width:2px;
```
