# hoangnam2464/rentease-management architecture

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

- Interactive diagram: https://gitdiagram.com/hoangnam2464/rentease-management
- Repository: https://github.com/hoangnam2464/rentease-management

## Overview

1. **Overall shape**
   - RentEase is a Django monorepo: one backend project, one server-rendered frontend layer, and shared static assets/templates in the same repository.
   - There is no separate SPA/frontend service; browsers talk directly to Django views, which render HTML templates and serve static files.

2. **Primary runtime boundary**
   - The backend lives under `backend/` and is the architectural center.
   - `backend/hostello_backend/` contains the Django project configuration, root URL routing, WSGI/ASGI entrypoints, and environment-driven settings.
   - Persistence is through Django ORM to PostgreSQL in local Docker, with SQLite as fallback when `DATABASE_URL` is absent.

3. **Core business domains**
   - The repository is organized into domain apps that map closely to the product model:
     - `accounts` for users, user types, profiles, and role mapping
     - `properties` for rental properties and rooms
     - `tenants` for tenants and co-tenants
     - `contracts` for rental contracts
     - `billing` for invoices, payments, and payment integrations
     - `maintenance` for repair tickets and maintenance records
     - `listings` for public room listings and viewing registrations
     - `governance` for private documentation and audit-oriented controls
   - These are the main data-owning subsystems and are the likely nodes in any architecture diagram.

4. **User access layers**
   - The application has distinct surfaces for Visitor, Owner, Tenant, Staff, and Admin.
   - Public visitors use listing pages and viewing registration without authentication.
   - Owners and tenants use role-specific portal routes.
   - Staff uses internal reports and Django Admin, while superusers/admins have full platform access.

5. **Portal subsystem**
   - `backend/portal/` is the cross-domain orchestration layer for authenticated user journeys.
   - It contains dashboard views, forms, decorators, template tags, and a demo-data seeding command.
   - This layer appears to coordinate data from properties, contracts, billing, maintenance, and listings into owner/tenant-specific screens rather than owning core business state itself.

6. **Billing and payment integration**
   - `billing` is the most integration-heavy subsystem.
   - It models invoices, invoice lines, payment intents, and webhook events, and contains a gateway adapter for PayOS/VietQR.
   - External payment confirmation flows into `backend/billing/api/webhooks.py`, meaning the authoritative payment state is updated by signed webhook callbacks rather than by client-side redirects alone.
   - The billing service layer likely sits between webhooks, invoice state, and payment history.

7. **Maintenance and notifications**
   - `maintenance` stores repair/maintenance lifecycle data and has signal hooks, suggesting side effects such as status updates or notifications.
   - `notices` is a separate app for notification records and user-facing notices.
   - This subsystem likely receives events from tenant requests or owner actions and surfaces them in tenant/owner portals.

8. **Public listings and lead capture**
   - `listings` handles the public-facing room catalog and viewing-registration flow.
   - Visitors can browse available rooms, see sanitized details, and submit interest forms without authentication.
   - This is a controlled boundary: public data is intentionally scoped so private contract, identity, and precise location information remain hidden.

9. **Operational reporting and admin**
   - `reports` provides staff-only reporting views and service logic.
   - Django Admin is customized with Jazzmin and supported by app-level admin registrations.
   - This creates a separate internal operational surface for staff oversight, distinct from the owner/tenant portals.

10. **Legacy compatibility layer**
   - The old HOSTELLO apps (`students`, `attendance`, `fees`, `requests`, `notices`) are still present.
   - README indicates they are retained for historical compatibility, not the primary RentEase product surface.
   - For an architecture diagram, treat them as legacy/adjacent modules that may still share models, signals, or admin integrations but are not the main product path.

11. **Front-end delivery**
   - `frontend/templates/` contains the rendered pages for public pages, owner and tenant portals, reports, login, and admin customizations.
   - `frontend/static/` holds CSS, JavaScript, and images, including custom design-system assets and admin styling.
   - The UI is therefore server-rendered, with light client-side scripting rather than a frontend application framework.

