Skip to content

WatchTower is a full-stack monitoring and authentication backend built with Bun, Express, Prisma, and PostgreSQL. It features secure user authentication, role management, and production-ready deployment using PM2, Nginx, and AWS EC2.

Notifications You must be signed in to change notification settings

kanhadewangan/WatchTower

Repository files navigation

WatchTower - Website Monitoring Application

A full-stack website monitoring application with real-time alerts, uptime tracking, and performance metrics. #Images -Dashboard image

-charts image

Features

  • 🔐 User Authentication (Register/Login)
  • 🌐 Website Management (Add, Edit, Delete)
  • 📊 Real-time Monitoring with multiple regions
  • 📈 Performance Metrics (Uptime, Response Time, Error Rate)
  • 📧 Email Alerts for downtime
  • 📉 Historical Data (1 hour, 24 hours, 7 days, 30 days)
  • 📱 Responsive Dashboard

Tech Stack

Backend

  • Node.js + Express
  • Prisma ORM
  • PostgreSQL
  • Redis (for caching)
  • Bull (for job queues)
  • JWT Authentication

Frontend

  • React 19
  • React Router v6
  • Axios
  • Recharts (for data visualization)
  • Tailwind CSS
  • Lucide React (icons)

Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • PostgreSQL
  • Redis (optional, for production)

Backend Setup

  1. Install backend dependencies:
npm install
  1. Set up environment variables (create .env file):
DATABASE_URL="postgresql://user:password@localhost:5432/watchtower"
JWT_SECRET="your-secret-key"
REDIS_HOST="localhost"
REDIS_PORT=6379
SMTP_HOST="smtp.gmail.com"
SMTP_PORT=587
SMTP_USER="your-email@gmail.com"
SMTP_PASS="your-app-password"
  1. Run Prisma migrations:
npx prisma migrate dev
  1. Generate Prisma Client:
npx prisma generate
  1. Start the backend server:
npm start

Backend will run on http://localhost:3000

Frontend Setup

  1. Navigate to frontend directory:
cd frontend
  1. Install frontend dependencies:
npm install
  1. Create .env file in frontend directory:
VITE_API_BASE_URL=http://localhost:3000/api/v1
  1. Start the frontend dev server:
npm run dev

Frontend will run on http://localhost:5173

API Endpoints

Authentication

  • POST /api/v1/users/register - Register new user
  • POST /api/v1/users/login - Login user

Websites

  • GET /api/v1/websites/websites - Get all websites
  • GET /api/v1/websites/website/:id - Get website by ID
  • POST /api/v1/websites/add-website - Add new website
  • PUT /api/v1/websites/update-website/:id - Update website
  • DELETE /api/v1/websites/delete-website/:id - Delete website

Checks/Monitoring

  • POST /api/v1/checks/add-check - Start monitoring a website
  • GET /api/v1/checks/checks/:websitename - Get all checks for a website
  • GET /api/v1/checks/uptime/:websitename - Get uptime metrics
  • GET /api/v1/checks/latest-check/:websitename - Get latest check
  • GET /api/v1/checks/last-1-hour/:websitename - Get checks from last hour
  • GET /api/v1/checks/last-24-hours/:websitename - Get checks from last 24 hours
  • GET /api/v1/checks/last-7-days/:websitename - Get checks from last 7 days
  • GET /api/v1/checks/last-30-days/:websitename - Get checks from last 30 days
  • DELETE /api/v1/checks/checks/:websitename - Delete all checks for a website

Running Tests

npm test

Project Structure

better/
├── models/
│   ├── controller/        # Route handlers
│   ├── service/           # Business logic services
│   └── auth/             # Authentication middleware
├── prisma/
│   ├── schema.prisma     # Database schema
│   └── migrations/       # Database migrations
├── testing/              # Test files
├── frontend/
│   ├── src/
│   │   ├── components/   # Reusable components
│   │   ├── pages/        # Page components
│   │   ├── services/     # API services
│   │   ├── context/      # React context
│   │   └── config/       # Configuration files
│   └── public/
└── index.js              # Backend entry point

Available Monitoring Regions

  • US_EAST_1 (US East)
  • US_WEST_1 (US West)
  • EU_WEST_1 (Europe West)
  • AP_SOUTHEAST_1 (Asia Pacific Southeast)

License

MIT

About

WatchTower is a full-stack monitoring and authentication backend built with Bun, Express, Prisma, and PostgreSQL. It features secure user authentication, role management, and production-ready deployment using PM2, Nginx, and AWS EC2.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages