# ankitbelbase17/simple_realstate_buyerportal architecture

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

- Interactive diagram: https://gitdiagram.com/ankitbelbase17/simple_realstate_buyerportal
- Repository: https://github.com/ankitbelbase17/simple_realstate_buyerportal

## Overview

1. **Repository purpose**
   - This is a DevOps-oriented “buyer portal” application with a small Node.js/Express app at the center, surrounded by containerization, automated deployment, and monitoring. The architecture is more about delivery and operability than about a large application domain.

2. **Core runtime boundary**
   - The main application runs as a **Node.js + Express backend** in `backend/`.
   - It likely serves both the API and the static frontend assets, since the repository contains separate `frontend/` HTML/CSS/JS files but no distinct frontend framework build system.

3. **Backend application shape**
   - `backend/server.js` is the entrypoint.
   - `backend/routes/auth.js` and `backend/routes/properties.js` split the API into authentication and property-related endpoints.
   - `backend/middleware/auth.js` is a request boundary for protecting authenticated routes.
   - `backend/db/init.js` indicates local database initialization, with SQLite called out in the README.

4. **Data flow inside the app**
   - Browser requests hit the Express server.
   - Auth requests go through the auth route and middleware.
   - Property requests are likely authorized and then read/write from SQLite.
   - Health and metrics endpoints are exposed for deployment verification and monitoring.

5. **Frontend subsystem**
   - `frontend/index.html` and `frontend/dashboard.html` are the two primary UI entry points.
   - CSS is split by concern: `auth.css`, `dashboard.css`, and shared `style.css`.
   - Client-side JavaScript is organized into `api.js` for backend calls, `auth.js` for login/register flows, `dashboard.js` for the portal view, and `toast.js` for notifications.
   - This suggests a static, server-served UI with direct API integration rather than a SPA build pipeline.

6. **Persistence and state**
   - The application state is lightweight and embedded: SQLite is used for local persistence instead of an external database service.
   - That keeps the deployment topology small: app container plus monitoring containers, with no separate database container in the documented architecture.

7. **Observability stack**
   - The app exposes `/metrics`, which Prometheus scrapes every 15 seconds.
   - `monitoring/prometheus.yml` defines the scrape target.
   - Grafana is auto-provisioned via `monitoring/grafana/provisioning/`, with a prebuilt dashboard in `monitoring/grafana/dashboards/buyer-portal.json`.
   - Monitoring is therefore part of the deployed system, not an afterthought.

8. **Container and local orchestration**
   - `Dockerfile` packages the application into a container.
   - `docker-compose.yml` coordinates the app with Prometheus and Grafana for local or deployed multi-service runs.
   - The README’s architecture implies a shared network between these services, with the app exposing port 5000, Prometheus on 9090, and Grafana on 3001.

9. **CI/CD pipeline**
   - `.github/workflows/ci-cd.yml` defines a 3-stage GitHub Actions flow:
     - lint/test and health checks,
     - Docker image build and container validation,
     - deployment validation and rollout.
   - The pipeline gates releases by checking both application health and metrics availability.

10. **Infrastructure and deployment management**
   - `ansible/deploy.yml` with `inventory.ini` and `ansible.cfg` handles server-side provisioning and deployment steps, including Docker install, repo clone, build, and verification.
   - `terraform/main.tf` provisions the Docker-based infrastructure via IaC.
   - `Vagrantfile` supports local VM-based environment provisioning, likely for reproducible development or demo environments.

11. **Automation scripts**
   - `scripts/deploy-local.sh` and `scripts/deploy-local.ps1` replicate the CI/CD flow locally.
   - `scripts/install-hooks.ps1` installs a Git post-commit hook for automatic local deployment.
   - `scripts/rollback.ps1` provides a rollback path to the previous known-good deployment.
   - `scripts/setup-runner.sh` suggests support for a self-hosted runner or local execution environment.

12. **Main architectural boundary diagram**
   - The key diagram should show:
     - Developer commits/pushes
     - GitHub Actions or local Git hook triggers pipeline
     - Dockerized Express app as the core runtime
     - Browser UI talking to backend APIs
     - SQLite as embedded persistence inside the app boundary
     - Prometheus scraping metrics from the app
     - Grafana reading from Prometheus
     - Ansible/Terraform/Vagrant as provisioning and deployment tooling around the runtime

