# malisunny543-pixel/pg-manager architecture

> Architecture diagram of the GitHub repository malisunny543-pixel/pg-manager, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/malisunny543-pixel/pg-manager
- Repository: https://github.com/malisunny543-pixel/pg-manager

## Overview

PGMS is a Flask-based, multi-property paying-guest management application with Admin, Manager/Warden, and Tenant portals. The principal workflow is staff managing properties and beds, allocating tenants, then handling billing and checkout; tenants use self-service for invoices, payments, complaints, notices, and checkout requests. Blueprints call service functions, which access MySQL through the database layer. README capabilities include RBAC, property isolation, bed concurrency/lifecycle, utility billing, audit trails, and reports. Service internals not shown are represented by their exact paths; links are limited to documented or indexed relationships.

Main entry points: [`app/db/__init__.py`](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/db/__init__.py) (Database API), [`app/services/audit_service.py`](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/services/audit_service.py) (Audit trail), [`app/admin/__init__.py`](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/admin/__init__.py) (Admin portal), [`app/__init__.py`](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/__init__.py) (Flask factory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Web entry and security"]
  node_factory["Flask factory<br/>[__init__.py]"]
  node_auth["Authentication<br/>[__init__.py]"]
  node_access["Session and RBAC<br/>[extensions.py]"]
end

subgraph group_operations["Property operations"]
  node_admin["Admin portal<br/>[__init__.py]"]
  node_manager["Manager portal<br/>[__init__.py]"]
  node_property["Property and rooms"]
  node_allocation["Bed allocation"]
end

subgraph group_finance["Finance and occupancy"]
  node_billing["Invoices and payments<br/>[billing_service.py]"]
  node_reports["Reports and dashboards<br/>[report_service.py]"]
end

subgraph group_resident["Resident services"]
  node_tenant["Tenant portal<br/>[__init__.py]"]
  node_complaints["Complaint handling"]
  node_notices["Notices and alerts<br/>[notice_service.py]"]
end

subgraph group_persistence["Persistence and audit"]
  node_audit["Audit trail<br/>[audit_service.py]"]
  node_dbapi["Database API<br/>[__init__.py]"]
  node_pool["Connection pool<br/>[connection.py]"]
  node_mysql[("MySQL database<br/>[schema.sql]")]
end

node_user(("Portal users"))

node_user -->|"opens portal"| node_factory
node_factory -->|"registers blueprint"| node_auth
node_factory -->|"registers blueprint"| node_admin
node_factory -->|"registers blueprint"| node_manager
node_factory -->|"registers blueprint"| node_tenant
node_admin -->|"guards routes"| node_access
node_manager -->|"guards routes"| node_access
node_tenant -->|"guards routes"| node_access
node_admin -->|"manages properties"| node_property
node_admin -->|"operates allocations"| node_allocation
node_manager -->|"manages rooms"| node_property
node_manager -->|"checks in tenants"| node_allocation
node_tenant -->|"views invoices"| node_billing
node_tenant -->|"submits complaints"| node_complaints
node_tenant -->|"reads notices"| node_notices
node_admin -->|"generates invoices"| node_billing
node_admin -->|"views reports"| node_reports
node_allocation -->|"records actions"| node_audit
node_billing -->|"records actions"| node_audit
node_complaints -->|"records actions"| node_audit
node_notices -->|"records actions"| node_audit
node_property -->|"records actions"| node_audit
node_auth -->|"records actions"| node_audit
node_auth -->|"queries users"| node_dbapi
node_allocation -->|"uses transactions"| node_dbapi
node_billing -->|"queries and writes"| node_dbapi
node_complaints -->|"queries and writes"| node_dbapi
node_notices -->|"queries and writes"| node_dbapi
node_property -->|"queries and writes"| node_dbapi
node_reports -->|"queries data"| node_dbapi
node_audit -->|"writes records"| node_dbapi
node_dbapi -->|"delegates queries"| node_pool
node_pool -.->|"reads and writes"| node_mysql

click node_factory "https://github.com/malisunny543-pixel/pg-manager/blob/main/app/__init__.py"
click node_auth "https://github.com/malisunny543-pixel/pg-manager/blob/main/app/auth/__init__.py"
click node_access "https://github.com/malisunny543-pixel/pg-manager/blob/main/app/extensions.py"
click node_admin "https://github.com/malisunny543-pixel/pg-manager/blob/main/app/admin/__init__.py"
click node_manager "https://github.com/malisunny543-pixel/pg-manager/blob/main/app/manager/__init__.py"
click node_property "https://github.com/malisunny543-pixel/pg-manager/blob/main/app/services/property_service.py"
click node_allocation "https://github.com/malisunny543-pixel/pg-manager/blob/main/app/services/allocation_service.py"
click node_tenant "https://github.com/malisunny543-pixel/pg-manager/blob/main/app/tenant/__init__.py"
click node_complaints "https://github.com/malisunny543-pixel/pg-manager/blob/main/app/services/complaint_service.py"
click node_notices "https://github.com/malisunny543-pixel/pg-manager/blob/main/app/services/notice_service.py"
click node_billing "https://github.com/malisunny543-pixel/pg-manager/blob/main/app/services/billing_service.py"
click node_reports "https://github.com/malisunny543-pixel/pg-manager/blob/main/app/services/report_service.py"
click node_audit "https://github.com/malisunny543-pixel/pg-manager/blob/main/app/services/audit_service.py"
click node_dbapi "https://github.com/malisunny543-pixel/pg-manager/blob/main/app/db/__init__.py"
click node_pool "https://github.com/malisunny543-pixel/pg-manager/blob/main/app/db/connection.py"
click node_mysql "https://github.com/malisunny543-pixel/pg-manager/blob/main/database/schema.sql"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_factory,node_auth,node_access,node_user toneBlue
class node_admin,node_manager,node_property,node_allocation toneAmber
class node_billing,node_reports toneMint
class node_tenant,node_complaints,node_notices toneRose
class node_audit,node_dbapi,node_pool,node_mysql toneIndigo
```

## Components

### Web entry and security

- [Flask factory](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/__init__.py): `app/__init__.py`
- [Authentication](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/auth/__init__.py): `app/auth/__init__.py`
- [Session and RBAC](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/extensions.py): `app/extensions.py`

### Property operations

- [Admin portal](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/admin/__init__.py): `app/admin/__init__.py`
- [Manager portal](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/manager/__init__.py): `app/manager/__init__.py`
- [Property and rooms](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/services/property_service.py): `app/services/property_service.py`
- [Bed allocation](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/services/allocation_service.py): `app/services/allocation_service.py`

### Finance and occupancy

- [Invoices and payments](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/services/billing_service.py): `app/services/billing_service.py`
- [Reports and dashboards](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/services/report_service.py): `app/services/report_service.py`

### Resident services

- [Tenant portal](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/tenant/__init__.py): `app/tenant/__init__.py`
- [Complaint handling](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/services/complaint_service.py): `app/services/complaint_service.py`
- [Notices and alerts](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/services/notice_service.py): `app/services/notice_service.py`

### Persistence and audit

- [Audit trail](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/services/audit_service.py): `app/services/audit_service.py`
- [Database API](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/db/__init__.py): `app/db/__init__.py`
- [Connection pool](https://github.com/malisunny543-pixel/pg-manager/blob/main/app/db/connection.py): `app/db/connection.py`
- [MySQL database](https://github.com/malisunny543-pixel/pg-manager/blob/main/database/schema.sql): `database/schema.sql`

### Other components

- **Portal users**

## Connections

- Portal users → Flask factory: opens portal (evidence: `README.md`)
- Flask factory → Authentication: registers blueprint (evidence: `app/__init__.py`)
- Flask factory → Admin portal: registers blueprint (evidence: `app/__init__.py`)
- Flask factory → Manager portal: registers blueprint (evidence: `app/__init__.py`)
- Flask factory → Tenant portal: registers blueprint (evidence: `app/__init__.py`)
- Admin portal → Session and RBAC: guards routes (evidence: `app/admin/__init__.py`)
- Manager portal → Session and RBAC: guards routes (evidence: `app/manager/__init__.py`)
- Tenant portal → Session and RBAC: guards routes (evidence: `app/tenant/__init__.py`)
- Admin portal → Property and rooms: manages properties (evidence: `app/admin/__init__.py`)
- Admin portal → Bed allocation: operates allocations (evidence: `app/admin/__init__.py`)
- Manager portal → Property and rooms: manages rooms (evidence: `app/manager/__init__.py`)
- Manager portal → Bed allocation: checks in tenants (evidence: `app/manager/__init__.py`)
- Tenant portal → Invoices and payments: views invoices (evidence: `app/tenant/__init__.py`)
- Tenant portal → Complaint handling: submits complaints (evidence: `app/tenant/__init__.py`)
- Tenant portal → Notices and alerts: reads notices (evidence: `app/tenant/__init__.py`)
- Admin portal → Invoices and payments: generates invoices (evidence: `app/admin/__init__.py`)
- Admin portal → Reports and dashboards: views reports (evidence: `README.md`)
- Bed allocation → Audit trail: records actions (evidence: `app/services/allocation_service.py`)
- Invoices and payments → Audit trail: records actions (evidence: `app/services/billing_service.py`)
- Complaint handling → Audit trail: records actions (evidence: `app/services/complaint_service.py`)
- Notices and alerts → Audit trail: records actions (evidence: `app/services/notice_service.py`)
- Property and rooms → Audit trail: records actions (evidence: `app/services/property_service.py`)
- Authentication → Audit trail: records actions
- Authentication → Database API: queries users
- Bed allocation → Database API: uses transactions (evidence: `app/services/allocation_service.py`)
- Invoices and payments → Database API: queries and writes (evidence: `app/services/billing_service.py`)
- Complaint handling → Database API: queries and writes (evidence: `app/services/complaint_service.py`)
- Notices and alerts → Database API: queries and writes (evidence: `app/services/notice_service.py`)
- Property and rooms → Database API: queries and writes (evidence: `app/services/property_service.py`)
- Reports and dashboards → Database API: queries data (evidence: `app/services/report_service.py`)
- Audit trail → Database API: writes records (evidence: `app/services/audit_service.py`)
- Database API → Connection pool: delegates queries (evidence: `app/db/__init__.py`)
- Connection pool → MySQL database: reads and writes
