Shopsys architecture

From shopsys/shopsys · View interactive version

Shopsys architecture is an AI agent skill from the GitHub repository shopsys/shopsys. How this Shopsys project is structured and the correct way to extend it — read it before implementing when you need to know WHERE code lives and HOW to extend functionality (model/entity, backend, Frontend API, administration, storefront) without editing the framework. Covers Entity Extension, servi

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.

Shopsys architecture — where to reach and how to extend

This skill orients you so you don't flounder while implementing. It doesn't implement for you and doesn't copy the documentation — it points you to the right place and the right mechanism.

The core model: you consume read-only packages

This repository is a project built on Shopsys Platform. The framework ships as Composer packages (shopsys/framework, shopsys/frontend-api, and others) installed under vendor/shopsys/ — treat that directory as read-only reference. You never edit it; you extend it from your own code in app/ and storefront/.

Two ways to change platform behavior:

1. Entity Extension (model layer)

An entity in the App\ namespace that extends a Shopsys\ base entity is wired up automatically. Add fields with Doctrine mapping/attributes, then generate a migration.

2. Service / class overrides (everything else)

Symfony autowiring resolves the vendor class by default. To make your subclass win, alias it in app/config/services.yaml:

# app/config/services.yaml
Shopsys\FrameworkBundle\Model\Product\ProductRepository:
    alias: App\Model\Product\ProductRepository

Without the alias, your custom class is never used. Forms follow the same idea via FormType extensions (*FormTypeExtension) placed alongside the form they extend — don't edit the vendor FormType.

Keep static analysis aware of your extensions

After extending an entity, factory, facade, or repository, run annotations-fix (bundled into standards-fix → .agents/skills/shopsys-commands/SKILL.md). It regenerates the @property and @method docblocks across the extension layer so PHPStan understands the extended types — e.g. that a factory now returns your App\ entity, not the Shopsys\ base. Skip it and static analysis reports false errors against the base types.

How to extend, by layer

Docs: Storefront, Frontend.

Docs: Model → Introduction to Model Architecture, Extensibility → Entity Extension, Cookbook → Adding New Attribute to an Entity.

Docs: Frontend API.

Docs: Administration, Extensibility → Extending Form.

Where things live

Backend (app/):

Storefront (storefront/): components/, pages/, graphql/, utils/, types/, styles/.

Framework reference (read-only): vendor/shopsys/*/src/.

Resources — in this order

  1. Local vendor/shopsys/ source = the most precise reference. Need a service signature, a method, or how something is built? Read the package source directly (Grep/Glob in vendor/shopsys/). It matches exactly the version running here. First stop.
  2. docs.shopsys.com — concepts and extension guides:

Mind the version in the URL (/en/latest/). If you know this project's major version, use it (e.g. /en/20.0/) so the guide matches.

Quick analysis before implementing

  1. Find the precedent — how is a similar thing already done in app/src/ and in vendor/shopsys/? Copy the established pattern (.agents/skills/codebase-pattern-finder/SKILL.md). For a new relation or stored structure, look for the same shape elsewhere in the model (e.g. OrderItem::$relatedItems) before adding a column or a JSON field — see Design conventions in .agents/skills/coding-conventions/SKILL.md.
  2. Standard extension? (new entity field, attribute, API field, admin grid) → check the Cookbook / Extensibility page for the concrete steps.
  3. Unknown package API? → read the source in vendor/shopsys/.
  4. Only then implement. Don't study ahead of need — pull only what the current change requires.
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.