12. **Background and maintenance utilities**
   - Management commands such as `seed_rentease_demo_data` and `generate_monthly_fees.py` indicate offline operational workflows for seeding and periodic fee generation.
   - Utility scripts like logo generation/checking and test-specific commands suggest some non-request-time automation exists alongside the main web app.
   - These are supporting processes, not separate services.

13. **Data flow summary**
   - Normal request path: browser → Django URL routing → app view/form/serializer logic → ORM → PostgreSQL/SQLite → template rendering back to browser.
   - Public listing path: anonymous browser → `listings` views → sanitized property/room data.
   - Payment path: tenant/owner action → billing service/gateway → PayOS/VietQR external service → webhook callback → billing models/status updates → portal/dashboard display.

14. **Deployment and infrastructure**
   - Local deployment is designed around Docker Compose for PostgreSQL 15 and a Python virtual environment for Django.
   - Static delivery is prepared for WhiteNoise-style serving, which matters for standalone deployment without a separate static server.
   - There is no Redis, Celery, separate API gateway, or frontend build pipeline in the current architecture.

15. **Security and tenancy boundary**
   - A central architectural constraint is data isolation by role and by owner/tenant scope.
   - The product explicitly avoids exposing sensitive identity data in public listings, portal lists, and staff search results.
   - Any diagram should show tenant/owner scoping as a cross-cutting boundary enforced in views, decorators, and model/query filtering rather than as a separate service.

