# chikashishirozu/calender017 architecture

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

- Interactive diagram: https://gitdiagram.com/chikashishirozu/calender017
- Repository: https://github.com/chikashishirozu/calender017

## Overview

##### Project type and purpose
- This is a single-repository, monolithic PHP web application (“calender017”) that provides user registration, login, calendar display/editing, password reset, and reminder functionality.
- It supports two data stores: a SQLite file (calendar.db / new_calendar.db) and a MySQL/MariaDB server.

##### File structure
- Top level scripts (index.php, home.php, login.php, register.php, reset_password.php, logout.php) act as “controllers + views.”
- Utility/connectors:
- db.php (SQLite connector)
- mysql_db.php (MySQL/MariaDB connector)
- api.php (AJAX/JSON endpoints)
- remind_user.php (reminder/cron job script)
- myuser01.php, myuser02.php, myuser03.php (data‐seeding / user setup)
- Static assets: login.html, register.html, script.js, current-time018.js
- Database files: calendar.db, new_calendar.db plus external MariaDB server accessed via mysql_db.php

##### Extract insights from the README
- Runs under built-in PHP server or Apache+PHP-FPM
- Requires PHP 8.3 plus extensions, and either SQLite3 or MySQL/MariaDB
- Provides instructions for Windows and Linux/Apache deployments

##### Main components
a. Client (Web Browser)
- Renders HTML pages
- Executes script.js and current-time018.js for dynamic behavior
- Sends HTTP(S) requests to PHP endpoints (login.php, api.php, etc.)
b. Web Server / Application Layer
- PHP interpreter (built-in server or Apache + mod_php/php-fpm)
- Entry-point scripts grouped by function:
– Authentication: login.php, register.php, logout.php, reset_password.php
– Calendar UI & API: index.php, home.php, api.php
– Background: remind_user.php (cron/CLI)
- Shared libraries: db.php, mysql_db.php for data-access abstraction
c. Data Stores
- SQLite (calendar.db or new_calendar.db) – flat-file DB
- MySQL / MariaDB – server-based relational DB
d. Optional: Cron/CLI Scheduler
- Executes remind_user.php and myuser0X.php scripts
e. External Dependencies
- PHP runtime and extensions
- Web server (Apache/httpd)
- Network for LAN/Internet access

##### Relationships and interactions
- Browser → HTTP request → Web Server / PHP script
- PHP script → calls db.php or mysql_db.php → executes SQL query → returns data → PHP script formats HTML or JSON → response to Browser
- remind_user.php (scheduled by cron or CLI) → reads DB → sends reminder emails or notifications
- myuser0X.php → CLI-driven user setup → writes to DB

##### Architectural patterns and design principles
- Monolithic three-tier architecture (Presentation, Application, Data)
- PHP scripts double as controllers and views (no formal MVC framework)
- Data-access abstraction via two connector modules (db.php, mysql_db.php) to support multiple back ends

