# supriyadutta167/to-do-app architecture

> Architecture diagram of the GitHub repository supriyadutta167/to-do-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/supriyadutta167/to-do-app
- Repository: https://github.com/supriyadutta167/to-do-app

## Overview

##### Project type and purpose
- This is a classic full‐stack LAMP web application: a To-Do List app built with PHP on the backend, MySQL as the database, and HTML/CSS/JavaScript (jQuery) on the frontend.
- Purpose: let users register/login, then add/edit/delete/search tasks in real time via AJAX, with light/dark mode and responsive UI.

##### File structure
Top-level:
- ajax/ – AJAX “API” endpoints (add, delete, update, get, search tasks; login; register)
- assets/css, assets/js – static frontend resources (style.css, script.js)
- config/database.php – DB connection setup
- includes/auth.php, includes/session.php – authentication/session logic
- index.php, register.php, dashboard.php, logout.php – page entry points
- sql/database.sql – DB schema

Pattern:
- Frontend pages (index, register, dashboard) load assets and include the session/auth logic.
- script.js drives UI events and issues AJAX calls to the PHP endpoints.
- Each AJAX script uses config/database.php to talk to MySQL.

##### README for additional insights
- Tech stack confirms the LAMP + jQuery/AJAX stack.
- Features list highlights the real-time interactions (AJAX) and security (encrypted passwords).

