From 0f8b86c25304c07b5825cd7bd1ea7bea6c300c75 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Tue, 26 Aug 2025 10:25:12 +0200 Subject: [PATCH] chore(docs): remove AGENTS.md file; enhance CLAUDE.md with detailed form authorization patterns and service configuration examples --- .cursor/rules/form-components.mdc | 21 +++++++ AGENTS.md | 93 ------------------------------- CLAUDE.md | 43 ++++++++++++++ 3 files changed, 64 insertions(+), 93 deletions(-) delete mode 100644 AGENTS.md diff --git a/.cursor/rules/form-components.mdc b/.cursor/rules/form-components.mdc index d56480823..665ccfd98 100644 --- a/.cursor/rules/form-components.mdc +++ b/.cursor/rules/form-components.mdc @@ -414,6 +414,27 @@ test('application form respects member permissions', function () { Save ``` +### Service Configuration Forms +```html + + + + +Save + + + + + +@can('update', $service) + +@endcan +``` + ### Server Management Forms ```html diff --git a/AGENTS.md b/AGENTS.md deleted file mode 100644 index 6a2e0fa6b..000000000 --- a/AGENTS.md +++ /dev/null @@ -1,93 +0,0 @@ -# AGENTS.md - -This file provides guidance to OpenCode when working with code in this repository. - -## Project Overview - -Coolify is an open-source, self-hostable platform for deploying applications and managing servers - an alternative to Heroku/Netlify/Vercel. It's built with Laravel (PHP) and uses Docker for containerization. - -## Development Commands - -### Frontend Development -- `npm run dev` - Start Vite development server for frontend assets -- `npm run build` - Build frontend assets for production - -### Backend Development -Only run artisan commands inside "coolify" container when in development. -- `php artisan serve` - Start Laravel development server -- `php artisan migrate` - Run database migrations -- `php artisan queue:work` - Start queue worker for background jobs -- `php artisan horizon` - Start Laravel Horizon for queue monitoring -- `php artisan tinker` - Start interactive PHP REPL - -### Code Quality -- `./vendor/bin/pint` - Run Laravel Pint for code formatting -- `./vendor/bin/phpstan` - Run PHPStan for static analysis -- `./vendor/bin/pest` - Run Pest tests - -## Architecture Overview - -### Technology Stack -- **Backend**: Laravel 12 (PHP 8.4) -- **Frontend**: Livewire + Alpine.js + Tailwind CSS -- **Database**: PostgreSQL 15 -- **Cache/Queue**: Redis 7 -- **Real-time**: Soketi (WebSocket server) -- **Containerization**: Docker & Docker Compose - -### Key Components - -#### Core Models -- `Application` - Deployed applications with Git integration -- `Server` - Remote servers managed by Coolify -- `Service` - Docker Compose services -- `Database` - Standalone database instances (PostgreSQL, MySQL, MongoDB, Redis, etc.) -- `Team` - Multi-tenancy support -- `Project` - Grouping of environments and resources - -#### Job System -- Uses Laravel Horizon for queue management -- Key jobs: `ApplicationDeploymentJob`, `ServerCheckJob`, `DatabaseBackupJob` -- `ServerManagerJob` and `ServerConnectionCheckJob` handle job scheduling - -#### Deployment Flow -1. Git webhook triggers deployment -2. `ApplicationDeploymentJob` handles build and deployment -3. Docker containers are managed on target servers -4. Proxy configuration (Nginx/Traefik) is updated - -#### Server Management -- SSH-based server communication via `ExecuteRemoteCommand` trait -- Docker installation and management -- Proxy configuration generation -- Resource monitoring and cleanup - -### Directory Structure -- `app/Actions/` - Domain-specific actions (Application, Database, Server, etc.) -- `app/Jobs/` - Background queue jobs -- `app/Livewire/` - Frontend components (full-stack with Livewire) -- `app/Models/` - Eloquent models -- `bootstrap/helpers/` - Helper functions for various domains -- `database/migrations/` - Database schema evolution - -## Development Guidelines - -### Code Organization -- Use Actions pattern for complex business logic -- Livewire components handle UI and user interactions -- Jobs handle asynchronous operations -- Traits provide shared functionality (e.g., `ExecuteRemoteCommand`) - -### Testing -- Uses Pest for testing framework -- Tests located in `tests/` directory - -### Deployment and Docker -- Applications are deployed using Docker containers -- Configuration generated dynamically based on application settings -- Supports multiple deployment targets and proxy configurations - -## Cloud instance -We have a cloud instance of Coolify, a hosted Coolify. -This consists of 2 horizon worker servers. -It has thousands of servers connected, thousands of users, so make sure develop features to that usecase. \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md index 5f9b96718..4458d4d46 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -86,6 +86,49 @@ Coolify uses a **server-side first** approach with minimal JavaScript: - **Enhanced Form Components** with built-in authorization system - Real-time updates via WebSocket without page refreshes +### Form Authorization Pattern +**IMPORTANT**: When creating or editing forms, ALWAYS include authorization: + +#### For Form Components (Input, Select, Textarea, Checkbox, Button): +Use `canGate` and `canResource` attributes for automatic authorization: +```html + +... + +Save +``` + +#### For Modal Components: +Wrap with `@can` directives: +```html +@can('update', $resource) + ... + ... +@endcan +``` + +#### In Livewire Components: +Always add the `AuthorizesRequests` trait and check permissions: +```php +use Illuminate\Foundation\Auth\Access\AuthorizesRequests; + +class MyComponent extends Component +{ + use AuthorizesRequests; + + public function mount() + { + $this->authorize('view', $this->resource); + } + + public function update() + { + $this->authorize('update', $this->resource); + // ... update logic + } +} +``` + ### Livewire Component Structure - Components located in `app/Livewire/` - Views in `resources/views/livewire/`