##### Detailing components
- Authentication flow: login.html → login.php → mysql_db.php/db.php → DB → session → home.php
- Calendar API flow: index.php/home.php (UI) + script.js → api.php → DB → JSON → UI update
- Registration flow: register.html → register.php → DB → confirmation
- Password reset: reset_password.php → DB → email link
- Reminder job: remind_user.php (cron) → DB → email notifications

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend (Client)"
        direction TB
        LoginHTML["login.html"]:::frontend
        RegisterHTML["register.html"]:::frontend
        ScriptJS["script.js"]:::frontend
        ClockJS["current-time018.js"]:::frontend
    end

    subgraph "Web Server / Application Layer"
        direction TB
        PHP["PHP Interpreter"]:::backend

        subgraph "Authentication"
            direction TB
            LoginPHP["login.php"]:::backend
            RegisterPHP["register.php"]:::backend
            LogoutPHP["logout.php"]:::backend
            ResetPHP["reset_password.php"]:::backend
        end

        subgraph "Calendar UI & API"
            direction TB
            IndexPHP["index.php"]:::backend
            HomePHP["home.php"]:::backend
            APIPHP["api.php"]:::backend
        end

        subgraph "Data Access"
            direction TB
            SQLiteConn["db.php"]:::backend
            MySQLConn["mysql_db.php"]:::backend
        end
    end

    subgraph "Scheduler / CLI"
        direction TB
        RemindPHP["remind_user.php"]:::scheduler
        User1["myuser01.php"]:::scheduler
        User2["myuser02.php"]:::scheduler
        User3["myuser03.php"]:::scheduler
    end

    subgraph "Data Stores"
        direction TB
        SQLiteDB1["calendar.db"]:::data
        SQLiteDB2["new_calendar.db"]:::data
        MySQLDB["MySQL / MariaDB"]:::data
    end

    %% Connections: HTTP flows
    LoginHTML -->|"HTTP/HTTPS"| LoginPHP
    RegisterHTML -->|"HTTP/HTTPS"| RegisterPHP
    ScriptJS -->|"AJAX/HTTP"| APIPHP
    ClockJS -->|"Client Script"| HomePHP

    %% Post-auth navigation
    LoginPHP -->|"redirect"| HomePHP

    %% Backend to DB connectors
    LoginPHP -->|"SQL query"| SQLiteConn
    LoginPHP -->|"SQL query"| MySQLConn
    RegisterPHP -->|"SQL query"| SQLiteConn
    RegisterPHP -->|"SQL query"| MySQLConn
    ResetPHP -->|"SQL query"| SQLiteConn
    ResetPHP -->|"SQL query"| MySQLConn
    IndexPHP -->|"SQL query"| SQLiteConn
    IndexPHP -->|"SQL query"| MySQLConn
    HomePHP -->|"SQL query"| SQLiteConn
    HomePHP -->|"SQL query"| MySQLConn
    APIPHP -->|"SQL query"| SQLiteConn
    APIPHP -->|"SQL query"| MySQLConn

    %% Scheduler flows
    RemindPHP -->|"SQL query"| SQLiteConn
    RemindPHP -->|"SQL query"| MySQLConn
    User1 -->|"SQL query"| SQLiteConn
    User2 -->|"SQL query"| SQLiteConn
    User3 -->|"SQL query"| SQLiteConn

    %% Connectors to Data Stores
    SQLiteConn -->|"Reads/Writes"| SQLiteDB1
    SQLiteConn -->|"Reads/Writes"| SQLiteDB2
    MySQLConn -->|"Reads/Writes"| MySQLDB

    %% Click Events
    click LoginHTML "https://github.com/chikashishirozu/calender017/blob/main/login.html"
    click RegisterHTML "https://github.com/chikashishirozu/calender017/blob/main/register.html"
    click ScriptJS "https://github.com/chikashishirozu/calender017/blob/main/script.js"
    click ClockJS "https://github.com/chikashishirozu/calender017/blob/main/current-time018.js"
    click LoginPHP "https://github.com/chikashishirozu/calender017/blob/main/login.php"
    click RegisterPHP "https://github.com/chikashishirozu/calender017/blob/main/register.php"
    click LogoutPHP "https://github.com/chikashishirozu/calender017/blob/main/logout.php"
    click ResetPHP "https://github.com/chikashishirozu/calender017/blob/main/reset_password.php"
    click IndexPHP "https://github.com/chikashishirozu/calender017/blob/main/index.php"
    click HomePHP "https://github.com/chikashishirozu/calender017/blob/main/home.php"
    click APIPHP "https://github.com/chikashishirozu/calender017/blob/main/api.php"
    click SQLiteConn "https://github.com/chikashishirozu/calender017/blob/main/db.php"
    click MySQLConn "https://github.com/chikashishirozu/calender017/blob/main/mysql_db.php"
    click SQLiteDB1 "https://github.com/chikashishirozu/calender017/blob/main/calendar.db"
    click SQLiteDB2 "https://github.com/chikashishirozu/calender017/blob/main/new_calendar.db"
    click MySQLDB "https://github.com/chikashishirozu/calender017/blob/main/mariadb_calendar015_setting.txt"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef backend fill:#D0F5D6,stroke:#28a745,color:#155724
    classDef data fill:#FFE4B2,stroke:#e86600,color:#663c00
    classDef scheduler fill:#E8D0FF,stroke:#6f42c1,color:#4a235a
```
