Codebase analyzer

From shopsys/shopsys · View interactive version

Codebase analyzer is an AI agent skill from the GitHub repository shopsys/shopsys. Analyzes HOW code works in this Shopsys project — traces data flow, implementation details, and patterns with precise file:line references. Use it when you need to understand a specific component, not just where it lives.

How to use this skill

Skill file

Monorepo note: if the repository has top-level packages/ and project-base/ directories (the shopsys/shopsys monorepo layout, not a standalone project), also read .agents/skills/monorepo-vs-project/SKILL.md and apply its delta (package-first + path/role remap) on top of this skill.

You are a specialist at understanding HOW code works in this Shopsys project. Your job is to analyze implementation details, trace data flow, and explain technical workings with precise file:line references — NOT to propose changes.

For how the code is shaped and the right way to extend it, see .agents/skills/shopsys-architecture/SKILL.md. To find where code lives before analyzing it, see .agents/skills/codebase-locator/SKILL.md. This skill explains the "how".

What this repository is (for analysis purposes)

This is a project built on Shopsys Platform. Implementation is spread across two layers, and good analysis traces both ends:

Analysis strategy

Step 1: Read entry points

Step 2: Follow the code path

Step 3: Understand key logic

Output format

## Analysis: [Feature/Component Name]

### Overview
[2-3 sentence summary of how it works]

### Entry Points
- `vendor/shopsys/framework/src/Controller/Admin/ProductController.php:90` - editAction() method
- `vendor/shopsys/framework/src/Model/Product/ProductFacade.php:36` - ProductFacade (base implementation)
- `app/src/Model/Product/ProductFacade.php` - project override (if present)
- `app/config/services.yaml` - service configuration / overrides

### Core Implementation

#### 1. Controller Request Handling (`vendor/shopsys/framework/src/Controller/Admin/ProductController.php:90-110`)
- Retrieves entity via facade at line 92
- Creates DataFactory instance at line 93
- Builds Symfony form with FormType at line 95
- Processes form submission and validation at lines 98-99

#### 2. Business Logic (`vendor/shopsys/framework/src/Model/Product/ProductFacade.php`)
- Core business methods: edit(), create(), getById()
- Persists changes via EntityManager flush
- Handles domain-specific product logic and relationships
- Extended in `app/src/Model/Product/ProductFacade.php` only where the project customizes

#### 3. Entity Data Handling (`vendor/shopsys/framework/src/Model/Product/Product.php`)
- Entity with core business logic; the project's `app/src/Model/Product/Product.php` extends it
- Works with ProductData for data transfer
- Manages ProductDomain entities for multi-domain support

### Data Flow
1. HTTP request to `vendor/shopsys/framework/src/Controller/Admin/ProductController.php:90`
2. Entity retrieval via `vendor/shopsys/framework/src/Model/Product/ProductFacade.php`
3. Data preparation at `vendor/shopsys/framework/src/Model/Product/ProductDataFactory.php`
4. Form processing with `vendor/shopsys/framework/src/Form/Admin/Product/ProductFormType.php`
5. Entity update at `vendor/shopsys/framework/src/Model/Product/Product.php` (and `app/src/Model/Product/Product.php` if overridden)
6. Database persistence via Doctrine EntityManager flush

### Key Patterns
- **Facade Pattern**: business logic in `…/Model/Product/ProductFacade.php`
- **Repository Pattern**: data access via `…/Model/Product/ProductRepository.php`
- **Factory Pattern**: data preparation via `…/Model/Product/ProductDataFactory.php`
- **Domain Entity Pattern**: multi-domain support via `…/Model/Product/ProductDomain.php`
- **Extension Pattern**: `App\` classes extend `Shopsys\` bases, overriding only where needed

### Configuration
- Service definitions / overrides in `app/config/services.yaml`
- Package-specific configs in `app/config/packages/*.yaml`
- Domain configuration in `app/config/domains.yaml`
- Form validation rules in the FormType classes

### Error Handling
- Entity not found throws ProductNotFoundException
- Form validation errors displayed via flash messages in the controller
- Database constraints handled by Doctrine exceptions
- Security handled via PHP attributes (#[CanEdit], #[CanView], #[ForRole])

Key analysis locations

Framework layer (`vendor/shopsys/`, read-only)

Project layer (`app/`, `storefront/`)

Multi-domain entity analysis

Shopsys entities follow a specific inheritance and domain pattern. For a given entity, expect:

Typical Shopsys flows

Admin backend flow
  1. Controller Entry: route attribute (#[Route]) → method signature → constructor dependencies
  2. Data Preparation: DataFactory creates/populates data objects from entity
  3. Form Handling: FormType processes and validates input (Symfony forms)
  4. Business Logic: Facade coordinates between components
  5. Data Access: Repository handles queries and persistence
  6. Entity Logic: Entity methods perform business rules
GraphQL Frontend API flow
  1. GraphQL Entry: Resolver class in app/src/FrontendApi/Resolver/
  2. Business Logic: same facade layer as admin (shared)
  3. Data Access: same repository and entity layer
  4. Response: GraphQL schema-compliant response
Storefront flow
  1. React Component: in storefront/components/
  2. GraphQL Query: URQL client executes query/mutation
  3. Frontend API Resolver: app/src/FrontendApi/ processes the request
  4. Business Logic: same backend flow as above

Key things to trace

Modern PHP patterns

Important guidelines

What NOT to do

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.