Heartbeat is a full-stack, distributed monitoring solution designed to track website availability across multiple regions. It leverages a modern monorepo architecture to sync a Next.js dashboard with a high-speed Express API, powered by independent background workers that perform health checks from the edge.
Test Credentials
Email: test@example.com
Password: Test@123
-
Pixel-Perfect Dashboard: A refined, responsive UI built with Next.js 16 and Tailwind CSS 4, featuring real-time latency visualizations and status grids.
-
Distributed Monitoring: Independent background workers simulate global pings, feeding high-fidelity data into a centralized Prisma-managed database.
-
Secure Authentication: Integrated Better Auth implementation supporting session management across a shared monorepo domain.
-
Real-Time Bridge: Live data synchronization between local monitoring workers and the cloud-hosted dashboard using Neon’s serverless driver and connection pooler.
The project is structured as a Turborepo monorepo to ensure seamless code sharing and optimized build pipelines.
-
Role: Serves as the user-facing command center.
-
Tech: React 19, Turbopack, Framer Motion, and Recharts.
-
Function: Manages user authentication, monitor configuration, and renders live status "ticks" from the database.
-
Role: The central logic hub and data gateway.
-
Tech: Node.js, Express 5, Zod, and Better Auth.
-
Function: Handles CRUD operations for monitors, serves health-check history, and manages secure session validation.
-
Role: The execution engine for health checks.
-
Tech: Bun runtime, Axios, and Prisma Client.
-
Function: Periodically pings target URLs, measures response times, and writes "website_tick" records directly to the database.
-
Role: Data synchronization and cleanup.
-
Tech: Bun.
-
Function: Orchestrates the flow of regional data and ensures consistent state between distributed components.
-
User Setup: A user signs in via the Frontend and adds a website URL to monitor.
-
API Processing: The API validates the request via Zod and stores the new monitor in the Neon Database.
-
Worker Execution: Background Workers (running locally or at the edge) detect the new monitor and begin high-frequency pings.
-
Data Ingestion: Each ping result (Up/Down/Latency) is saved as a "tick" in the database.
-
Live View: The Frontend polls the API, which retrieves the latest ticks. The UI updates in real-time to show the monitor's health status.
This project uses Bun as the primary package manager and runtime.
-
Install Bun
-
A PostgreSQL database (Neon recommended)
-
Clone the repository:
Bash
git clone https://github.com/MDub3y/heartbeat.git cd heartbeat -
Install dependencies:
Bash
bun install -
Configure Environment Variables: Create a
.envfile in the root with:Code snippet
DATABASE_URL=your_neon_db_url BETTER_AUTH_SECRET=your_secret BETTER_AUTH_URL=http://localhost:3000 NEXT_PUBLIC_API_URL=http://localhost:3001
-
Start:
Bash
bun dev
