# valdiks1/apartment-building-management-system architecture

> Architecture diagram of the GitHub repository valdiks1/apartment-building-management-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/valdiks1/apartment-building-management-system
- Repository: https://github.com/valdiks1/apartment-building-management-system

## Overview

##### Project Type & Purpose
- This is a web-based apartment building management system. It is built using PHP with a MySQL database, designed to help manage apartment building operations.
- The system supports two types of users: administrators (with a dedicated admin panel) and regular users (who can register, view profiles, and interact with the system).

##### Main Components
a. Frontend Components:
- Public Pages: index.php, register.php, profile.php, question.php. These handle user interactions.
- Client-side assets: CSS (css/style.css) and JavaScript (js/app.js and js/all.js) for UI styling and interactivity.
- Media: The img directory, which likely contains images used on the site.

b. Backend Components:
- PHP Files: Files such as connection.php and utility.php are responsible for database connectivity and auxiliary functions.
- Admin Section: Located in the admin directory; includes files like adminPage.php, applications.php, contacts.php, mainInfo.php, questions.php, rule.php, and tariffs.php. These files manage administrative functions.
- Additional PHP files: applications.php (likely manages user applications) outside of the admin folder.

c. Database:
- A MySQL database is set up via the MyHome.sql script. The database connection is established in connection.php.
- Tables and relationships later using the SQL file content if needed.

##### Relationships and Interactions
- User requests (from index.php, register.php, etc.) are received by the frontend.
- Interaction happens through PHP backend scripts that process requests, query/modify the database (using connection.php), and return results.
- The admin section interacts similarly but via dedicated PHP pages under the admin folder.
- External communications are limited to the local server environment, emphasizing database connectivity and session management between user and admin operations.

##### Architectural Patterns & Design Principles
- The project follows a simple PHP web application architecture without a strict MVC separation but inherently partitions the application by user roles (admin vs. regular user).
- There’s a clear separation between presentation (CSS, JavaScript, and HTML/PHP pages) and business logic (PHP scripts and utility functions).
- Database abstraction is partially handled in connection.php and is critical for the system.

##### Technologies, Frameworks, and Libraries
- PHP for server-side logic.
- MySQL for data storage and retrieval.
- HTML/CSS/JavaScript for the frontend UI.
- No modern frameworks are indicated; the design is more traditional and file-based.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Frontend Subgraph
    subgraph "User Frontend"
        U1["index.php"]:::frontend
        U2["register.php"]:::frontend
        U3["profile.php"]:::frontend
        U4["question.php"]:::frontend
    end

    %% Client-side Assets Subgraph
    subgraph "Client-side Assets"
        CA1["css/style.css"]:::assets
        CA2["js/app.js"]:::assets
        CA3["js/all.js"]:::assets
        CA4["img"]:::assets
    end

    %% Backend Core Services Subgraph
    subgraph "Backend Core Services"
        B1["connection.php"]:::backend
        B2["utility.php"]:::backend
        B3["applications.php"]:::backend
    end

    %% Admin Panel Subgraph
    subgraph "Admin Panel"
        A1["adminPage.php"]:::admin
        A2["applications.php"]:::admin
        A3["contacts.php"]:::admin
        A4["mainInfo.php"]:::admin
        A5["questions.php"]:::admin
        A6["rule.php"]:::admin
        A7["tariffs.php"]:::admin
    end

    %% Database Node
    DB["MySQL Database"]:::database

    %% Connections from User Frontend to Backend Core Services (User Request Flow)
    U1 -->|"submitReq"| B3
    U2 -->|"submitReq"| B3
    U3 -->|"submitReq"| B3
    U4 -->|"submitReq"| B3

    %% Connection from Admin Panel to Backend Core Services (Admin Request Flow)
    A1 -->|"adminReq"| B1
    A2 -->|"adminReq"| B1
    A3 -->|"adminReq"| B1
    A4 -->|"adminReq"| B1
    A5 -->|"adminReq"| B1
    A6 -->|"adminReq"| B1
    A7 -->|"adminReq"| B1

    %% Internal Backend Communication
    B3 -->|"queries"| B1
    B2 -->|"assists"| B1

    %% Connection from Backend Core to Database
    B1 -->|"connectsTo"| DB

    %% Click Events for User Frontend
    click U1 "https://github.com/valdiks1/apartment-building-management-system/blob/main/index.php"
    click U2 "https://github.com/valdiks1/apartment-building-management-system/blob/main/register.php"
    click U3 "https://github.com/valdiks1/apartment-building-management-system/blob/main/profile.php"
    click U4 "https://github.com/valdiks1/apartment-building-management-system/blob/main/question.php"

    %% Click Events for Client-side Assets
    click CA1 "https://github.com/valdiks1/apartment-building-management-system/blob/main/css/style.css"
    click CA2 "https://github.com/valdiks1/apartment-building-management-system/blob/main/js/app.js"
    click CA3 "https://github.com/valdiks1/apartment-building-management-system/blob/main/js/all.js"
    click CA4 "https://github.com/valdiks1/apartment-building-management-system/tree/main/img"

    %% Click Events for Backend Core Services
    click B1 "https://github.com/valdiks1/apartment-building-management-system/blob/main/connection.php"
    click B2 "https://github.com/valdiks1/apartment-building-management-system/blob/main/utility.php"
    click B3 "https://github.com/valdiks1/apartment-building-management-system/blob/main/applications.php"

    %% Click Events for Admin Panel
    click A1 "https://github.com/valdiks1/apartment-building-management-system/blob/main/admin/adminPage.php"
    click A2 "https://github.com/valdiks1/apartment-building-management-system/blob/main/admin/applications.php"
    click A3 "https://github.com/valdiks1/apartment-building-management-system/blob/main/admin/contacts.php"
    click A4 "https://github.com/valdiks1/apartment-building-management-system/blob/main/admin/mainInfo.php"
    click A5 "https://github.com/valdiks1/apartment-building-management-system/blob/main/admin/questions.php"
    click A6 "https://github.com/valdiks1/apartment-building-management-system/blob/main/admin/rule.php"
    click A7 "https://github.com/valdiks1/apartment-building-management-system/blob/main/admin/tariffs.php"

    %% Click Event for Database Initialization Script
    click DB "https://github.com/valdiks1/apartment-building-management-system/blob/main/myHome.sql"

    %% Styles for different layers
    classDef frontend fill:#ffd1dc,stroke:#d63384,stroke-width:2px;
    classDef assets fill:#d1e8ff,stroke:#1c7ed6,stroke-width:2px;
    classDef backend fill:#d1ffd6,stroke:#37b24d,stroke-width:2px;
    classDef admin fill:#fff3bf,stroke:#f08c00,stroke-width:2px;
    classDef database fill:#ffc9c9,stroke:#fa5252,stroke-width:2px;
```
