# chouaib100/todoapp-php architecture

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

- Interactive diagram: https://gitdiagram.com/chouaib100/todoapp-php
- Repository: https://github.com/chouaib100/todoapp-php

## Overview

##### Project type and purpose
- This is a PHP-based full-stack MVC web application (a ToDo app) that demonstrates both SQL injection vulnerabilities and secure‐coding practices.
- README confirms it uses MySQL and is intended as an educational tool in web security.

##### File structure
- Top-level directories:
– App/ (contains MVC folders)
– App/public/ (webroot/front controller + assets)
– .idea/ (IDE settings)
- Inside App/:
– config/ (database.php, routes.php) → DB credentials & route definitions
– controllers/ (AuthController, ProfileController, TaskController) → business logic
– models/ (User.php, Task.php) → data‐access layer
– views/ (auth/, profile/, tasks/) → presentation templates
- App/public/:
– .htaccess → URL rewriting to index.php
– index.php → Front Controller
– assets/css, assets/js → static files
- Pattern: Classic MVC with a Front Controller and layered separation (presentation, logic, data).

##### README for additional insights
- Confirms purpose: showcase SQL injection vulnerabilities → secure vs insecure queries.
- Technology stack: PHP (≥7), MySQL, Apache (with mod_rewrite), HTML/CSS/JS.

##### Elements
- Blue for presentation (Browser, Views)
- Green for logic (Controllers, Router)
- Orange for data (Models, DB)
– Callouts highlighting vulnerable SQL vs parameterized query paths
– Notes indicating config files feeding routing and DB connections

##### Detail
– Include the public/assets sub-systems delivering CSS/JS.
– Show how config/database.php credentials are consumed by Models.
– Represent session store interactions in AuthController.
– If desired, layer environment boundaries (development vs production) and show deployment artifact (App folder + public) on the server.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Browser["Client Browser"]:::presentation
        Styles["styles.css"]:::presentation
        Script["script.js"]:::presentation
        LoginView["Login View"]:::presentation
        RegisterView["Register View"]:::presentation
        ProfileEditView["Profile Edit View"]:::presentation
        TaskListView["Task List View"]:::presentation
        TaskCreateView["Task Create View"]:::presentation
    end

    %% Logic Layer
    subgraph "Logic Layer"
        WebServer["Apache / PHP Runtime"]:::logic
        FrontController["Front Controller\nindex.php"]:::logic
        Router["Routing Layer\nroutes.php"]:::logic
        AuthController["AuthController"]:::logic
        ProfileController["ProfileController"]:::logic
        TaskController["TaskController"]:::logic
    end

    %% Data Layer
    subgraph "Data Layer"
        DBConfig["DB Config\ndatabase.php"]:::data
        UserModel["User Model"]:::data
        TaskModel["Task Model"]:::data
        DB[(MySQL Database)]:::data
    end

    %% Flows
    Browser -->|"HTTP Request"| WebServer
    Browser -->|"GET CSS/JS"| Styles
    Browser -->|"GET JS"| Script

    WebServer -->|"mod_rewrite .htaccess"| FrontController
    FrontController -->|"load routes"| Router
    Router -->|"dispatch"| AuthController
    Router -->|"dispatch"| ProfileController
    Router -->|"dispatch"| TaskController

    AuthController -->|"uses DB Config"| DBConfig
    ProfileController -->|"uses DB Config"| DBConfig
    TaskController -->|"uses DB Config"| DBConfig

    AuthController -->|"calls User Model"| UserModel
    ProfileController -->|"calls User Model"| UserModel
    TaskController -->|"calls Task Model"| TaskModel

    UserModel -->|"vulnerable SQL"| DB
    UserModel -->|"secure prepared statement"| DB
    TaskModel -->|"vulnerable SQL"| DB
    TaskModel -->|"secure prepared statement"| DB

    AuthController -->|"returns view data"| LoginView
    AuthController -->|"returns view data"| RegisterView
    ProfileController -->|"returns view data"| ProfileEditView
    TaskController -->|"returns view data"| TaskListView
    TaskController -->|"returns view data"| TaskCreateView

    LoginView -->|"HTML Response"| Browser
    RegisterView -->|"HTML Response"| Browser
    ProfileEditView -->|"HTML Response"| Browser
    TaskListView -->|"HTML Response"| Browser
    TaskCreateView -->|"HTML Response"| Browser

    %% Click Events
    click Styles "https://github.com/chouaib100/todoapp-php/blob/main/App/public/assets/css/styles.css"
    click Script "https://github.com/chouaib100/todoapp-php/blob/main/App/public/assets/js/script.js"
    click WebServer "https://github.com/chouaib100/todoapp-php/blob/main/App/public/.htaccess"
    click FrontController "https://github.com/chouaib100/todoapp-php/blob/main/App/public/index.php"
    click Router "https://github.com/chouaib100/todoapp-php/blob/main/App/config/routes.php"
    click DBConfig "https://github.com/chouaib100/todoapp-php/blob/main/App/config/database.php"
    click AuthController "https://github.com/chouaib100/todoapp-php/blob/main/App/controllers/AuthController.php"
    click ProfileController "https://github.com/chouaib100/todoapp-php/blob/main/App/controllers/ProfileController.php"
    click TaskController "https://github.com/chouaib100/todoapp-php/blob/main/App/controllers/TaskController.php"
    click UserModel "https://github.com/chouaib100/todoapp-php/blob/main/App/models/User.php"
    click TaskModel "https://github.com/chouaib100/todoapp-php/blob/main/App/models/Task.php"
    click LoginView "https://github.com/chouaib100/todoapp-php/blob/main/App/views/auth/login.php"
    click RegisterView "https://github.com/chouaib100/todoapp-php/blob/main/App/views/auth/register.php"
    click ProfileEditView "https://github.com/chouaib100/todoapp-php/blob/main/App/views/profile/edit.php"
    click TaskListView "https://github.com/chouaib100/todoapp-php/blob/main/App/views/tasks/index.php"
    click TaskCreateView "https://github.com/chouaib100/todoapp-php/blob/main/App/views/tasks/create.php"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#000,color:#000
    classDef logic fill:#90EE90,stroke:#000,color:#000
    classDef data fill:#FFA500,stroke:#000,color:#000
```
