Trey t eb127fda20 Add real-time log monitoring and system stats dashboard
Implements a comprehensive monitoring system for the admin interface:

Backend:
- New monitoring package with Redis ring buffer for log storage
- Zerolog MultiWriter to capture logs to Redis
- System stats collection (CPU, memory, disk, goroutines, GC)
- HTTP metrics middleware (request counts, latency, error rates)
- Asynq queue stats for worker process
- WebSocket endpoint for real-time log streaming
- Admin auth middleware now accepts token in query params (for WebSocket)

Frontend:
- New monitoring page with tabs (Overview, Logs, API Stats, Worker Stats)
- Real-time log viewer with level filtering and search
- System stats cards showing CPU, memory, goroutines, uptime
- HTTP endpoint statistics table
- Asynq queue depth visualization
- Enable/disable monitoring toggle in settings

Memory safeguards:
- Max 200 unique endpoints tracked
- Hourly stats reset to prevent unbounded growth
- Max 1000 log entries in ring buffer
- Max 1000 latency samples for P95 calculation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-09 10:26:40 -06:00
2025-11-28 21:10:48 -06:00
2025-12-04 21:11:23 -06:00
2025-11-28 21:10:48 -06:00
2025-11-26 21:05:21 -06:00
2025-11-28 21:10:48 -06:00
2025-11-28 00:27:41 -06:00

Casera API (Go)

Go implementation of the Casera property management API, built with Gin, GORM, and GoAdmin.

Tech Stack

  • HTTP Framework: Gin
  • ORM: GORM with PostgreSQL
  • Push Notifications: Direct APNs (via apns2) + FCM HTTP API
  • Admin Panel: GoAdmin
  • Background Jobs: Asynq
  • Caching: Redis
  • Logging: zerolog
  • Configuration: Viper

Quick Start

Prerequisites

  • Go 1.21+
  • PostgreSQL 15+
  • Redis 7+

Development Setup

# Install dependencies
make deps

# Copy environment file
cp .env.example .env
# Edit .env with your configuration

# Run the API server
make run

Docker Setup

# Start all services
make docker-up

# View logs
make docker-logs

# Stop services
make docker-down

Project Structure

myCribAPI-go/
├── cmd/
│   ├── api/main.go          # API server entry point
│   ├── worker/main.go       # Background worker entry point
│   └── admin/main.go        # GoAdmin server entry point
├── internal/
│   ├── config/              # Configuration management
│   ├── models/              # GORM models
│   ├── database/            # Database connection
│   ├── repositories/        # Data access layer
│   ├── services/            # Business logic
│   ├── handlers/            # HTTP handlers
│   ├── middleware/          # Gin middleware
│   ├── dto/                 # Request/Response DTOs
│   ├── router/              # Route setup
│   ├── push/                # APNs/FCM push notifications
│   ├── worker/              # Asynq jobs
│   └── admin/               # GoAdmin tables
├── pkg/
│   ├── utils/               # Utilities
│   └── errors/              # Error types
├── migrations/              # SQL migrations
├── templates/emails/        # Email templates
├── docker/                  # Docker files
├── go.mod
└── Makefile

API Endpoints

The API maintains 100% compatibility with the Django version.

Public Endpoints (No Auth)

  • GET /api/health/ - Health check
  • POST /api/auth/login/ - Login
  • POST /api/auth/register/ - Register
  • GET /api/static_data/ - Cached lookups

Protected Endpoints (Token Auth)

  • GET /api/residences/ - List residences
  • GET /api/tasks/ - List tasks
  • GET /api/tasks/by-residence/:id/ - Kanban board
  • See full API documentation in the Django project

Configuration

Environment variables (see .env.example):

Variable Description Default
PORT Server port 8000
DEBUG Debug mode false
SECRET_KEY JWT secret required
POSTGRES_* Database config -
REDIS_URL Redis URL redis://localhost:6379/0
APNS_* iOS push config -
FCM_SERVER_KEY Android push key -

Development

# Run tests
make test

# Run tests with coverage
make test-coverage

# Run linter
make lint

# Format code
make fmt

Database

This Go version uses the same PostgreSQL database as the Django version. GORM models are mapped to Django's table names:

  • auth_user - Django's User model
  • user_authtoken - Auth tokens
  • residence_residence - Residences
  • task_task - Tasks

Seeding Data

Seed files are located in seeds/:

  • 001_lookups.sql - Lookup tables (residence types, task categories, priorities, etc.)
  • 002_test_data.sql - Test users, residences, tasks, contractors, etc.

Local Development

# Seed lookup tables
./dev.sh seed

# Seed test data
./dev.sh seed-test

Production (Dokku)

# Seed lookup tables (required)
cat seeds/001_lookups.sql | dokku postgres:connect casera-db

# Seed test data
cat seeds/002_test_data.sql | dokku postgres:connect casera-db

Test Users

All test users have password: password123

Username Email Tier Notes
admin admin@example.com Pro Admin user
john john@example.com Pro Owns 2 residences
jane jane@example.com Free Owns 1 residence, shared access to residence 1
bob bob@example.com Free Owns 1 residence

Test Data Includes

  • 4 residences (house, beach house, apartment, condo)
  • 4 contractors with specialties
  • 10 tasks across residences
  • Documents/warranties
  • Notifications

Migration from Django

This is a full rewrite that maintains API compatibility. The mobile clients (KMM) work with both versions without changes.

License

Proprietary - Casera

Description
No description provided
Readme 3.4 MiB
Languages
Go 75.5%
TypeScript 20.3%
Shell 2.4%
HTML 0.7%
CSS 0.7%
Other 0.2%