{"id":31890009,"url":"https://github.com/dabananda/apartmentmanagementsystem","last_synced_at":"2026-05-09T05:32:29.254Z","repository":{"id":310597074,"uuid":"1040476619","full_name":"dabananda/ApartmentManagementSystem","owner":"dabananda","description":"A comprehensive role based apartment management system","archived":false,"fork":false,"pushed_at":"2025-10-06T02:41:39.000Z","size":536,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-06T04:29:09.919Z","etag":null,"topics":["apartment-management-system","asp-net-core","bootstrap","identity-framework","payment-gateway","razor-pages","role-based-access-control","sql-server"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dabananda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-19T03:32:00.000Z","updated_at":"2025-10-06T02:41:42.000Z","dependencies_parsed_at":"2025-08-26T11:29:04.234Z","dependency_job_id":null,"html_url":"https://github.com/dabananda/ApartmentManagementSystem","commit_stats":null,"previous_names":["dabananda/apartmentmanagementsystem"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dabananda/ApartmentManagementSystem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabananda%2FApartmentManagementSystem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabananda%2FApartmentManagementSystem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabananda%2FApartmentManagementSystem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabananda%2FApartmentManagementSystem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dabananda","download_url":"https://codeload.github.com/dabananda/ApartmentManagementSystem/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dabananda%2FApartmentManagementSystem/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014113,"owners_count":26085462,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apartment-management-system","asp-net-core","bootstrap","identity-framework","payment-gateway","razor-pages","role-based-access-control","sql-server"],"created_at":"2025-10-13T07:17:04.593Z","updated_at":"2026-05-09T05:32:29.216Z","avatar_url":"https://github.com/dabananda.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Apartment Management System\n\nA role-based ASP.NET Core MVC application to operate an apartment building: buildings \u0026 flats, owners \u0026 tenants, shared expenses, monthly rent billing, payments (manual \u0026 Stripe), entry/visitor logs, and maintenance tickets. Designed for multi-role workflows with per‑building data boundaries.\n\n---\n\n## Table of Contents\n\n- [Features](#features)\n- [Roles \u0026 Permissions](#roles--permissions)\n- [Tech Stack](#tech-stack)\n- [Project Structure](#project-structure)\n- [Quick Start](#quick-start)\n  - [Prerequisites](#prerequisites)\n  - [Clone \u0026 Restore](#1-clone--restore)\n  - [Configure Secrets](#2-configure-secrets)\n  - [Database](#3-database)\n  - [Run the App](#4-run-the-app)\n  - [Stripe: Local Webhook Setup](#stripe-local-webhook-setup)\n- [Seeded Data](#seeded-data)\n- [Payments](#payments)\n  - [Manual Payments](#manual-payments)\n  - [Stripe Checkout + Webhook](#stripe-checkout--webhook)\n- [Tenant Assignment Rules](#tenant-assignment-rules)\n- [Background Jobs](#background-jobs)\n- [Troubleshooting](#troubleshooting)\n- [Development Tips](#development-tips)\n- [Contributing](#contributing)\n\n---\n\n## Features\n\n- **Authentication \u0026 Roles (ASP.NET Identity)**: `SuperAdmin`, `President`, `Owner`, `Tenant`, `Staff`, `User` (pending).\n- **Buildings \u0026 Flats**: CRUD with unique building codes (e.g., `BID1001`). Per-building stats.\n- **Owners \u0026 Tenants**: Assign tenants to flats; owner-to-tenant billing profiles.\n- **Common Bills \u0026 Allocations**: Create shared bills and allocate to owners; track payments \u0026 due.\n- **Tenant Billing**:\n  - Per‑flat billing profile (title + monthly amount).\n  - **Monthly bill generation** on the 1st via background service.\n  - Paid/Due totals visible in dashboards and portal.\n- **Payments**:\n  - **Manual** owner/tenant payments with email receipts.\n  - **Stripe Checkout** for card payments + **webhook** reconciliation.\n- **Tenant Portal**: Bills, payments, notices, tickets.\n- **Entry/Visitor Logs** \u0026 **Maintenance Tickets**.\n- **Email (SMTP)** with HTML receipts.\n\n---\n\n## Roles \u0026 Permissions\n\n- **SuperAdmin**: Full control; can manage buildings and create any role.\n- **President**: Building lead. May also hold the **Owner** role. Can create **Owner** and **Tenant** users for their building.\n- **Owner**: Can create **Tenant** users for their building; manages flats and tenant rent.\n- **Tenant**: Views bills, makes payments, creates tickets.\n- **Staff/User**: Limited operational roles as configured.\n\n\u003e President may have both `President` and `Owner` roles. UI and server enforce: **President can create Owner \u0026 Tenant**; **Owner can create Tenant** only.\n\n---\n\n## Tech Stack\n\n- **.NET 8** — ASP.NET Core MVC + Identity\n- **EF Core** — SQL Server\n- **Razor Views** — Bootstrap-based UI\n- **BackgroundService** — monthly bill generator\n- **Stripe** — Checkout \u0026 webhook for card payments\n\n---\n\n## Project Structure\n\n```\nApartmentManagementSystem/\n  Controllers/\n  Data/\n  Models/\n  Services/\n  ViewModels/\n  Views/\n  wwwroot/\n  Program.cs\n  appsettings*.json\n```\n\n---\n\n## Quick Start\n\n### Prerequisites\n\n- **.NET 8 SDK**\n- **SQL Server** (Developer/Express/LocalDB)\n- **Stripe CLI** (for local webhooks): https://stripe.com/docs/stripe-cli\n\n### 1) Clone \u0026 Restore\n\n```bash\ngit clone https://github.com/dabananda/ApartmentManagementSystem.git\ncd ApartmentManagementSystem/ApartmentManagementSystem\ndotnet restore\n```\n\n### 2) Configure Secrets\n\nUse **User Secrets** for local development.\n\n```bash\n# Initialize secrets store\ndotnet user-secrets init\n\n# Database connection\ndotnet user-secrets set \"ConnectionStrings:DefaultConnection\" \"Server=.;Database=AMS;Trusted_Connection=True;TrustServerCertificate=True;\"\n\n# Seeded SuperAdmin password\ndotnet user-secrets set \"SuperAdminPassword\" \"ChangeThis!123\"\n\n# SMTP (example values)\ndotnet user-secrets set \"Smtp:Host\" \"smtp.example.com\"\ndotnet user-secrets set \"Smtp:Port\" \"587\"\ndotnet user-secrets set \"Smtp:From\" \"noreply@example.com\"\ndotnet user-secrets set \"Smtp:User\" \"smtp-user\"\ndotnet user-secrets set \"Smtp:Password\" \"smtp-password\"\n\n# Stripe (dev) — keys \u0026 currency\ndotnet user-secrets set \"Stripe:PublishableKey\" \"pk_test_...\"\ndotnet user-secrets set \"Stripe:SecretKey\" \"sk_test_...\"\ndotnet user-secrets set \"Stripe:WebhookSecret\" \"whsec_...\"   # comes from Stripe CLI output\ndotnet user-secrets set \"Stripe:Currency\" \"usd\"\n```\n\n**Stripe config demo** (for reference only):\n\n```json\n\"Stripe\": {\n  \"PublishableKey\": \"\",\n  \"SecretKey\": \"\",\n  \"WebhookSecret\": \"\",\n  \"Currency\": \"\"\n}\n```\n\n\u003e You may also use `appsettings.Development.json` instead of user secrets if preferred.\n\n### 3) Database\n\n```bash\ndotnet ef database update\n```\n\n### 4) Run the App\n\n```bash\ndotnet run\n```\nOpen the printed HTTPS URL (e.g., `https://localhost:7033/`).\n\n### Stripe: Local Webhook Setup\n\nAfter the app is running, start the Stripe CLI listener **in a separate terminal**.  \nReplace the port if your local HTTPS port differs (see `Properties/launchSettings.json`).\n\n```powershell\nstripe listen --forward-to https://localhost:7033/payments/webhook\n```\n\nThe CLI prints a signing secret like:\n\n```\nReady! Your webhook signing secret is: whsec_xxx\n```\n\nCopy that to user secrets as `Stripe:WebhookSecret` (see above). With the listener running, Stripe events reach your local app and **payments will be recorded**.\n\n---\n\n## Seeded Data\n\nOn first run the app seeds:\n\n- Roles: **SuperAdmin, President, Owner, Tenant, Staff, User**\n- **SuperAdmin** account:\n  - **Email:** `superadmin@ams.com`\n  - **Password:** value from `SuperAdminPassword`\n\nLog in as SuperAdmin to create buildings, assign a President, and invite Owners/Tenants.\n\n---\n\n## Payments\n\n### Manual Payments\n\n- Owners and tenants can record manual payments (cash/bank).  \n- After a successful save, the app attempts to send a **receipt email**. Email failures are logged and surfaced as a small warning, but **do not block** the request.\n\n### Stripe Checkout + Webhook\n\n- Checkout sessions are created server-side.\n- The webhook endpoint `POST /payments/webhook` finalizes payments on `checkout.session.completed` or `payment_intent.succeeded` events.\n- Idempotency is enforced to prevent duplicates.\n\n**Local testing flow:**\n\n1. Run the app.\n2. Start the Stripe listener:\n   ```powershell\n   stripe listen --forward-to https://localhost:7033/payments/webhook\n   ```\n3. Use the UI to initiate a card payment, or trigger test events:\n   ```bash\n   stripe trigger checkout.session.completed\n   stripe trigger payment_intent.succeeded\n   ```\n\n---\n\n## Tenant Assignment Rules\n\n- A tenant can have **only one active flat assignment** at a time.\n- A flat can have **only one active tenant** at a time.\n- Enforced by both UI and **database filtered unique indexes** (active = `EndDate IS NULL`).\n\nThis prevents double-assignments even under concurrent requests.\n\n---\n\n## Background Jobs\n\n- `TenantMonthlyBillGenerator` runs daily and generates bills on the **1st** of each month based on **Flat Billing Profiles**.\n- In production with multiple instances, run a single instance or add a distributed lock to avoid duplicate runs.\n- Operates in UTC; display times are localized in the UI.\n\n---\n\n## Troubleshooting\n\n- **Payments recorded but page showed an error**: likely SMTP connectivity. Email send is best‑effort; payment saves are not rolled back. Configure `Smtp:*` settings or disable email in dev.\n- **Stripe webhook not firing**: ensure the app is running **and** the Stripe CLI listener is active, and the `Stripe:WebhookSecret` matches the latest CLI output.\n- **DataTables warning about unknown parameter**: ensure the table columns in the view match the data or use named property bindings in DataTables configuration.\n\n---\n\n## Contributing\n\nPRs are welcome! Please open an issue for discussion before large changes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabananda%2Fapartmentmanagementsystem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdabananda%2Fapartmentmanagementsystem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdabananda%2Fapartmentmanagementsystem/lists"}