|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | +This is a Ruby on Rails 8.0 application built on the Bullet Train framework. It integrates with ClickFunnels for user management and power user tracking. |
| 7 | + |
| 8 | +## Development Commands |
| 9 | + |
| 10 | +### Setup |
| 11 | +```bash |
| 12 | +bin/setup # Initial setup (installs dependencies, creates database) |
| 13 | +bin/rails db:seed # Seed database with sample data |
| 14 | +``` |
| 15 | + |
| 16 | +### Running the Application |
| 17 | +```bash |
| 18 | +bin/dev # Start development server with Procfile.dev (includes Sidekiq, CSS/JS watching) |
| 19 | +bin/rails server # Start only Rails server |
| 20 | +``` |
| 21 | + |
| 22 | +### Testing |
| 23 | +```bash |
| 24 | +bin/rails test # Run all tests |
| 25 | +bin/rails test test/path/to/specific_test.rb # Run specific test file |
| 26 | +bin/rails test test/path/to/test.rb:42 # Run specific test at line 42 |
| 27 | +MAGIC_TEST=1 bin/rails test:system # Record system tests with Magic Test |
| 28 | +``` |
| 29 | + |
| 30 | +### Code Quality |
| 31 | +```bash |
| 32 | +bundle exec standardrb # Run Ruby linter |
| 33 | +bundle exec standardrb --fix # Auto-fix Ruby linting issues |
| 34 | +``` |
| 35 | + |
| 36 | +### Database |
| 37 | +```bash |
| 38 | +bin/rails db:migrate # Run pending migrations |
| 39 | +bin/rails db:rollback # Rollback last migration |
| 40 | +bin/rails db:schema:dump # Update db/schema.rb |
| 41 | +``` |
| 42 | + |
| 43 | +### Background Jobs |
| 44 | +```bash |
| 45 | +bundle exec sidekiq # Run Sidekiq (included in bin/dev) |
| 46 | +``` |
| 47 | + |
| 48 | +### Deployment |
| 49 | +```bash |
| 50 | +bin/kamal deploy # Deploy to production using Kamal |
| 51 | +``` |
| 52 | + |
| 53 | +## Architecture Overview |
| 54 | + |
| 55 | +### Bullet Train Framework |
| 56 | +Bullet Train is a comprehensive Ruby on Rails SaaS framework that provides extensive built-in functionality. This application leverages: |
| 57 | + |
| 58 | +**Core Features**: |
| 59 | +- Multi-tenancy with Teams and membership-based permissions |
| 60 | +- User authentication with Devise |
| 61 | +- OAuth integration via Doorkeeper |
| 62 | +- Webhook handling (incoming and outgoing) |
| 63 | +- Admin panel via Avo |
| 64 | +- API versioning structure |
| 65 | +- Role-based access control with granular permissions |
| 66 | +- Onboarding workflows |
| 67 | +- Billing system integration (Stripe) |
| 68 | +- Zapier integration support |
| 69 | + |
| 70 | +**Super Scaffolding**: |
| 71 | +Bullet Train's code generation engine that creates complete CRUD interfaces. Key commands: |
| 72 | + |
| 73 | +```bash |
| 74 | +# Generate new model with CRUD interface |
| 75 | +rails generate super_scaffold ModelName Team field:field_type |
| 76 | + |
| 77 | +# Add field to existing model |
| 78 | +rails generate super_scaffold:field ModelName field:field_type |
| 79 | + |
| 80 | +# Available field types: text_field, trix_editor, buttons, super_select, image |
| 81 | +``` |
| 82 | + |
| 83 | +Example: |
| 84 | +```bash |
| 85 | +# Create a Project model under Team |
| 86 | +rails generate super_scaffold Project Team name:text_field description:trix_editor |
| 87 | +rake db:migrate |
| 88 | + |
| 89 | +# Add status field with button options |
| 90 | +rails generate super_scaffold:field Project status:buttons |
| 91 | +rake db:migrate |
| 92 | +``` |
| 93 | + |
| 94 | +**Important Conventions**: |
| 95 | +- All models are typically scoped to Teams |
| 96 | +- Keep magic comments in generated files for future scaffolding |
| 97 | +- Use `valid_*` methods for defining select field options |
| 98 | +- Support for Action Models for complex business logic |
| 99 | +- Modular design allows overriding framework components |
| 100 | + |
| 101 | +### Key Components |
| 102 | + |
| 103 | +**ClickFunnels Integration** (app/lib/clickfunnels/): |
| 104 | +- Custom Faraday-based client for ClickFunnels API |
| 105 | +- Plans to migrate to official clickfunnels-ruby-sdk gem (see PLAN.md) |
| 106 | +- Webhook handling for ClickFunnels events |
| 107 | +- Background job for marking power users |
| 108 | + |
| 109 | +**API Structure** (app/controllers/api/v1/): |
| 110 | +- RESTful API with versioning |
| 111 | +- OAuth authentication via Doorkeeper |
| 112 | +- Standard JSON responses |
| 113 | + |
| 114 | +**Webhook System** (app/controllers/webhooks/): |
| 115 | +- Incoming webhooks from external services |
| 116 | +- Outgoing webhooks for event notifications |
| 117 | +- Signature verification for security |
| 118 | + |
| 119 | +**Background Processing**: |
| 120 | +- Sidekiq for async job processing |
| 121 | +- Redis for job queue storage |
| 122 | +- MarkPowerUserJob for ClickFunnels integration |
| 123 | + |
| 124 | +### Configuration |
| 125 | + |
| 126 | +**Environment Variables** (config/application.yml): |
| 127 | +- BASE_URL: Application base URL |
| 128 | +- MARKETING_SITE_URL: Marketing site URL |
| 129 | +- STRIPE_SECRET_KEY: Stripe API key |
| 130 | +- CLICK_FUNNELS_API_KEY: ClickFunnels API key |
| 131 | +- CLICK_FUNNELS_WORKSPACE_SUBDOMAIN: ClickFunnels subdomain (to be renamed) |
| 132 | +- CLICK_FUNNELS_WORKSPACE_ID: Workspace ID (to be moved to config) |
| 133 | + |
| 134 | +**Database**: PostgreSQL with ActiveRecord |
| 135 | + |
| 136 | +**Asset Pipeline**: |
| 137 | +- ESBuild for JavaScript bundling |
| 138 | +- Tailwind CSS with PostCSS |
| 139 | +- Stimulus for JavaScript framework |
| 140 | + |
| 141 | +### Testing Strategy |
| 142 | +- Minitest for unit and integration tests |
| 143 | +- Capybara for system tests |
| 144 | +- FactoryBot for test data |
| 145 | +- SimpleCov for coverage reporting |
| 146 | +- Fixtures for external API responses (test/fixtures/clickfunnels/) |
| 147 | + |
| 148 | +### Current Development Focus |
| 149 | +The `mark-as-power-user-in-clickfunnels` branch implements functionality to mark users as "power users" in ClickFunnels. There's an active migration plan (PLAN.md) to move from the custom implementation to the official ClickFunnels SDK. |
0 commit comments