How hoanganhwhy/group7_arboris_rentalroommanagementsystem works
1. Overall shape
- HostelMate is a two-tier application: a React + Vite + TypeScript single-page frontend in src/ and a Node.js + Express backend in server/.
- The frontend talks to the backend over HTTP through a small API layer, and the backend persists data in SQLite.
2. Frontend entry and composition
- The client bootstraps from src/main.tsx, renders src/App.tsx, and uses index.html as the Vite entry.
- The UI is organized as page modules under src/pages/ for the main business areas: Dashboard, Rooms, Tenants, TenantAccounts, Invoices, MeterReadings, Repairs.
3. Shared UI boundary
- Reusable controls live in src/components/ui/ such as Button, Input, Modal, Sidebar, and FilterDropdown.
- This suggests a mostly page-driven admin console where pages assemble forms, tables, filters, and dialogs from shared primitives rather than using a heavyweight component framework.
4. Client-to-server data flow
- src/lib/api.ts is the front-end boundary for backend calls; pages likely use it instead of calling fetch directly.
- The architecture is: page interaction → API helper → Express route → SQLite. This keeps transport concerns separate from page logic.
5. Backend service layer
- server/server.js is the Express application entry point and exposes the application’s REST APIs.
- server/db.js centralizes database connection/setup, so route handlers can remain focused on domain rules instead of connection management.
6. Persistence model
- The backend uses SQLite files checked into the repo (server/csdl_hostelmate.sqlite, server/quan_ly_phong_tro.sqlite), indicating a lightweight embedded database deployment.
- The test suite also runs against :memory: SQLite, so tests are isolated from the production/dev database files.
7. Domain subsystems
- The README identifies the main business modules as:
- Rooms: room metadata, capacity, floor, area, rent, status, and deletion protection when occupied.
- Tenants: tenant profiles and phone normalization to E.164.
- Room assignments / contracts: check-in, representative tenant, renewal, and checkout with room status updates.
- Meter readings: monthly electricity and water readings with monotonic validation.
- Invoices: rent + utilities + other fees, with month/year selection and CSV/Excel export.
- Repairs: issue reporting constrained to tenants actually occupying the room.
8. Business-rule boundaries
- The core architecture is rule-heavy at the API layer: many actions are validated against current occupancy, tenant identity, and previous readings.
- Important state transitions are centralized in the backend, especially when an action changes room state from available → occupied → maintenance or closes an assignment on checkout.
9. Reporting and export
- Invoices are not just stored; they also support structured export for spreadsheet workflows, including UTF-8 BOM handling for Vietnamese text.
- This makes the invoice subsystem a bridge between transactional data and operational reporting.
10. Testing architecture
- Backend tests live in server/tests/server.test.js and run with Jest + Supertest.
- The test setup is intentionally isolated from the real DB, which is important for reliable API-level verification of business rules.
11. Tooling and quality gates
- The repo uses ESLint at both root and server level to enforce consistent code style.
- GitHub Actions in .github/workflows/ci.yml automates CI on push/PR, combining linting and backend test execution.
12. Repository-level deployment/runtime boundary
- The root package.json and the separate server/package.json imply independent frontend and backend dependency graphs, but a single developer workflow.
- Local development runs both processes together; architecturally, the frontend is a consumer of the backend API, not a server-rendered app.
13. What to draw in an architecture diagram
- Show four main boxes: React UI, API client layer, Express API server, and SQLite database.
- Then subdivide the API server into the six domain modules above, and place tests/CI as a parallel quality pipeline rather than part of the runtime path.
Main entry points: App.tsx App Shell · server.js Express API · api.ts API Client · db.js DB Setup
Components 23
Frontend
React + Vite single-page client
- Index HTML · Vite HTML entrypoint for the SPA
index.html - Main · Bootstraps the React application
src/main.tsx - App Shell · Top-level application composition
src/App.tsx - API Client · Front-end boundary for backend requests
src/lib/api.ts - Dashboard · Overview and status page
src/pages/Dashboard.tsx - Rooms · Room management UI
src/pages/Rooms.tsx - Tenants · Tenant profile management UI
src/pages/Tenants.tsx - Tenant Accounts · Tenant account and billing view
src/pages/TenantAccounts.tsx - Invoices · Billing and export workflows
src/pages/Invoices.tsx - Meter Readings · Utility reading entry and review
src/pages/MeterReadings.tsx - Repairs · Repair issue reporting UI
src/pages/Repairs.tsx - UI Primitives · Reusable buttons, inputs, modal, sidebar, and filters
src/components/ui
Backend
Express API and SQLite persistence
- Express API · REST API entrypoint
server/server.js - DB Setup · Centralized SQLite connection and setup
server/db.js - SQLite Store · Repository-checked SQLite databases
server/csdl_hostelmate.sqlite - Rooms Service · Room metadata, status, and occupancy rules
- Tenants Service · Tenant profiles and phone normalization
- Assignments · Check-in, renewal, representative tenant, checkout
- Meter Service · Monthly electricity and water readings
- Invoices Service · Rent, utilities, fees, and export output
- Repairs Service · Issue reporting constrained by occupancy
Quality
Tests and CI checks
- API Tests · Isolated backend tests against in-memory SQLite
server/tests/server.test.js - CI Workflow · Automated lint and backend test pipeline
.github/workflows/ci.yml
Connections 34
- Index HTML → Main: loads · Vite HTML entry loads the client bootstrap
- Main → App Shell: renders · Mounts the top-level React app
- App Shell → Dashboard: navigates · Composes the main page modules
- App Shell → Rooms: navigates · Composes the main page modules
- App Shell → Tenants: navigates · Composes the main page modules
- App Shell → Tenant Accounts: navigates · Composes the main page modules
- App Shell → Invoices: navigates · Composes the main page modules
- App Shell → Meter Readings: navigates · Composes the main page modules
- App Shell → Repairs: navigates · Composes the main page modules
- App Shell → UI Primitives: uses · Pages build screens from shared controls
- Dashboard → API Client: requests · Uses the API helper for backend data
- Rooms → API Client: requests · Uses the API helper for backend data
- Tenants → API Client: requests · Uses the API helper for backend data
- Tenant Accounts → API Client: requests · Uses the API helper for backend data
- Invoices → API Client: requests · Uses the API helper for backend data
- Meter Readings → API Client: requests · Uses the API helper for backend data
- Repairs → API Client: requests · Uses the API helper for backend data
- API Client → Express API: calls · Client talks to the REST API over HTTP
- Express API → Rooms Service: routes · Delegates room operations to the domain boundary
- Express API → Tenants Service: routes · Delegates tenant operations to the domain boundary
- Express API → Assignments: routes · Delegates occupancy and checkout flows
- Express API → Meter Service: routes · Delegates utility reading flows
- Express API → Invoices Service: routes · Delegates billing and export flows
- Express API → Repairs Service: routes · Delegates repair workflows
- Rooms Service → DB Setup: reads/writes · Persists room state through the DB layer
- Tenants Service → DB Setup: reads/writes · Persists tenant records through the DB layer
- Assignments → DB Setup: reads/writes · Stores occupancy and contract state
- Meter Service → DB Setup: reads/writes · Stores monotonic meter readings
- Invoices Service → DB Setup: reads/writes · Builds and stores invoice data
- Repairs Service → DB Setup: reads/writes · Stores repair issues and status
- DB Setup → SQLite Store: connects · Centralized SQLite connection targets the repo database files
- API Tests → Express API: verifies · Exercises the API surface with Supertest
- API Tests → SQLite Store: isolates · Runs against in-memory SQLite during tests
- CI Workflow → API Tests: runs · CI executes the backend test suite