Main entry points: [`backend/server.js`](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/backend/server.js) (Express app), [`.github/workflows/ci-cd.yml`](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/.github/workflows/ci-cd.yml) (CI/CD), [`docker-compose.yml`](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/docker-compose.yml) (Compose stack), [`backend/routes/auth.js`](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/backend/routes/auth.js) (Auth API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_delivery["Delivery"]
  node_developer(("Developer<br/>actor"))
  node_github_actions{{"CI/CD<br/>pipeline<br/>[ci-cd.yml]"}}
  node_local_ops["Local deploy<br/>automation<br/>[deploy-local.sh]"]
  node_rollback["Rollback<br/>automation<br/>[rollback.ps1]"]
  node_dockerfile["Docker image<br/>container build"]
  node_compose["Compose stack<br/>orchestration<br/>[docker-compose.yml]"]
end

subgraph group_runtime["Runtime"]
  node_browser(("Browser<br/>client"))
  node_frontend_ui["Portal UI<br/>static frontend<br/>[index.html]"]
  node_frontend_js["Client scripts<br/>frontend logic<br/>[api.js]"]
  node_backend_server["Express app<br/>node backend<br/>[server.js]"]
  node_auth_routes["Auth API<br/>routes<br/>[auth.js]"]
  node_property_routes["Properties API<br/>routes<br/>[properties.js]"]
  node_auth_middleware["Auth guard<br/>middleware<br/>[auth.js]"]
  node_sqlite[("SQLite<br/>embedded db<br/>[init.js]")]
end

subgraph group_observability["Observability"]
  node_metrics["Metrics<br/>endpoint"]
  node_prometheus["Prometheus<br/>metrics scrape<br/>[prometheus.yml]"]
  node_grafana["Grafana<br/>dashboarding<br/>[buyer-portal.json]"]
end

subgraph group_infra["Infra"]
  node_ansible["Ansible<br/>provisioning<br/>[deploy.yml]"]
  node_terraform["Terraform<br/>infra as code<br/>[main.tf]"]
  node_vagrant["Vagrant<br/>vm env"]
  node_runner_setup["Runner setup<br/>automation<br/>[setup-runner.sh]"]
end

node_developer -->|"push"| node_github_actions
node_developer -->|"run locally"| node_local_ops
node_developer -.->|"recover"| node_rollback
node_github_actions -->|"build image"| node_dockerfile
node_github_actions -->|"validate stack"| node_compose
node_github_actions -->|"deploy"| node_ansible
node_github_actions -.->|"provision"| node_terraform
node_github_actions -.->|"prepare runner"| node_runner_setup
node_local_ops -->|"start stack"| node_compose
node_compose -->|"run app"| node_backend_server
node_compose -->|"run scrape"| node_prometheus
node_compose -->|"run dashboard"| node_grafana
node_browser -->|"open portal"| node_frontend_ui
node_frontend_ui -->|"use"| node_frontend_js
node_frontend_js -->|"API calls"| node_backend_server
node_backend_server -->|"route auth"| node_auth_routes
node_backend_server -->|"route data"| node_property_routes
node_backend_server -->|"protect"| node_auth_middleware
node_backend_server -->|"persist"| node_sqlite
node_backend_server -->|"expose"| node_metrics
node_auth_routes -->|"validate"| node_auth_middleware
node_auth_routes -->|"read/write"| node_sqlite
node_property_routes -->|"read/write"| node_sqlite
node_prometheus -->|"scrape"| node_metrics
node_grafana -->|"query"| node_prometheus
node_ansible -->|"deploy stack"| node_compose
node_terraform -.->|"provision env"| node_vagrant

click node_github_actions "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/.github/workflows/ci-cd.yml"
click node_local_ops "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/scripts/deploy-local.sh"
click node_rollback "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/scripts/rollback.ps1"
click node_dockerfile "https://github.com/ankitbelbase17/simple_realstate_buyerportal/tree/main/Dockerfile"
click node_compose "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/docker-compose.yml"
click node_frontend_ui "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/frontend/index.html"
click node_frontend_js "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/frontend/js/api.js"
click node_backend_server "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/backend/server.js"
click node_auth_routes "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/backend/routes/auth.js"
click node_property_routes "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/backend/routes/properties.js"
click node_auth_middleware "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/backend/middleware/auth.js"
click node_sqlite "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/backend/db/init.js"
click node_prometheus "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/monitoring/prometheus.yml"
click node_grafana "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/monitoring/grafana/dashboards/buyer-portal.json"
click node_ansible "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/ansible/deploy.yml"
click node_terraform "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/terraform/main.tf"
click node_vagrant "https://github.com/ankitbelbase17/simple_realstate_buyerportal/tree/main/Vagrantfile"
click node_runner_setup "https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/scripts/setup-runner.sh"

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_developer,node_github_actions,node_local_ops,node_rollback,node_dockerfile,node_compose toneBlue
class node_browser,node_frontend_ui,node_frontend_js,node_backend_server,node_auth_routes,node_property_routes,node_auth_middleware,node_sqlite toneAmber
class node_metrics,node_prometheus,node_grafana toneMint
class node_ansible,node_terraform,node_vagrant,node_runner_setup toneRose
```

## Components

### Delivery

Commit, build, validate, and deploy automation.

- **Developer**: actor · Commits code and triggers local or CI delivery paths.
- [CI/CD](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/.github/workflows/ci-cd.yml): pipeline · GitHub Actions workflow for linting, image build, validation, and rollout. · `.github/workflows/ci-cd.yml`
- [Local deploy](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/scripts/deploy-local.sh): automation · Local deployment and validation scripts mirroring the pipeline. · `scripts/deploy-local.sh`
- [Rollback](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/scripts/rollback.ps1): automation · Reverts to the previous known-good deployment. · `scripts/rollback.ps1`
- [Docker image](https://github.com/ankitbelbase17/simple_realstate_buyerportal/tree/main/Dockerfile): container build · Packages the application runtime into a container image. · `Dockerfile`
- [Compose stack](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/docker-compose.yml): orchestration · Runs the app with Prometheus and Grafana in a shared local stack. · `docker-compose.yml`

### Runtime

Browser-facing app and backend API boundary.

- **Browser**: client · User entry point for the portal UI.
- [Portal UI](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/frontend/index.html): static frontend · Login and dashboard pages served as static assets. · `frontend/index.html`
- [Client scripts](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/frontend/js/api.js): frontend logic · Browser-side API calls, auth flow, dashboard behavior, and toasts. · `frontend/js/api.js`
- [Express app](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/backend/server.js): node backend · Main server entrypoint serving UI, API, and operational endpoints. · `backend/server.js`
- [Auth API](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/backend/routes/auth.js): routes · Authentication and session-related endpoints. · `backend/routes/auth.js`
- [Properties API](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/backend/routes/properties.js): routes · Property-related endpoints for portal data. · `backend/routes/properties.js`
- [Auth guard](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/backend/middleware/auth.js): middleware · Protects authenticated routes at the request boundary. · `backend/middleware/auth.js`
- [SQLite](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/backend/db/init.js): embedded db · Local persistence initialized inside the backend deployment boundary. · `backend/db/init.js`

### Observability

Metrics scraping and dashboarding.

- **Metrics**: endpoint · Application observability endpoint scraped by Prometheus.
- [Prometheus](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/monitoring/prometheus.yml): metrics scrape · Scrapes the backend metrics endpoint on a fixed interval. · `monitoring/prometheus.yml`
- [Grafana](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/monitoring/grafana/dashboards/buyer-portal.json): dashboarding · Reads Prometheus data and serves the buyer portal dashboard. · `monitoring/grafana/dashboards/buyer-portal.json`

### Infra

Provisioning and environment setup.

- [Ansible](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/ansible/deploy.yml): provisioning · Server-side deployment and verification automation. · `ansible/deploy.yml`
- [Terraform](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/terraform/main.tf): infra as code · Infrastructure provisioning for the Docker-based environment. · `terraform/main.tf`
- [Vagrant](https://github.com/ankitbelbase17/simple_realstate_buyerportal/tree/main/Vagrantfile): vm env · Local VM environment for reproducible setup and demos. · `Vagrantfile`
- [Runner setup](https://github.com/ankitbelbase17/simple_realstate_buyerportal/blob/main/scripts/setup-runner.sh): automation · Prepares a self-hosted or local execution environment for automation. · `scripts/setup-runner.sh`

## Connections

- Developer → CI/CD: push · Code changes enter the CI/CD workflow.
- Developer → Local deploy: run locally · Local scripts reproduce the deployment flow.
- Developer → Rollback: recover · Rollback path for failed deployments.
- CI/CD → Docker image: build image · Pipeline builds the container image before validation.
- CI/CD → Compose stack: validate stack · Pipeline validates the containerized runtime.
- CI/CD → Ansible: deploy · Workflow hands off deployment to Ansible-based automation.
- CI/CD → Terraform: provision · Infrastructure changes are managed through Terraform.
- CI/CD → Runner setup: prepare runner · Supports self-hosted or local execution for automation.
- Local deploy → Compose stack: start stack · Local deployment launches the app and monitoring stack.
- Compose stack → Express app: run app · The app container is orchestrated by Compose.
- Compose stack → Prometheus: run scrape · Prometheus is part of the deployed stack.
- Compose stack → Grafana: run dashboard · Grafana is part of the deployed stack.
- Browser → Portal UI: open portal · Users access the static portal pages.
- Portal UI → Client scripts: use · Pages are driven by browser-side scripts.
- Client scripts → Express app: API calls · Client scripts talk directly to the Express backend.
- Express app → Auth API: route auth · Express mounts authentication endpoints.
- Express app → Properties API: route data · Express mounts portal data endpoints.
- Express app → Auth guard: protect · Authenticated routes pass through the guard.
- Express app → SQLite: persist · Application data is stored in embedded SQLite.
- Express app → Metrics: expose · Backend serves a metrics endpoint for scraping.
- Auth API → Auth guard: validate · Auth flows apply request protection where needed.
- Auth API → SQLite: read/write · Authentication state is backed by SQLite.
- Properties API → SQLite: read/write · Property data is persisted in SQLite.
- Prometheus → Metrics: scrape · Prometheus collects metrics from the backend endpoint.
- Grafana → Prometheus: query · Grafana visualizes the metrics stored in Prometheus.
- Ansible → Compose stack: deploy stack · Ansible deploys the containerized application stack.
- Terraform → Vagrant: provision env · Infrastructure work supports repeatable environments.