Main entry points: [`backend/portal`](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/portal) (Portal), [`docker-compose.yml`](https://github.com/hoangnam2464/rentease-management/blob/complete-product/docker-compose.yml) (PostgreSQL / SQLite), [`backend/hostello_backend`](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/hostello_backend) (Django Project), [`backend/billing`](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/billing) (Billing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_browser(("Browser<br/>client"))
  node_templates["Templates<br/>server-rendered ui"]
  node_static["Static UI<br/>assets"]
end

subgraph group_backend["Backend"]
  node_project["Django Project<br/>project config"]
  node_portal["Portal<br/>orchestration"]
  node_accounts["Accounts<br/>identity domain"]
  node_properties["Properties<br/>portfolio domain"]
  node_tenants["Tenants<br/>tenant domain"]
  node_contracts["Contracts<br/>rental domain"]
  node_billing["Billing<br/>payments domain"]
  node_maintenance["Maintenance<br/>repair domain"]
  node_listings["Listings<br/>public listing domain"]
  node_governance["Governance<br/>controls domain"]
  node_reports["Reports<br/>staff reporting"]
  node_admin["Django Admin<br/>ops console<br/>[admin.py]"]
  node_notices["Notices<br/>notification domain"]
end

subgraph group_legacy["Legacy"]
  node_legacy_apps["Legacy Apps<br/>compatibility layer"]
end

subgraph group_infra["Infrastructure"]
  node_payos(("PayOS/VietQR<br/>external gateway"))
  node_database[("PostgreSQL / SQLite<br/>datastore<br/>[docker-compose.yml]")]
end

node_browser -->|"HTTP"| node_project
node_project -->|"renders"| node_templates
node_project -->|"serves"| node_static
node_project -->|"routes"| node_portal
node_project -->|"routes"| node_listings
node_project -->|"routes"| node_reports
node_project -->|"mounts"| node_admin
node_portal -->|"uses"| node_accounts
node_portal -->|"uses"| node_properties
node_portal -->|"uses"| node_tenants
node_portal -->|"uses"| node_contracts
node_portal -->|"uses"| node_billing
node_portal -->|"uses"| node_maintenance
node_portal -->|"uses"| node_notices
node_listings -->|"reads"| node_properties
node_listings -->|"renders"| node_templates
node_reports -->|"reads"| node_properties
node_reports -->|"reads"| node_contracts
node_reports -->|"reads"| node_billing
node_reports -->|"reads"| node_maintenance
node_billing -->|"integrates"| node_payos
node_billing -->|"persists"| node_database
node_maintenance -->|"persists"| node_database
node_accounts -->|"persists"| node_database
node_properties -->|"persists"| node_database
node_tenants -->|"persists"| node_database
node_contracts -->|"persists"| node_database
node_listings -->|"persists"| node_database
node_governance -->|"persists"| node_database
node_legacy_apps -->|"persists"| node_database
node_admin -->|"manages"| node_accounts
node_admin -->|"manages"| node_properties
node_admin -->|"manages"| node_billing
node_admin -->|"manages"| node_maintenance
node_legacy_apps -.->|"overlaps"| node_notices
node_billing -.->|"updates"| node_portal

click node_templates "https://github.com/hoangnam2464/rentease-management/tree/complete-product/frontend/templates"
click node_static "https://github.com/hoangnam2464/rentease-management/tree/complete-product/frontend/static"
click node_project "https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/hostello_backend"
click node_portal "https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/portal"
click node_accounts "https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/accounts"
click node_properties "https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/properties"
click node_tenants "https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/tenants"
click node_contracts "https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/contracts"
click node_billing "https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/billing"
click node_maintenance "https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/maintenance"
click node_listings "https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/listings"
click node_governance "https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/governance"
click node_reports "https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/reports"
click node_admin "https://github.com/hoangnam2464/rentease-management/blob/complete-product/backend/accounts/admin.py"
click node_database "https://github.com/hoangnam2464/rentease-management/blob/complete-product/docker-compose.yml"
click node_legacy_apps "https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/students"
click node_notices "https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/notices"

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_browser,node_templates,node_static toneBlue
class node_project,node_portal,node_accounts,node_properties,node_tenants,node_contracts,node_billing,node_maintenance,node_listings,node_governance,node_reports,node_admin,node_notices toneAmber
class node_legacy_apps toneMint
class node_payos,node_database toneRose
```

## Components

### Presentation

Server-rendered HTML, static assets, and browser-facing pages

- **Browser**: client · Visitors, owners, tenants, staff, and admins access the site through the browser
- [Templates](https://github.com/hoangnam2464/rentease-management/tree/complete-product/frontend/templates): server-rendered ui · HTML templates for home, listings, portals, reports, login, and admin pages · `frontend/templates`
- [Static UI](https://github.com/hoangnam2464/rentease-management/tree/complete-product/frontend/static): assets · CSS, JavaScript, images, and admin styling served with the app · `frontend/static`

### Backend

Django project, domain apps, and orchestration layers

- [Django Project](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/hostello_backend): project config · Root URL routing, settings, WSGI/ASGI entrypoints, and environment configuration · `backend/hostello_backend`
- [Portal](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/portal): orchestration · Authenticated cross-domain journeys, dashboards, decorators, forms, and demo seeding · `backend/portal`
- [Accounts](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/accounts): identity domain · Users, profiles, user types, and role mapping · `backend/accounts`
- [Properties](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/properties): portfolio domain · Properties, rooms, ownership scope, and room metadata · `backend/properties`
- [Tenants](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/tenants): tenant domain · Tenants and co-tenants · `backend/tenants`
- [Contracts](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/contracts): rental domain · Rental contracts and payment-cycle rules · `backend/contracts`
- [Billing](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/billing): payments domain · Invoices, invoice lines, payment intents, webhook events, and gateway services · `backend/billing`
- [Maintenance](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/maintenance): repair domain · Repair tickets and maintenance records · `backend/maintenance`
- [Listings](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/listings): public listing domain · Public room catalog and viewing registrations · `backend/listings`
- [Governance](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/governance): controls domain · Private documentation and audit-oriented controls · `backend/governance`
- [Reports](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/reports): staff reporting · Staff-only reporting services and views · `backend/reports`
- [Django Admin](https://github.com/hoangnam2464/rentease-management/blob/complete-product/backend/accounts/admin.py): ops console · Customized administrative surface with app registrations and Jazzmin styling · `backend/accounts/admin.py`
- [Notices](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/notices): notification domain · Notification records and user-facing notices · `backend/notices`

### Legacy

Older HOSTELLO modules kept for compatibility

- [Legacy Apps](https://github.com/hoangnam2464/rentease-management/tree/complete-product/backend/students): compatibility layer · Older HOSTELLO modules retained for historical compatibility · `backend/students`

### Infrastructure

Datastores and external payment integration

- **PayOS/VietQR**: external gateway · External payment provider used for payment confirmation flows
- [PostgreSQL / SQLite](https://github.com/hoangnam2464/rentease-management/blob/complete-product/docker-compose.yml): datastore · Primary ORM-backed persistence with PostgreSQL locally and SQLite fallback · `docker-compose.yml`

## Connections

- Browser → Django Project: HTTP · All web traffic enters through Django routing
- Django Project → Templates: renders · Views render server-side HTML templates
- Django Project → Static UI: serves · Static assets are delivered with the app
- Django Project → Portal: routes · Authenticated journeys are handled by the portal layer
- Django Project → Listings: routes · Public listing pages and viewing registration are exposed here
- Django Project → Reports: routes · Staff reporting views are mounted through the project URLs
- Django Project → Django Admin: mounts · Admin surface is configured at the project level
- Portal → Accounts: uses · Role checks and profile data shape user journeys
- Portal → Properties: uses · Portal screens aggregate portfolio data
- Portal → Tenants: uses · Tenant and co-tenant information is surfaced in portals
- Portal → Contracts: uses · Contracts drive owner and tenant screens
- Portal → Billing: uses · Invoices, payments, and payment status appear in portals
- Portal → Maintenance: uses · Repair flows are coordinated through the portal
- Portal → Notices: uses · Notifications are shown in tenant and owner journeys
- Listings → Properties: reads · Public listings are derived from property and room data with sanitization
- Listings → Templates: renders · Public listing pages use server-rendered templates
- Reports → Properties: reads · Reporting aggregates property and room data
- Reports → Contracts: reads · Contract reports are built from rental data
- Reports → Billing: reads · Billing reports summarize invoices and payments
- Reports → Maintenance: reads · Maintenance reports summarize repairs and status
- Billing → PayOS/VietQR: integrates · Gateway adapter and webhook callbacks connect to external payments
- Billing → PostgreSQL / SQLite: persists · Invoices, payment intents, and webhook events are stored through the ORM
- Maintenance → PostgreSQL / SQLite: persists · Repair lifecycle data is stored in the database
- Accounts → PostgreSQL / SQLite: persists · Users, profiles, and role mappings are stored in the database
- Properties → PostgreSQL / SQLite: persists · Portfolio and room state are stored in the database
- Tenants → PostgreSQL / SQLite: persists · Tenant records and co-tenant links are stored in the database
- Contracts → PostgreSQL / SQLite: persists · Contracts and payment-cycle data are stored in the database
- Listings → PostgreSQL / SQLite: persists · Public listing and viewing-registration records are stored in the database
- Governance → PostgreSQL / SQLite: persists · Governance records are stored through the ORM
- Legacy Apps → PostgreSQL / SQLite: persists · Compatibility modules still share the main datastore
- Django Admin → Accounts: manages · Administrative screens operate over core app models
- Django Admin → Properties: manages · Admin tools manage portfolio data
- Django Admin → Billing: manages · Admin tools can inspect billing state
- Django Admin → Maintenance: manages · Admin tools can inspect maintenance state
- Legacy Apps → Notices: overlaps · Legacy modules overlap with notice and request style functionality
- Billing → Portal: updates · Webhook-confirmed payment state is reflected back into user dashboards
