# darkness-07/notes-sharing architecture

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

- Interactive diagram: https://gitdiagram.com/darkness-07/notes-sharing
- Repository: https://github.com/darkness-07/notes-sharing

## Overview

##### Project Type and Purpose
- This is a monolithic LAMP-style web application (full-stack), implemented in PHP with an Apache server and MySQL back end.
- Purpose: Allow students to register, log in, upload/download academic notes, and give admins tools to manage users and notes.

##### Main Components
a. Clients (Browsers on desktop or mobile)
b. Web Server Layer (Apache via XAMPP)
c. Application Layer (PHP scripts)
- Public pages: index.html, login.php, register.php, logout.php
- Protected/user controllers: upload.php, delete_note.php
- Admin controllers: admin_login.php, dashboard.php, delete_user.php, update_user.php, admin_logout.php
- Shared modules: db.php (connection), stylesheets (styles.css, dashboard.css, login-Register.css)
d. Data Layer
- MySQL Database “notes_sharing” (tables: users, notes, etc.)
- File storage area for uploaded note files (could be a server‐side folder)
e. External Dependencies (phpMyAdmin for DB setup)

##### Relationships and Data Flows
- Apache routes requests to specific PHP controllers
- Controllers use db.php to issue SQL queries to MySQL
- MySQL returns data to PHP; PHP renders HTML/CSS back to Client
- File uploads/downloads handled by PHP file I/O interacting with the file storage folder

##### Architectural Patterns and Design Principles
- Layered architecture:
Layer 1 (Presentation): HTML5/CSS3/Bootstrap files and templates
Layer 2 (Business Logic): PHP controllers for authentication, upload/download, admin actions
Layer 3 (Data Access): db.php abstraction for MySQL operations
- Separation of concerns: distinct files for user vs. admin functions; shared database connector
- Stateless HTTP interactions: each request hits PHP, no long-lived sessions on the server aside from PHP sessions

##### Detailing and Depth
- Session management as part of the PHP layer (to show login/logout workflows)
- Authentication flow: login form → login.php → db.php → session start → redirect to dashboard
- Error or validation paths if desired (e.g., failed login loops back to login.php)
- File upload lifecycle: upload.php → move_uploaded_file → storage directory → record metadata in MySQL → confirm to user

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    subgraph "Clients"
        Browser["Browser (Desktop/Mobile)"]:::client
    end

    %% Server Layer
    subgraph "Web Server Layer (Apache via XAMPP)"
        Apache["Apache Web Server"]:::backend
    end

    Browser -->|"HTTP Request"| Apache
    Apache -->|"Routes Request"| PublicControllers
    Apache -->|"Routes Request"| UserControllers
    Apache -->|"Routes Request"| AdminControllers

    %% Presentation Layer: Public Pages
    subgraph "Public Pages" 
        index["index.html"]:::client
        login["login.php"]:::backend
        register["register.php"]:::backend
        logout["logout.php"]:::backend
    end

    %% User Controllers
    subgraph "User Controllers"
        upload["upload.php"]:::backend
        deleteNote["delete_note.php"]:::backend
    end

    %% Admin Controllers
    subgraph "Admin Controllers"
        adminLogin["admin_login.php"]:::backend
        dashboard["dashboard.php"]:::backend
        deleteUser["delete_user.php"]:::backend
        updateUser["update_user.php"]:::backend
        adminLogout["admin_logout.php"]:::backend
    end

    %% Shared Modules
    subgraph "Shared Modules"
        db["db.php (DB Connection)"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        MySQL["MySQL DB\nnotes_sharing"]:::db
        Storage["File Storage\n(uploaded notes folder)"]:::storage
    end

    %% Flows: Public Controllers to DB
    index -->|"serves static HTML"| Browser
    login -->|"validate credentials"| db
    register -->|"create user"| db
    logout -->|"end session"| Browser

    upload -->|"file I/O"| Storage
    upload -->|"record metadata"| db
    deleteNote -->|"remove file & record"| Storage
    deleteNote -->|"remove record"| db

    adminLogin -->|"validate admin"| db
    dashboard -->|"fetch data"| db
    deleteUser -->|"remove user record"| db
    updateUser -->|"update user record"| db
    adminLogout -->|"end session"| Browser

    %% DB interactions back to PHP
    db -->|"query result"| login
    db -->|"query result"| register
    db -->|"query result"| upload
    db -->|"query result"| deleteNote
    db -->|"query result"| adminLogin
    db -->|"query result"| dashboard
    db -->|"query result"| deleteUser
    db -->|"query result"| updateUser

    %% PHP renders responses
    login -->|"render HTML/CSS"| Browser
    register -->|"render HTML/CSS"| Browser
    upload -->|"render confirmation"| Browser
    deleteNote -->|"render confirmation"| Browser
    adminLogin -->|"redirect to dashboard"| Browser
    dashboard -->|"render dashboard"| Browser
    deleteUser -->|"render update"| Browser
    updateUser -->|"render update"| Browser
    adminLogout -->|"redirect to login"| Browser

    %% Click Events
    click index "https://github.com/darkness-07/notes-sharing/blob/main/index.html"
    click login "https://github.com/darkness-07/notes-sharing/blob/main/login.php"
    click register "https://github.com/darkness-07/notes-sharing/blob/main/register.php"
    click logout "https://github.com/darkness-07/notes-sharing/blob/main/logout.php"
    click upload "https://github.com/darkness-07/notes-sharing/blob/main/upload.php"
    click deleteNote "https://github.com/darkness-07/notes-sharing/blob/main/delete_note.php"
    click adminLogin "https://github.com/darkness-07/notes-sharing/blob/main/admin_login.php"
    click dashboard "https://github.com/darkness-07/notes-sharing/blob/main/dashboard.php"
    click deleteUser "https://github.com/darkness-07/notes-sharing/blob/main/delete_user.php"
    click updateUser "https://github.com/darkness-07/notes-sharing/blob/main/update_user.php"
    click adminLogout "https://github.com/darkness-07/notes-sharing/blob/main/admin_logout.php"
    click db "https://github.com/darkness-07/notes-sharing/blob/main/db.php"
    classDef client fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef db fill:#FFA500,stroke:#000,stroke-width:1px
    classDef storage fill:#D3D3D3,stroke:#000,stroke-width:1px
```