a. Main components
1. Client Browser (UI Layer):
- HTML pages (Login, Register, Dashboard)
- CSS (style.css)
- JS/jQuery (script.js)
2. Web Server (Application Layer):
- PHP page controllers (index.php, register.php, dashboard.php, logout.php)
- AJAX endpoints (ajax/*.php)
- Auth/session modules (includes/auth.php, includes/session.php)
- DB config module (config/database.php)
3. Database Layer:
- MySQL server (tables from sql/database.sql)
b. Relationships & data flows
- UI events → script.js → AJAX request → PHP endpoint → DB query/update → JSON response → script.js → UI update
- Login/Register flows go through auth.php/session.php modules.
- Dashboard page loads initial HTML then uses GET AJAX to fetch todos and subsequent CRUD calls.
c. Architectural patterns & principles
- Layered architecture: Presentation (HTML/CSS/JS), Application (PHP logic), Data (MySQL).
- Separation of concerns:
- AJAX folder as API layer
- includes/ for auth/session logic
- config/ for environment setup
- Stateless HTTP + stateful session management.
d. Key technologies
- Frontend: HTML5, CSS3, jQuery
- Backend: PHP 7+
- Data store: MySQL
- AJAX for asynchronous calls

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client-Side Layer
    subgraph "Client-Side"
        PageIndex["index.php"]:::client
        PageRegister["register.php"]:::client
        PageDashboard["dashboard.php"]:::client
        Style["assets/css/style.css"]:::client
        Script["assets/js/script.js"]:::client
    end

    %% Server-Side Layer
    subgraph "Server-Side"
        subgraph "Page Controllers"
            CtrlIndex["index.php"]:::server
            CtrlRegister["register.php"]:::server
            CtrlDashboard["dashboard.php"]:::server
            CtrlLogout["logout.php"]:::server
        end
        subgraph "AJAX API Endpoints"
            AddTodo["add_todo.php"]:::server
            DeleteTodo["delete_todo.php"]:::server
            GetTodos["get_todos.php"]:::server
            LoginAJAX["login.php"]:::server
            RegisterAJAX["register.php"]:::server
            SearchTodos["search_todos.php"]:::server
            UpdateTodo["update_todo.php"]:::server
        end
        subgraph "Services"
            Auth["includes/auth.php"]:::server
            Session["includes/session.php"]:::server
            DBConfig["config/database.php"]:::server
        end
    end

    %% Database Layer
    subgraph "Database"
        MySQL["MySQL Database\n(sql/database.sql)"]:::db
    end

    %% Client to Server Flows
    PageIndex -->|"GET HTML"| CtrlIndex
    PageRegister -->|"GET HTML"| CtrlRegister
    PageDashboard -->|"GET HTML"| CtrlDashboard
    PageIndex --> Style
    PageIndex --> Script
    PageRegister --> Style
    PageRegister --> Script
    PageDashboard --> Style
    PageDashboard --> Script

    %% AJAX Calls
    Script -->|"POST /ajax/add_todo.php"| AddTodo
    Script -->|"POST /ajax/delete_todo.php"| DeleteTodo
    Script -->|"GET /ajax/get_todos.php"| GetTodos
    Script -->|"POST /ajax/search_todos.php"| SearchTodos
    Script -->|"POST /ajax/update_todo.php"| UpdateTodo
    Script -->|"POST /ajax/login.php"| LoginAJAX
    Script -->|"POST /ajax/register.php"| RegisterAJAX

    %% API to Services & DB
    AddTodo -->|"uses"| DBConfig
    DeleteTodo -->|"uses"| DBConfig
    GetTodos -->|"uses"| DBConfig
    SearchTodos -->|"uses"| DBConfig
    UpdateTodo -->|"uses"| DBConfig
    LoginAJAX -->|"validateLogin()"| Auth
    LoginAJAX -->|"uses"| DBConfig
    RegisterAJAX -->|"registerUser()"| Auth
    RegisterAJAX -->|"uses"| DBConfig

    %% Controllers use Auth/Session
    CtrlIndex -->|"checkSession()"| Session
    CtrlRegister -->|"checkSession()"| Session
    CtrlDashboard -->|"checkSession()"| Session
    CtrlLogout -->|"destroySession()"| Session
    CtrlIndex -->|"authcalls"| Auth
    CtrlRegister -->|"authcalls"| Auth
    CtrlDashboard -->|"authcalls"| Auth
    CtrlLogout -->|"authcalls"| Auth

    %% DB Config to DB
    DBConfig -->|"connect()"| MySQL
    MySQL -->|"resultset"| DBConfig

    %% Responses back to Client
    AddTodo -->|"JSON response"| Script
    DeleteTodo -->|"JSON response"| Script
    GetTodos -->|"JSON response"| Script
    SearchTodos -->|"JSON response"| Script
    UpdateTodo -->|"JSON response"| Script
    LoginAJAX -->|"JSON response"| Script
    RegisterAJAX -->|"JSON response"| Script
    CtrlIndex -->|"HTML"| PageIndex
    CtrlRegister -->|"HTML"| PageRegister
    CtrlDashboard -->|"HTML"| PageDashboard

    %% Click Events
    click PageIndex "https://github.com/supriyadutta167/to-do-app/blob/main/index.php"
    click PageRegister "https://github.com/supriyadutta167/to-do-app/blob/main/register.php"
    click PageDashboard "https://github.com/supriyadutta167/to-do-app/blob/main/dashboard.php"
    click Style "https://github.com/supriyadutta167/to-do-app/blob/main/assets/css/style.css"
    click Script "https://github.com/supriyadutta167/to-do-app/blob/main/assets/js/script.js"
    click CtrlIndex "https://github.com/supriyadutta167/to-do-app/blob/main/index.php"
    click CtrlRegister "https://github.com/supriyadutta167/to-do-app/blob/main/register.php"
    click CtrlDashboard "https://github.com/supriyadutta167/to-do-app/blob/main/dashboard.php"
    click CtrlLogout "https://github.com/supriyadutta167/to-do-app/blob/main/logout.php"
    click AddTodo "https://github.com/supriyadutta167/to-do-app/blob/main/ajax/add_todo.php"
    click DeleteTodo "https://github.com/supriyadutta167/to-do-app/blob/main/ajax/delete_todo.php"
    click GetTodos "https://github.com/supriyadutta167/to-do-app/blob/main/ajax/get_todos.php"
    click LoginAJAX "https://github.com/supriyadutta167/to-do-app/blob/main/ajax/login.php"
    click RegisterAJAX "https://github.com/supriyadutta167/to-do-app/blob/main/ajax/register.php"
    click SearchTodos "https://github.com/supriyadutta167/to-do-app/blob/main/ajax/search_todos.php"
    click UpdateTodo "https://github.com/supriyadutta167/to-do-app/blob/main/ajax/update_todo.php"
    click Auth "https://github.com/supriyadutta167/to-do-app/blob/main/includes/auth.php"
    click Session "https://github.com/supriyadutta167/to-do-app/blob/main/includes/session.php"
    click DBConfig "https://github.com/supriyadutta167/to-do-app/blob/main/config/database.php"
    click MySQL "https://github.com/supriyadutta167/to-do-app/blob/main/sql/database.sql"

    %% Styles
    classDef client fill:#e6ffe6,stroke:#2d742d,color:#2d742d;
    classDef server fill:#e6e6ff,stroke:#403dba,color:#403dba;
    classDef db fill:#fff0b3,stroke:#d28c00,color:#d28c00;
```
