# mikalasa/todo-list architecture

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

- Interactive diagram: https://gitdiagram.com/mikalasa/todo-list
- Repository: https://github.com/mikalasa/todo-list

## Overview

##### Project Overview
- The project is a full-stack web application focused on Todo list management with additional features such as a login/registration system, CRUD operations for todos, and a circular statistics display with smooth UI animations.
- It is deployed on an AWS EC2 instance, but also easily runnable locally using XAMPP (or similar LAMP/WAMP stack) with a MySQL database.

##### Main Architectural Components
A. Frontend / User Interface:
- Entry Point: index.php serves as the main landing page.
- Templates: Located in the template/ directory (with subfolders like compoment_template and profile_template) for rendering different parts of the UI (e.g., User_Login_Register, TodoList, Player, Statistics).
- CSS: All presentation styles are managed in the css/ folder (including layout, responsive design, and specific page styles such as for the player and login popup).
- Event Scripts: JavaScript files in the event/ directory handle interactions and animations for various features like login/register actions, todo CRUD operations, statistics display, and overall page responsiveness.

B. Backend / API Endpoints:
- API Structure: The api/ directory contains several subdirectories each representing a specific domain:
- login_register_api: Handles user login, logout, and registration functionalities.
- todo_api: Contains endpoints for creating, editing, deleting, and updating todos.
- statistics_api: Provides data related to statistics (e.g., count differences for todos).
- todo_menu_api: Retrieves categorized lists for different Todo states (live, completed, deleted).
- These endpoints use PHP files (e.g., login.php, register.php, addNew_todo.php, etc.) to process HTTP requests from the frontend.

C. Database:
- The MySQL database is initialized using the todo.sql file.
- The connection details (host, user, password, db) are configured in the index.php file. The database supports CRUD operations to store and retrieve todo items, user information, and possibly statistical data.

D. Static Assets and Utility:
- Utility: The utility/ folder holds common JavaScript functions (e.g., AJAX tool, utility functions) that assist in API communication and other common tasks.
- Data: A JSON file (playlist.json in data/) that likely powers the media player functionality.

##### Relationships & Interactions
- User interactions with the UI trigger events (via JavaScript files in event/) that make AJAX calls to the various API endpoints hosted under the api/ directory.
- The PHP APIs in turn interact with the MySQL database to perform CRUD operations, user authentication, and data retrieval for statistics.
- The frontend consumes the results from these APIs to update the UI (via templates and CSS styling) in real time.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["User Browser"]:::browser

    subgraph "Frontend Layer"
        F1["index.php (Main Landing Page)"]:::frontend
        F2["Templates"]:::frontend
        F3["CSS Styling"]:::frontend
        F4["Event Scripts"]:::frontend
    end

    A --> F1
    F1 --> F2
    F1 --> F3
    F1 --> F4

    subgraph "Backend Layer"
        B1["Login &Registration API"]:::backend
        B2["Todo Operations API"]:::backend
        B3["Statistics API"]:::backend
        B4["Todo Menu API"]:::backend
    end

    %% Frontend Event Scripts trigger backend API calls
    F4 -->|"AJAX"| B1
    F4 -->|"AJAX"| B2
    F4 -->|"AJAX"| B3
    F4 -->|"AJAX"| B4

    %% Database Interaction
    DB["MySQL Database"]:::database
    B1 --> DB
    B2 --> DB
    B3 --> DB
    B4 --> DB

    subgraph "Assets & Utilities"
        S1["Static Assets"]:::static
        S2["Media Data (playlist.json)"]:::static
        U1["Utility Scripts"]:::utility
    end

    %% Frontend uses assets and utilities
    F1 --> U1
    F1 --> S1
    F1 --> S2

    subgraph "Deployment Environments"
        D1["AWS EC2 Deployment"]:::deployment
        D2["Local XAMPP Deployment"]:::deployment
    end

    %% Both Frontend and Backend are deployed in these environments
    F1 --> D1
    F1 --> D2
    B1 --> D1
    B1 --> D2
    B2 --> D1
    B2 --> D2
    B3 --> D1
    B3 --> D2
    B4 --> D1
    B4 --> D2

    %% Click Events for Component Mapping
    click F1 "https://github.com/mikalasa/todo-list/blob/main/index.php"
    click F2 "https://github.com/mikalasa/todo-list/tree/main/template/"
    click F3 "https://github.com/mikalasa/todo-list/tree/main/css/"
    click F4 "https://github.com/mikalasa/todo-list/tree/main/event/"
    click B1 "https://github.com/mikalasa/todo-list/tree/main/api/login_register_api/"
    click B2 "https://github.com/mikalasa/todo-list/tree/main/api/todo_api/"
    click B3 "https://github.com/mikalasa/todo-list/tree/main/api/statistics_api/"
    click B4 "https://github.com/mikalasa/todo-list/tree/main/api/todo_menu_api/"
    click DB "https://github.com/mikalasa/todo-list/blob/main/todo.sql"
    click S1 "https://github.com/mikalasa/todo-list/tree/main/static/"
    click S2 "https://github.com/mikalasa/todo-list/blob/main/data/playlist.json"
    click U1 "https://github.com/mikalasa/todo-list/tree/main/utility/"

    %% Style Classes
    classDef frontend fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef backend fill:#87CEEB,stroke:#333,stroke-width:2px;
    classDef database fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef static fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef utility fill:#E6E6FA,stroke:#333,stroke-width:2px;
    classDef deployment fill:#FFC0CB,stroke:#333,stroke-width:2px;
    classDef browser fill:#D3D3D3,stroke:#333,stroke-width:2px;
```
