Root CLAUDE.md reduced from 475 to 175 lines (75 excl. GitNexus). Detailed context now loads automatically only when editing code in the relevant directory: - provisioning/CLAUDE.md — env vars, provisioning flow, lifecycle - config/CLAUDE.md — auth, scopes, JWT, OIDC role extraction - docker/CLAUDE.md — routing, networks, bootstrap, deployment pipeline - installer/CLAUDE.md — deployment modes, compose templates, env naming - ui/CLAUDE.md — frontend files, sign-in UI No information lost — everything moved, nothing deleted. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
176 lines
11 KiB
Markdown
176 lines
11 KiB
Markdown
# CLAUDE.md
|
|
|
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
|
|
## Project
|
|
|
|
Cameleer SaaS — **vendor management plane** for the Cameleer observability stack. Two personas: **vendor** (platform:admin) manages the platform and provisions tenants; **tenant admin** (tenant:manage) manages their observability instance. The vendor creates tenants, which provisions per-tenant cameleer-server + UI instances via Docker API. No example tenant — clean slate bootstrap, vendor creates everything.
|
|
|
|
## Ecosystem
|
|
|
|
This repo is the SaaS layer on top of two proven components:
|
|
|
|
- **cameleer** (sibling repo) — Java agent using ByteBuddy for zero-code instrumentation of Camel apps. Captures route executions, processor traces, payloads, metrics, and route graph topology. Deploys as `-javaagent` JAR.
|
|
- **cameleer-server** (sibling repo) — Spring Boot observability backend. Receives agent data via HTTP, pushes config/commands via SSE. PostgreSQL + ClickHouse storage. React SPA dashboard. JWT auth with Ed25519 config signing. Docker container orchestration for app deployments.
|
|
- **cameleer-website** — Marketing site (Astro 5)
|
|
- **design-system** — Shared React component library (`@cameleer/design-system` on Gitea npm registry)
|
|
|
|
Agent-server protocol is defined in `cameleer/cameleer-common/PROTOCOL.md`. The agent and server are mature, proven components — this repo wraps them with multi-tenancy, billing, and self-service onboarding.
|
|
|
|
## Key Packages
|
|
|
|
### Java Backend (`src/main/java/net/siegeln/cameleer/saas/`)
|
|
|
|
| Package | Purpose | Key classes |
|
|
|---------|---------|-------------|
|
|
| `config/` | Security, tenant isolation, web config | `SecurityConfig`, `TenantIsolationInterceptor`, `TenantContext`, `PublicConfigController`, `MeController` |
|
|
| `tenant/` | Tenant data model | `TenantEntity` (JPA: id, name, slug, tier, status, logto_org_id, db_password) |
|
|
| `vendor/` | Vendor console (platform:admin) | `VendorTenantService`, `VendorTenantController`, `InfrastructureService` |
|
|
| `portal/` | Tenant admin portal (org-scoped) | `TenantPortalService`, `TenantPortalController` |
|
|
| `provisioning/` | Pluggable tenant provisioning | `DockerTenantProvisioner`, `TenantDatabaseService`, `TenantDataCleanupService` |
|
|
| `certificate/` | TLS certificate lifecycle | `CertificateService`, `CertificateController`, `TenantCaCertService` |
|
|
| `license/` | License management | `LicenseService`, `LicenseController` |
|
|
| `identity/` | Logto & server integration | `LogtoManagementClient`, `ServerApiClient` |
|
|
| `audit/` | Audit logging | `AuditService` |
|
|
|
|
### Frontend
|
|
|
|
- **`ui/src/`** — React 19 SPA at `/platform/*` (vendor + tenant admin pages)
|
|
- **`ui/sign-in/`** — Custom Logto sign-in UI (built into `cameleer-logto` Docker image)
|
|
|
|
## Architecture Context
|
|
|
|
The SaaS platform is a **vendor management plane**. It does not proxy requests to servers — instead it provisions dedicated per-tenant cameleer-server instances via Docker API. Each tenant gets isolated server + UI containers with their own database schemas, networks, and Traefik routing.
|
|
|
|
For detailed architecture docs, see the directory-scoped CLAUDE.md files (loaded automatically when editing code in that directory):
|
|
- **Provisioning flow, env vars, lifecycle** → `src/.../provisioning/CLAUDE.md`
|
|
- **Auth, scopes, JWT, OIDC** → `src/.../config/CLAUDE.md`
|
|
- **Docker, routing, networks, bootstrap, deployment pipeline** → `docker/CLAUDE.md`
|
|
- **Installer, deployment modes, compose templates** → `installer/CLAUDE.md`
|
|
- **Frontend, sign-in UI** → `ui/CLAUDE.md`
|
|
|
|
## Database Migrations
|
|
|
|
PostgreSQL (Flyway): `src/main/resources/db/migration/`
|
|
- V001 — consolidated baseline: tenants (with db_password, server_endpoint, provision_error, ca_applied_at), licenses, audit_log, certificates, tenant_ca_certs
|
|
|
|
## Related Conventions
|
|
|
|
- Gitea-hosted: `gitea.siegeln.net/cameleer/`
|
|
- CI: `.gitea/workflows/` — Gitea Actions
|
|
- K8s target: k3s cluster at 192.168.50.86
|
|
- Docker images: CI builds and pushes all images — Dockerfiles use multi-stage builds, no local builds needed
|
|
- `cameleer-saas` — SaaS vendor management plane (frontend + JAR baked in)
|
|
- `cameleer-logto` — custom Logto with sign-in UI baked in
|
|
- `cameleer-server` / `cameleer-server-ui` — provisioned per-tenant (not in compose, created by `DockerTenantProvisioner`)
|
|
- `cameleer-runtime-base` — base image for deployed apps (agent JAR + `cameleer-log-appender.jar` + JRE). CI downloads latest agent and log appender SNAPSHOTs from Gitea Maven registry. The Dockerfile ENTRYPOINT is overridden by `DockerRuntimeOrchestrator` at container creation; agent config uses `CAMELEER_AGENT_*` env vars set by `DeploymentExecutor`.
|
|
- Docker builds: `--no-cache`, `--provenance=false` for Gitea compatibility
|
|
- `docker-compose.dev.yml` — exposes ports for direct access, sets `SPRING_PROFILES_ACTIVE: dev`. Volume-mounts `./ui/dist` into the container so local UI builds are served without rebuilding the Docker image (`SPRING_WEB_RESOURCES_STATIC_LOCATIONS` overrides classpath). Adds Docker socket mount for tenant provisioning.
|
|
- Design system: import from `@cameleer/design-system` (Gitea npm registry)
|
|
|
|
## Disabled Skills
|
|
|
|
- Do NOT use any `gsd:*` skills in this project. This includes all `/gsd:` prefixed commands.
|
|
|
|
<!-- gitnexus:start -->
|
|
# GitNexus — Code Intelligence
|
|
|
|
This project is indexed by GitNexus as **cameleer-saas** (2816 symbols, 5989 relationships, 238 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
|
|
|
|
> If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first.
|
|
|
|
## Always Do
|
|
|
|
- **MUST run impact analysis before editing any symbol.** Before modifying a function, class, or method, run `gitnexus_impact({target: "symbolName", direction: "upstream"})` and report the blast radius (direct callers, affected processes, risk level) to the user.
|
|
- **MUST run `gitnexus_detect_changes()` before committing** to verify your changes only affect expected symbols and execution flows.
|
|
- **MUST warn the user** if impact analysis returns HIGH or CRITICAL risk before proceeding with edits.
|
|
- When exploring unfamiliar code, use `gitnexus_query({query: "concept"})` to find execution flows instead of grepping. It returns process-grouped results ranked by relevance.
|
|
- When you need full context on a specific symbol — callers, callees, which execution flows it participates in — use `gitnexus_context({name: "symbolName"})`.
|
|
|
|
## When Debugging
|
|
|
|
1. `gitnexus_query({query: "<error or symptom>"})` — find execution flows related to the issue
|
|
2. `gitnexus_context({name: "<suspect function>"})` — see all callers, callees, and process participation
|
|
3. `READ gitnexus://repo/cameleer-saas/process/{processName}` — trace the full execution flow step by step
|
|
4. For regressions: `gitnexus_detect_changes({scope: "compare", base_ref: "main"})` — see what your branch changed
|
|
|
|
## When Refactoring
|
|
|
|
- **Renaming**: MUST use `gitnexus_rename({symbol_name: "old", new_name: "new", dry_run: true})` first. Review the preview — graph edits are safe, text_search edits need manual review. Then run with `dry_run: false`.
|
|
- **Extracting/Splitting**: MUST run `gitnexus_context({name: "target"})` to see all incoming/outgoing refs, then `gitnexus_impact({target: "target", direction: "upstream"})` to find all external callers before moving code.
|
|
- After any refactor: run `gitnexus_detect_changes({scope: "all"})` to verify only expected files changed.
|
|
|
|
## Never Do
|
|
|
|
- NEVER edit a function, class, or method without first running `gitnexus_impact` on it.
|
|
- NEVER ignore HIGH or CRITICAL risk warnings from impact analysis.
|
|
- NEVER rename symbols with find-and-replace — use `gitnexus_rename` which understands the call graph.
|
|
- NEVER commit changes without running `gitnexus_detect_changes()` to check affected scope.
|
|
|
|
## Tools Quick Reference
|
|
|
|
| Tool | When to use | Command |
|
|
|------|-------------|---------|
|
|
| `query` | Find code by concept | `gitnexus_query({query: "auth validation"})` |
|
|
| `context` | 360-degree view of one symbol | `gitnexus_context({name: "validateUser"})` |
|
|
| `impact` | Blast radius before editing | `gitnexus_impact({target: "X", direction: "upstream"})` |
|
|
| `detect_changes` | Pre-commit scope check | `gitnexus_detect_changes({scope: "staged"})` |
|
|
| `rename` | Safe multi-file rename | `gitnexus_rename({symbol_name: "old", new_name: "new", dry_run: true})` |
|
|
| `cypher` | Custom graph queries | `gitnexus_cypher({query: "MATCH ..."})` |
|
|
|
|
## Impact Risk Levels
|
|
|
|
| Depth | Meaning | Action |
|
|
|-------|---------|--------|
|
|
| d=1 | WILL BREAK — direct callers/importers | MUST update these |
|
|
| d=2 | LIKELY AFFECTED — indirect deps | Should test |
|
|
| d=3 | MAY NEED TESTING — transitive | Test if critical path |
|
|
|
|
## Resources
|
|
|
|
| Resource | Use for |
|
|
|----------|---------|
|
|
| `gitnexus://repo/cameleer-saas/context` | Codebase overview, check index freshness |
|
|
| `gitnexus://repo/cameleer-saas/clusters` | All functional areas |
|
|
| `gitnexus://repo/cameleer-saas/processes` | All execution flows |
|
|
| `gitnexus://repo/cameleer-saas/process/{name}` | Step-by-step execution trace |
|
|
|
|
## Self-Check Before Finishing
|
|
|
|
Before completing any code modification task, verify:
|
|
1. `gitnexus_impact` was run for all modified symbols
|
|
2. No HIGH/CRITICAL risk warnings were ignored
|
|
3. `gitnexus_detect_changes()` confirms changes match expected scope
|
|
4. All d=1 (WILL BREAK) dependents were updated
|
|
|
|
## Keeping the Index Fresh
|
|
|
|
After committing code changes, the GitNexus index becomes stale. Re-run analyze to update it:
|
|
|
|
```bash
|
|
npx gitnexus analyze
|
|
```
|
|
|
|
If the index previously included embeddings, preserve them by adding `--embeddings`:
|
|
|
|
```bash
|
|
npx gitnexus analyze --embeddings
|
|
```
|
|
|
|
To check whether embeddings exist, inspect `.gitnexus/meta.json` — the `stats.embeddings` field shows the count (0 means no embeddings). **Running analyze without `--embeddings` will delete any previously generated embeddings.**
|
|
|
|
> Claude Code users: A PostToolUse hook handles this automatically after `git commit` and `git merge`.
|
|
|
|
## CLI
|
|
|
|
| Task | Read this skill file |
|
|
|------|---------------------|
|
|
| Understand architecture / "How does X work?" | `.claude/skills/gitnexus/gitnexus-exploring/SKILL.md` |
|
|
| Blast radius / "What breaks if I change X?" | `.claude/skills/gitnexus/gitnexus-impact-analysis/SKILL.md` |
|
|
| Trace bugs / "Why is X failing?" | `.claude/skills/gitnexus/gitnexus-debugging/SKILL.md` |
|
|
| Rename / extract / split / refactor | `.claude/skills/gitnexus/gitnexus-refactoring/SKILL.md` |
|
|
| Tools, resources, schema reference | `.claude/skills/gitnexus/gitnexus-guide/SKILL.md` |
|
|
| Index, status, clean, wiki CLI commands | `.claude/skills/gitnexus/gitnexus-cli/SKILL.md` |
|
|
|
|
<!-- gitnexus:end -->
|