# iamakashyadav/note-taking-web-app architecture

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

- Interactive diagram: https://gitdiagram.com/iamakashyadav/note-taking-web-app
- Repository: https://github.com/iamakashyadav/note-taking-web-app

## Overview

##### Project Type and Purpose
- This is a small full-stack note-taking web application built on a classic LAMP-style architecture.
- Front-end: plain HTML, CSS, JavaScript
- Back-end: PHP
- Database: MySQL
- Purpose: allow users to register, log in, and perform CRUD operations (create, read, update, delete) on notes.

##### File Structure Analysis
- Top-level PHP entrypoints:
- index.php (landing/home page)
- register.php (user sign-up)
- login.php (authentication)
- logout.php (end session)
- notes.php (notes dashboard and CRUD endpoints)
- config/db_connect.php: central database connection logic
- css/: stylesheets (auth.css, index.css, notes.css)
- js/notes.js: front-end logic for note creation/editing
- img/: static assets
- No external frameworks—everything served by a single PHP application

##### Key Architectural Components
a. Client (Browser)
- Fetches HTML/CSS/JS from the server
- Renders pages, invokes AJAX (if used) or form submissions
b. Web Server & PHP Runtime
- Apache (or similar) with PHP interpreter
- Routes requests to the appropriate PHP script (index, login, notes, etc.)
- Uses config/db_connect.php to open a MySQL connection
c. MySQL Database
- Two tables: user (user_id, email, password, name, created_at) and notes (note_id, user_id, title, note, created_at, last_updated_at)
d. Static File Server
- Serves CSS, JS, and image files

##### Interactions and Data Flow
1. User navigates to index.php → server returns HTML/CSS
2. User submits register.php/login.php form → PHP script validates input, writes or reads from MySQL, sets a session cookie
3. Upon successful auth, user is redirected to notes.php → PHP queries the notes table for the logged-in user
4. notes.php serves the notes page and includes notes.js to handle client-side note operations (edit/delete via form submits or AJAX)
5. Any create/edit/delete triggers another HTTP request to notes.php → PHP updates MySQL → returns updated HTML fragment or JSON
6. logout.php destroys the session and redirects

##### Architectural Patterns & Principles
- Separation of concerns:
- Static assets (css/, js/, img/) vs. dynamic endpoints (.php)
- Centralized DB connection (config/db_connect.php)
- CRUD pattern for notes
- Session-based authentication
- Simplest MVC-style (though not a formal framework):
- “View” = HTML/CSS, “Controller” = PHP scripts, “Model” = MySQL tables

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Layer
    subgraph "Client (Browser)" 
        Browser["Browser"]:::client
    end

    %% Static Assets Layer
    subgraph "Static Assets" 
        CSSIndex["css/index.css"]:::static
        CSSAuth["css/auth.css"]:::static
        CSSNotes["css/notes.css"]:::static
        JSNotes["js/notes.js"]:::static
        IMG["img/"]:::static
    end

    %% Server Layer
    subgraph "Web Server + PHP Runtime"
        Index["index.php"]:::server
        Register["register.php"]:::server
        Login["login.php"]:::server
        Logout["logout.php"]:::server
        Notes["notes.php"]:::server
        DBConnector["config/db_connect.php"]:::server
    end

    %% Database Layer
    subgraph "Database Server"
        DB["MySQL Database<br/>(user & notes tables)"]:::db
    end

    %% Client to Static Assets
    Browser -->|"GET css/index.css"| CSSIndex
    Browser -->|"GET css/auth.css"| CSSAuth
    Browser -->|"GET css/notes.css"| CSSNotes
    Browser -->|"GET js/notes.js"| JSNotes
    Browser -->|"GET images"| IMG

    %% Client to Server HTTP Requests
    Browser -->|"GET /index.php"| Index
    Browser -->|"POST /register.php"| Register
    Browser -->|"POST /login.php"| Login
    Browser -->|"GET /logout.php"| Logout
    Browser -->|"GET/POST /notes.php"| Notes

    %% Server internal calls
    Index --> DBConnector
    Register --> DBConnector
    Login --> DBConnector
    Logout --> DBConnector
    Notes --> DBConnector

    %% Server to Database
    DBConnector -->|"SQL queries"| DB

    %% Click Events
    click Index "https://github.com/iamakashyadav/note-taking-web-app/blob/master/index.php"
    click Register "https://github.com/iamakashyadav/note-taking-web-app/blob/master/register.php"
    click Login "https://github.com/iamakashyadav/note-taking-web-app/blob/master/login.php"
    click Logout "https://github.com/iamakashyadav/note-taking-web-app/blob/master/logout.php"
    click Notes "https://github.com/iamakashyadav/note-taking-web-app/blob/master/notes.php"
    click DBConnector "https://github.com/iamakashyadav/note-taking-web-app/blob/master/config/db_connect.php"
    click CSSAuth "https://github.com/iamakashyadav/note-taking-web-app/blob/master/css/auth.css"
    click CSSIndex "https://github.com/iamakashyadav/note-taking-web-app/blob/master/css/index.css"
    click CSSNotes "https://github.com/iamakashyadav/note-taking-web-app/blob/master/css/notes.css"
    click JSNotes "https://github.com/iamakashyadav/note-taking-web-app/blob/master/js/notes.js"
    click IMG "https://github.com/iamakashyadav/note-taking-web-app/tree/master/img/"
    click README "https://github.com/iamakashyadav/note-taking-web-app/blob/master/README.md"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef server fill:#90EE90,stroke:#000,stroke-width:1px
    classDef db fill:#FFA500,stroke:#000,stroke-width:1px
    classDef static fill:#D3D3D3,stroke:#000,stroke-width:1px
```
