How ankitbelbase17/simple_realstate_buyerportal works
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: server.js Express app · ci-cd.yml CI/CD · docker-compose.yml Compose stack · auth.js Auth API
Components 21
Delivery
Commit, build, validate, and deploy automation.
- Developer · Commits code and triggers local or CI delivery paths.
- CI/CD · GitHub Actions workflow for linting, image build, validation, and rollout.
.github/workflows/ci-cd.yml - Local deploy · Local deployment and validation scripts mirroring the pipeline.
scripts/deploy-local.sh - Rollback · Reverts to the previous known-good deployment.
scripts/rollback.ps1 - Docker image · Packages the application runtime into a container image.
Dockerfile - Compose stack · Runs the app with Prometheus and Grafana in a shared local stack.
docker-compose.yml
Runtime
Browser-facing app and backend API boundary.
- Browser · User entry point for the portal UI.
- Portal UI · Login and dashboard pages served as static assets.
frontend/index.html - Client scripts · Browser-side API calls, auth flow, dashboard behavior, and toasts.
frontend/js/api.js - Express app · Main server entrypoint serving UI, API, and operational endpoints.
backend/server.js - Auth API · Authentication and session-related endpoints.
backend/routes/auth.js - Properties API · Property-related endpoints for portal data.
backend/routes/properties.js - Auth guard · Protects authenticated routes at the request boundary.
backend/middleware/auth.js - SQLite · Local persistence initialized inside the backend deployment boundary.
backend/db/init.js
Observability
Metrics scraping and dashboarding.
- Metrics · Application observability endpoint scraped by Prometheus.
- Prometheus · Scrapes the backend metrics endpoint on a fixed interval.
monitoring/prometheus.yml - Grafana · Reads Prometheus data and serves the buyer portal dashboard.
monitoring/grafana/dashboards/buyer-portal.json
Infra
Provisioning and environment setup.
- Ansible · Server-side deployment and verification automation.
ansible/deploy.yml - Terraform · Infrastructure provisioning for the Docker-based environment.
terraform/main.tf - Vagrant · Local VM environment for reproducible setup and demos.
Vagrantfile - Runner setup · Prepares a self-hosted or local execution environment for automation.
scripts/setup-runner.sh
Connections 27
- 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.