# Repository: bluewave-labs/Checkmate # Stars: 9637 ## CLAUDE.md # CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Project Overview Checkmate is an open-source uptime and infrastructure monitoring application. It monitors server hardware, uptime, response times, and incidents with real-time alerts. The companion agent [Capture](https://github.com/bluewave-labs/capture) provides infrastructure metrics (CPU, RAM, disk, temperature). ## Development Commands ### Client (React/Vite) ```bash cd client npm install npm run dev # Start dev server at http://localhost:5173 npm run build # TypeScript check + production build npm run lint # ESLint (strict, max-warnings 0) npm run format # Prettier formatting npm run format-check # Check formatting ``` ### Server (Node.js/Express) ```bash cd server npm install npm run dev # Start with hot-reload (nodemon + tsx) at http://localhost:52345 npm run build # TypeScript compile + path alias resolution npm run test # Run Mocha tests with c8 coverage npm run lint # ESLint v9 npm run lint-fix # Auto-fix lint issues npm run format # Prettier formatting ``` ### Docker Development ```bash cd docker/dev ./build_images.sh docker run -d -p 27017:27017 -v uptime_mongo_data:/data/db --name uptime_database_mongo mongo:6.0 ``` ## Environment Setup ### Server `.env` (minimum required) ```env CLIENT_HOST="http://localhost:5173" JWT_SECRET="my_secret_key_change_this" DB_CONNECTION_STRING="mongodb://localhost:27017/uptime_db" TOKEN_TTL="99d" ORIGIN="localhost" LOG_LEVEL="debug" ``` ### Client `.env` ```env VITE_APP_API_BASE_URL="http://localhost:52345/api/v1" VITE_APP_LOG_LEVEL="debug" ``` ## Architecture ### Monorepo Structure - `/client` - React 18 + TypeScript + Vite + MUI frontend - `/server` - Node.js 20+ + Express + TypeScript backend - `/docker` - Multi-environment Docker configs (dev, staging, prod, arm, mono) ### Backend Layers ``` server/src/ ├── controllers/ # Route handlers (authController, monitorController, etc.) ├── service/ # Business logic │ ├── business/ # Core monitoring logic │ ├── infrastructure/ # Server/system utilities │ └── system/ # App-level settings ├── db/ │ ├── models/ # Mongoose schemas (Monitor, Check, Incident, User, etc.) │ ├── migration/ # Database migrations (run on startup) │ └── modules/ # Database-specific modules ├── middleware/v1/ # verifyJWT, rateLimiter, sanitization, responseHandler ├── routes/v1/ # API route definitions ├── validation/ # Joi input validation schemas └── repositories/ # Data access layer ``` ### Frontend Structure ``` client/src/ ├── Components/ # Reusable UI components ├── Pages/ # Page components (Auth, Uptime, Infrastructure, Incidents, etc.) ├── Features/ # Redux slices (Auth, UI) ├── Hooks/ # Custom React hooks ├── Utils/ # Utilities (NetworkService.js is main API client) ├── Validation/ # Input validation └── locales/ # i18n translations ``` ### API - Base URL: `/api/v1` - Documentation: `http://localhost:52345/api-docs` (Swagger UI) - OpenAPI spec: `/server/openapi.json` ### Key Technologies - **State Management**: Redux Toolkit + Redux-Persist - **Data Fetching**: SWR + Axios - **Database**: MongoDB with Mongoose ODM - **Queue/Cache**: Redis + BullMQ + Pulse (cron scheduling) - **i18n**: i18next + react-i18next (translations via PoEditor) --- ## Backend Architecture Patterns ### Repository Pattern & Separation of Concerns The backend enforces a strict three-layer separation between HTTP handling, business logic, and data access: ``` Request → Controller → Service → Repository → MongoDB (Mongoose) ``` - **Controllers** (`/controllers`) handle HTTP concerns only: parsing request params, calling the appropriate service, and returning a response via the `responseHandler` middleware. They contain no business logic. - **Services** (`/service/business`) contain all business logic: deciding whether an incident should be created, whether a notification should fire, what state a monitor is in, etc. - **Repositories** (`/repositories`) are the sole layer that talks to MongoDB through Mongoose. They expose clean, reusable query methods (e.g. `findByMonitorId`, `createCheck`) so that services never construct raw DB queries directly. This separation makes each layer independently testable and keeps Mongoose-specific code out of business logic. When adding a new feature, the pattern to follow is: add a repository method for any new DB query, call it from a service, and expose it via a controller route. ### Monitoring Flow: From Check to Notification Background monitoring runs on a scheduled queue, not on the HTTP request cycle. The high-level flow for uptime monitoring is: ``` Pulse (cron) → BullMQ Job → StatusService ├── performs HTTP/port/ping check ├── saves Check via CheckRepository ├── evaluates monitor state change │ └── calls IncidentService (create / resolve incident) └── calls NotificationService (email, Slack, Discord, webhook) ``` 1. **Pulse** (cron scheduler) enqueues a job into a **BullMQ** queue for each active monitor at its configured interval. 2. A **BullMQ worker** picks up the job and calls `StatusService`, which performs the actual check (HTTP request, TCP port probe, ping, etc.). 3. The result is persisted as a `Check` document via the repository layer. 4. `StatusService` compares the new result against the monitor's previous state. If the monitor transitions from up → down (or down → up), it delegates to `IncidentService` to open or resolve an `Incident` document. 5. On a state change, `NotificationService` reads the monitor's configured `Notification` documents and dispatches alerts to all enabled channels (email, Discord, Slack, webhooks). ### Queue System (BullMQ + Redis) Redis serves two roles: job queue storage for BullMQ and ephemeral caching. BullMQ manages concurrency, retries, and backpressure for monitoring jobs, ensuring checks are processed reliably even under load. - Each monitor type (HTTP, port, ping, infrastructure) maps to its own queue worker so failures in one type don't block others. - Job scheduling interval is driven by the `interval` field on the `Monitor` model. - Failed jobs are retried with configurable backoff before being moved to a dead-letter state. - Redis is also used to cache frequently read data (e.g. aggregated stats) to reduce MongoDB query pressure. When working on anything related to check scheduling, incident lifecycle, or notifications, trace the flow starting from the relevant BullMQ worker rather than from the controller layer. --- ## Code Conventions ### Internationalization All user-facing strings must use the translation function: ```javascript t('your.key') // Never hardcode UI strings ``` ### Branching - Always branch from `develop` (not master) - Use descriptive names: `feat/add-alerts`, `fix/login-error` - PRs target `develop` branch ### Formatting - **Client**: Prettier with `printWidth: 90`, tabs, double quotes - **Server**: Prettier with `printWidth: 150`, tabs, double quotes - Both use ESLint with strict settings ### Testing Server tests use Mocha + Chai + Sinon: ```bash npm test # Run all tests with coverage npm test -- --grep "pattern" # Run specific tests ``` Test files: `server/tests/**/*.test.js` ## Database Models Key Mongoose models in `/server/src/db/models/`: - **Monitor** - Monitoring configuration (website, infrastructure, port, etc.) - **Check** - Individual monitoring check results - **Incident** - Downtime incidents - **User** - User accounts - **Team** - Team/workspace management - **StatusPage** - Public status pages - **Notification** - Alert configuration (email, Discord, Slack, webhooks) - **MaintenanceWindow** - Scheduled maintenance periods - **AppSettings** - Global application settings ## README.md

bluewave-labs%2Fcheckmate | Trendshift

![](https://img.shields.io/github/license/bluewave-labs/checkmate) ![](https://img.shields.io/github/repo-size/bluewave-labs/checkmate) ![](https://img.shields.io/github/commit-activity/m/bluewave-labs/checkmate) ![](https://img.shields.io/github/last-commit/bluewave-labs/checkmate) ![](https://img.shields.io/github/languages/top/bluewave-labs/checkmate) ![](https://img.shields.io/github/issues/bluewave-labs/checkmate) ![](https://img.shields.io/github/issues-pr/bluewave-labs/checkmate) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9901/badge)](https://www.bestpractices.dev/projects/9901) [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/bluewave-labs/checkmate)

Checkmate

An open source uptime and infrastructure monitoring application

image This repository contains both the frontend and the backend of Checkmate, an open-source, self-hosted monitoring tool for tracking server hardware, uptime, response times, and incidents in real-time with beautiful visualizations. Checkmate regularly checks whether a server/website is accessible and performs optimally, providing real-time alerts and reports on the monitored services' availability, downtime, and response time. Checkmate also has an agent, called [Capture](https://github.com/bluewave-labs/capture), to retrieve data from remote servers. While Capture is not required to run Checkmate, it provides additional insights about your servers' CPU, RAM, disk, and temperature status. Capture can run on Linux, Windows, Mac, Raspberry Pi, or any device that can run Go. Checkmate has been stress-tested with 1000+ active monitors without any particular issues or performance bottlenecks. **If you would like to sponsor a feature, [see this link](https://checkmate.so/sponsored-features).** ## 📚 Table of contents - [📦 Demo](#demo) - [🔗 User's guide](#users-guide) - [🛠️ Installation](#installation) - [🚀 Performance](#performance) - [💚 Questions & Ideas](#questions--ideas) - [🧩 Features](#features) - [🏗️ Screenshots](#screenshots) - [🏗️ Tech stack](#tech-stack) - [🔗 A few links](#a-few-links) - [🤝 Contributing](#contributing) - [💰 Our sponsors](#our-sponsors) ## Demo You can see the latest build of [Checkmate](https://checkmate-demo.bluewavelabs.ca/) in action. The username is demouser@demo.com and the password is Demouser1! (just a note that we update the demo server from time to time, so if it doesn't work for you, please ping us on the Discussions channel). ## User's guide Usage instructions can be found [here](https://checkmate.so/docs). ## Prerequisites - [Docker](https://www.docker.com/) installed - [Git](https://git-scm.com/) installed ## Installation See installation instructions in [Checkmate documentation portal](https://checkmate.so/docs). Alternatively, you can also use [Coolify](https://coolify.io/), [Elestio](https://elest.io/open-source/checkmate), [K8s](./charts/helm/checkmate/INSTALLATION.md), [Sive Host](https://sive.host) (South Africa), [Cloudzy](https://cloudzy.com/marketplace/checkmate) or [Pikapods](https://www.pikapods.com/) to quickly spin off a Checkmate instance. If you would like to monitor your server infrastructure, you'll need [Capture agent](https://github.com/bluewave-labs/capture). Capture repository also contains the installation instructions. ### Using a Custom CA If you need to monitor internal HTTPS endpoints with certificates from private Certificate Authorities (like Smallstep), see our [Custom CA Trust Guide](./docs/custom-ca-trust.md) for Docker configuration options. For more documentation, see the [docs directory](./docs/). ## Performance Thanks to extensive optimizations, Checkmate operates with an exceptionally small memory footprint, requiring minimal memory and CPU resources. Here’s the memory usage of a Node.js instance running on a server that monitors 323 servers every minute: ![image](https://github.com/user-attachments/assets/37e04a75-d83a-488f-b25c-025511b492c9) You can see the memory footprint of MongoDB and Redis on the same server (398Mb and 15Mb) for the same amount of servers: ![image](https://github.com/user-attachments/assets/3b469e85-e675-4040-a162-3f24c1afc751) ## Questions & Ideas If you have any questions, suggestions or comments, you have several options: - [Discord channel](https://discord.gg/NAb6H3UTjK) (preferred) - [GitHub Discussions](https://github.com/bluewave-labs/Checkmate/discussions) (we check here from time to time) Feel free to ask questions or share your ideas - we'd love to hear from you! ## Features - Completely open source, deployable on your servers or home devices (e.g Raspberry Pi 4 or 5) - Website monitoring - Page speed monitoring - Infrastructure monitoring (memory, disk usage, CPU performance, network etc) - requires [Capture](https://github.com/bluewave-labs/capture) agent - Selective disk monitoring with mountpoint selection - Docker monitoring - Ping monitoring - SSL monitoring - Port monitoring - Game server monitoring (3.0) - Incidents at a glance - Status pages - E-mail, Webhooks, Discord and Slack notifications - Scheduled maintenance - JSON query monitoring - Multi-language support for English, German, Japanese, Portuguese (Brazil), Russian, Turkish, Ukrainian, Vietnamese, Chinese (Traditional, Taiwan) **Short term roadmap:** - Plugins that will help Checkmate get any information from a remote service (e.g database, etc) - Better notifications - Network monitoring - ..and a few more features If you would like to sponsor an additional feature, [see this page](https://checkmate.so/sponsored-features). ## Screenshots

image

image

image

image

## Tech stack - [ReactJs](https://react.dev/) - [MUI (React framework)](https://mui.com/) - [Node.js](https://nodejs.org/en) - [MongoDB](https://mongodb.com) - [Recharts](https://recharts.org) - Lots of other open source components! ## A few links - If you would like to support us, please consider giving it a ⭐ and click on "watch". - Have a question or suggestion for the roadmap/featureset? Check our [Discord channel](https://discord.gg/NAb6H3UTjK) or [Discussions](https://github.com/bluewave-labs/checkmate/discussions) forum. - Need a ping when there's a new release? Use [Newreleases](https://newreleases.io/), a free service to track releases. - Watch a Checkmate [installation and usage video](https://www.youtube.com/watch?v=GfFOc0xHIwY) ## Contributing We are [Alex](http://github.com/ajhollid) (team lead), [Gorkem](http://github.com/gorkem-bwl/), [Aryaman](https://github.com/Br0wnHammer), [Mert](https://github.com/mertssmnoglu) and [Karen](https://github.com/karenvicent) helping individuals and businesses monitor their infra and servers. We pride ourselves on building strong connections with contributors at every level. Despite being a young project, Checkmate has already earned 7000+ stars and attracted 90+ contributors from around the globe. Our repo is starred by employees from **Google, Microsoft, Intel, Cisco, Tencent, Electronic Arts, ByteDance, JP Morgan Chase, Deloitte, Accenture, Foxconn, Broadcom, China Telecom, Barclays, Capgemini, Wipro, Cloudflare, Dassault Systèmes and NEC**, so don’t hold back — jump in, contribute and learn with us! Here's how you can contribute: 0. Star this repo :) 1. Check [Contributor's guideline](https://github.com/bluewave-labs/Checkmate/blob/develop/CONTRIBUTING.md). First timers are encouraged to check `good-first-issue` tag. 2. Read a detailed structure of [Checkmate](https://deepwiki.com/bluewave-labs/Checkmate) if you would like to deep dive into the architecture. 3. Open an issue if you believe you've encountered a bug. 4. Check for good-first-issue's if you are a newcomer. 5. Make a pull request to add new features/make quality-of-life improvements/fix bugs. 6. Check out this interactive walkthrough of the `Checkmate` codebase on CodeCanvas [here](https://www.code-canvas.com/?session=unauthenticatedGithub&repo=Checkmate&owner=bluewave-labs&branch=develop&OnboardingTutorial=true). To refine existing dataflow simulation or create new ones, follow the quick tutorial [here](https://docs.code-canvas.com/updating-diagram). [![Star History Chart](https://api.star-history.com/svg?repos=bluewave-labs/checkmate&type=Date)](https://star-history.com/#bluewave-labs/Checkmate&Date) ## Our sponsors Thanks to [Gitbook](https://gitbook.io/) for giving us a free tier for their documentation platform, and [Poeditor](https://poeditor.com/) providing us a free account to use their i18n services. If you would like to sponsor Checkmate, please send an email to hello@bluewavelabs.ca If you would like to sponsor a feature, [see this page](https://checkmate.so/sponsored-features).