Skip to content

About

better stack uptime clone

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”” Better Uptime

A high-performance, real-time website uptime monitoring platform built entirely in Rust.
Inspired by Better Uptime


πŸ“– Overview

Better Uptime is an open-source uptime monitoring platform that continuously checks your websites and tracks their availability, response times, and health status across multiple regions. It's designed as a distributed system of microservices β€” all written in Rust β€” communicating through Redis Streams for low-latency, high-throughput event processing.

✨ Key Features

  • Continuous Monitoring β€” Automatically pings your websites at regular intervals and records response times
  • Multi-Region Checks β€” Supports health checks from multiple geographic regions to detect localized outages
  • Real-time Event Pipeline β€” Redis Streams power the event-driven architecture for instant data flow between services
  • Status Tracking β€” Tracks Up, Down, and Unknown states for every monitored endpoint
  • User Authentication β€” Secure signup/signin with Argon2 password hashing and JWT-based auth
  • REST API β€” Full CRUD API for managing monitored websites and viewing uptime data
  • Structured Logging β€” JSON-formatted, span-based tracing across all services via tracing
  • Dockerized β€” One-command deployment with Docker Compose

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend   │◄─────►│                  API Server                  β”‚
β”‚  (Planned)   β”‚       β”‚            (Poem β€’ Port 8080)               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                          β”‚
                                          β”‚  Diesel ORM
                                          β–Ό
                      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                      β”‚              PostgreSQL 17                    β”‚
                      β”‚  users β”‚ websites β”‚ website_ticks β”‚ regions  β”‚
                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                          β–²
                                          β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                           β”‚                           β”‚
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚      Producer       β”‚    β”‚       Worker        β”‚    β”‚    Site Writer      β”‚
   β”‚  (Scheduler/Cron)   β”‚    β”‚   (Health Checker)  β”‚    β”‚  (Persistence)     β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚                           β”‚                           β”‚
              β”‚  publish                  β”‚  consume/publish          β”‚  consume
              β–Ό                           β–Ό                           β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚                          Redis 7 Streams                                 β”‚
   β”‚                process_queue  ◄──►  store_queue                          β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Data Flow

  1. Producer queries PostgreSQL for all registered websites (cursor-paginated, batches of 50) and publishes check events to the Redis process_queue every 3 minutes.
  2. Worker consumes events from the process_queue, makes HTTP requests to each website, records response time and status (Up/Down), then publishes results to the store_queue.
  3. Site Writer consumes results from the store_queue and bulk-inserts them into the website_ticks table in PostgreSQL, then acknowledges the stream entries.

🧱 Project Structure

This is a Cargo workspace with 8 crates, each with a clear responsibility:

better-uptime-rust/
β”œβ”€β”€ api/                # REST API server (Poem framework)
β”‚   └── src/
β”‚       β”œβ”€β”€ modules/
β”‚       β”‚   β”œβ”€β”€ auth/       # Signup, signin, JWT auth
β”‚       β”‚   └── website/    # Website CRUD & monitoring data
β”‚       β”œβ”€β”€ server.rs       # Server setup & request logging middleware
β”‚       β”œβ”€β”€ router.rs       # Route mounting
β”‚       β”œβ”€β”€ config.rs       # Environment config
β”‚       └── state.rs        # Shared application state
β”‚
β”œβ”€β”€ producer/           # Scheduled job β€” publishes website check events
β”‚   └── src/
β”‚       └── producer.rs     # Cursor-paginated website fetcher β†’ Redis publisher
β”‚
β”œβ”€β”€ worker/             # Health checker β€” pings websites, records results
β”‚   └── src/
β”‚       └── worker.rs       # HTTP health checks with response time tracking
β”‚
β”œβ”€β”€ site-writer/        # Persistence layer β€” writes check results to DB
β”‚   └── src/
β”‚       └── writer.rs       # Stream consumer β†’ bulk database inserts
β”‚
β”œβ”€β”€ store/              # Database layer (Diesel ORM + PostgreSQL)
β”‚   β”œβ”€β”€ migrations/         # 7 Diesel migrations
β”‚   └── src/
β”‚       β”œβ”€β”€ model/          # Diesel models (User, Website, WebsiteTick, Region)
β”‚       β”œβ”€β”€ module/         # Repository pattern (UserRepository, WebsiteRepository)
β”‚       └── schema.rs       # Auto-generated Diesel schema
β”‚
β”œβ”€β”€ stream/             # Redis Streams abstraction layer
β”‚   └── src/
β”‚       β”œβ”€β”€ stream.rs       # Redis connection + client setup
β”‚       β”œβ”€β”€ process.rs      # process_queue consumer/publisher
β”‚       β”œβ”€β”€ store.rs        # store_queue consumer/publisher
β”‚       └── seed.rs         # Stream initialization
β”‚
β”œβ”€β”€ common/             # Shared utilities
β”‚   └── src/
β”‚       └── logging.rs      # Structured JSON logging setup (tracing)
β”‚
β”œβ”€β”€ migrator/           # Database migration runner
β”œβ”€β”€ seed/               # Database seeder
β”‚
β”œβ”€β”€ Cargo.toml          # Workspace manifest
β”œβ”€β”€ Dockerfile          # Multi-stage build (builder β†’ per-service targets)
β”œβ”€β”€ docker-compose.yml  # Full stack orchestration
└── README.md

πŸ› οΈ Tech Stack

Layer Technology
Language Rust 1.90 (Edition 2024)
API Framework Poem
Database PostgreSQL 17
ORM Diesel (with r2d2 connection pool)
Message Broker Redis 7 (Streams)
Auth Argon2 password hashing + JWT (jsonwebtoken)
HTTP Client reqwest
Logging tracing + tracing-subscriber (JSON format)
Containerization Docker multi-stage builds + Docker Compose
Frontend 🚧 Coming soon

πŸš€ Getting Started

Prerequisites

Run with Docker Compose

# Clone the repo
git clone https://github.com/your-username/better-uptime-rust.git
cd better-uptime-rust

# Start the entire stack
docker compose up --build

This will spin up:

Service Description Port
postgres PostgreSQL 17 database 5432
redis Redis 7 message broker 6379
migrate Runs Diesel migrations, then exits β€”
seed Seeds initial data, then exits β€”
api REST API server 8080
producer Website check scheduler β€”
worker HTTP health checker β€”
site-writer Results persistence writer β€”

Local Development

# Start infrastructure
docker compose up postgres redis -d

# Run migrations
cargo run -p migrator

# Seed the database
cargo run -p seed

# Start individual services (in separate terminals)
cargo run -p api
cargo run -p producer
cargo run -p worker
cargo run -p site-writer

Note: Each service reads its config from a .env file in its own crate directory. See the individual .env files for required environment variables.


πŸ“‘ API Reference

Base URL: http://localhost:8080/api

Authentication

Method Endpoint Description
POST /auth/signup Create a new account
POST /auth/signin Sign in and receive JWT

Websites

Method Endpoint Description
POST /website/website Add a website to monitor
GET /website/website/:website_id Get website details & uptime data

πŸ“Š Database Schema

users           (id UUID PK, username TEXT, password TEXT, created_at TIMESTAMPTZ)
websites        (id UUID PK, url TEXT, user_id UUID FK→users, created_at TIMESTAMPTZ)
website_ticks   (id UUID PK, websites_id UUID FK→websites, response_time_ms INT,
                 region_name TEXT FK→regions, status status_type, created_at TIMESTAMPTZ)
regions         (name TEXT PK)

The status_type is a PostgreSQL custom enum: up | down | unknown.


πŸ—ΊοΈ Roadmap

  • Frontend β€” Dashboard UI (considering Yew/Rust-based SPA or Next.js)
  • Additional API endpoints (list websites, delete website, uptime history)
  • Alerting & notifications (email, Slack, webhooks)
  • Status pages (public-facing uptime dashboards)
  • Multi-region worker deployment
  • Incident timeline & reporting
  • Rate limiting & API key authentication

πŸ“„ License

This project is open source and available under the MIT License.


Built with πŸ¦€ Rust β€” fast, safe, and reliable.

About

better stack uptime clone

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages