# Contributing to Observer Lite Thank you for taking the time to contribute! Observer Lite is a self-hosted uptime monitoring tool built with Python/FastAPI and Vue 3. Contributions of all kinds are welcome — bug fixes, new features, documentation improvements, and test coverage. ## Table of Contents - [Getting Started](#getting-started) - [Development Setup](#development-setup) - [Project Structure](#project-structure) - [Coding Standards](#coding-standards) - [Running Tests](#running-tests) - [Submitting a Pull Request](#submitting-a-pull-request) - [Reporting Bugs](#reporting-bugs) - [Feature Requests](#feature-requests) --- ## Getting Started 1. **Fork** the repository on GitHub. 2. **Clone** your fork locally: ```bash git clone https://github.com//observer-lite.git cd observer-lite ``` 3. Create a feature branch: ```bash git checkout -b feat/your-feature-name ``` --- ## Development Setup ### Backend (Python 3.12+) ```bash cd backend # Create a virtual environment (uv is recommended, pip works too) python3.12 -m venv .venv source .venv/bin/activate # Install dependencies in editable mode pip install -e ".[dev]" # Apply database migrations DATABASE_URL="sqlite+aiosqlite:////tmp/observer_dev.db" \ DATABASE_PATH="/tmp/observer_dev.db" \ alembic upgrade head # Start the backend DATABASE_URL="sqlite+aiosqlite:////tmp/observer_dev.db" \ DATABASE_PATH="/tmp/observer_dev.db" \ SECRET_KEY="dev-secret-do-not-use-in-prod" \ PORT=8080 \ uvicorn app.main:app --host 127.0.0.1 --port 8080 --reload --workers 1 ``` > **`--workers 1` is required.** APScheduler and the SSE broadcaster are in-process; multiple workers cause duplicate checks and missed events. ### Frontend (Node 20+) ```bash cd frontend npm install npm run dev # Vite dev server at http://localhost:5173 # API proxied to http://localhost:8080 ``` Open **http://localhost:5173** in your browser. Default credentials: `admin` / `admin`. You will be prompted to change the password on first login. --- ## Project Structure ``` observer-lite/ ├── backend/ │ ├── app/ │ │ ├── checkers/ # Monitor type implementations (HTTP, Ping, SSL, Heartbeat) │ │ ├── db/ # SQLAlchemy models and async session factory │ │ ├── routers/ # FastAPI routers (one per resource) │ │ ├── schemas/ # Pydantic v2 request/response schemas │ │ ├── services/ # Business logic (check processing, notifications, stats) │ │ ├── scheduler/ # APScheduler engine, job manager, and job functions │ │ ├── sse/ # Server-Sent Events broadcaster │ │ └── utils/ # Crypto helpers, pagination │ ├── alembic/ # Database migrations │ └── tests/ # pytest test suite └── frontend/ └── src/ ├── api/ # Axios API clients ├── components/ # Reusable Vue components ├── pages/ # Route-level page components ├── router/ # Vue Router configuration and guards └── stores/ # Pinia state stores ``` --- ## Coding Standards ### Python - **Style:** Follow [PEP 8](https://peps.python.org/pep-0008/). We use `ruff` for linting and formatting. ```bash cd backend ruff check app/ ruff format app/ ``` - **Type hints:** All public functions must have full type annotations. - **Docstrings:** Use [Google-style docstrings](https://google.github.io/styleguide/pyguide.html#383-functions-and-methods) for all public modules, classes, and functions. - **Async:** All DB operations and external I/O must be `async`. Never call blocking code on the event loop without `asyncio.to_thread`. - **Security:** Never log request bodies, passwords, or tokens. Validate all user-controlled input with Pydantic. ### TypeScript / Vue - **Style:** ESLint + Prettier (configured in the project). ```bash cd frontend npm run lint npm run type-check ``` - **Components:** Use `