Files
web-petting/CLAUDE.md
T

61 lines
2.5 KiB
Markdown
Raw Permalink Normal View History

2026-04-29 17:49:07 +03:00
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
Pet sitting web service for managing clients and bookings. The owner uses the site to:
- Receive and manage client requests (leads) from the website
- Schedule calls and visits with clients
- Upload photos/videos of pets for remote viewing by clients (public media page via unique token)
- Get Telegram notifications about new requests
## Tech Stack
- **Language:** Rust (edition 2024)
2026-07-11 14:11:31 +03:00
- **Web framework:** [Cot](https://github.com/cot-rs/cot) - Rust web framework (Django-like), local path `../cot/cot`
- **Database:** PostgreSQL (via Cot ORM)
2026-04-29 17:49:07 +03:00
- **Notifications:** Telegram Bot API
## Build & Run
```sh
2026-07-11 14:11:31 +03:00
cargo build # build
cargo run # run dev server at http://127.0.0.1:8000
cargo test # run all tests
cargo test <name> # run a single test by name
cargo clippy # lint
cargo fmt --check # check formatting
cot migration make # generate migrations from model changes (requires cot-cli)
```
Set `WEB_PETTING_DATABASE_URL` (or `DATABASE_URL`) before running the app or migrations. Example:
```sh
WEB_PETTING_DATABASE_URL=postgresql://postgres:postgres@localhost:5432/web_petting cargo run
2026-04-29 17:49:07 +03:00
```
## Architecture
2026-07-11 14:11:31 +03:00
Monolithic Cot web app with a single PostgreSQL database.
2026-04-29 17:49:07 +03:00
2026-07-11 14:11:31 +03:00
- `src/main.rs` - project/app setup, router, config
- `src/models.rs` - all database models (Lead, Client, Visit, Media, User, Setting)
- `src/migrations.rs` - migration registry
- `src/migrations/` - migration files
2026-04-29 17:49:07 +03:00
## Database Design Principles
- **Soft-delete everywhere:** records are never physically deleted, only status changes (e.g. `active` -> `archived`, `new` -> `rejected`). This ensures data can always be recovered.
- **Status fields** are stored as `String` with enum-like values defined in `models.rs`.
- **Foreign keys** use `cot::db::ForeignKey<T>` with `Restrict` on delete/update.
## Data Model
2026-07-11 14:11:31 +03:00
- **Lead** (`new`/`in_progress`/`converted`/`rejected`) - public form submission; links to Client when converted
- **Client** (`active`/`archived`) - confirmed client with `media_token` for public media page
- **Visit** (`scheduled`/`completed`/`cancelled`/`deleted`) - pet sitting session, belongs to Client and User
- **Media** (`active`/`archived`) - photo/video, belongs to Client, optionally to Visit
- **User** (`active`/`archived`) - admin accounts (supports multiple admins)
- **Setting** - global key-value config (telegram_bot_token, telegram_chat_id, etc.)