Insight into the Shopware 6 core architecture

Insight into the Shopware 6 core architecture

With Shopware 6, the architecture was rethought from scratch and adapted to today's eCommerce.

In this session, Jan Bücker and Jonas Elfering will give you a deeper insight into the PHP-side architecture and functionality. All important and interesting sections from Context to the Data Abstraction Layer are introduced to you step by step, so that you are prepared to get started with Shopware 6.

0fcc31283750e5abb9e34399afc55191?s=128

Jan Bücker

May 23, 2019
Tweet

Transcript

  1. 56 Developers have contributed to the platform

  2. 7500+ commits were made to build v6.0.0+dp1

  3. 31bfd704 First commit on Shopware 6

  4. Insight into the core architecture Jan Bücker, Jonas Elfering

  5. Jan Bücker Developer Core ➜ 4 years at shopware AG

    ➜ Born ‘89 ➜ Say hi on twitter @janbuecker ➜ I music! ❤
  6. ➜ @shopware since 2017 ➜ @keulinho ➜ @j_elfering Jonas Elfering

    Developer Enterprise
  7. Attention! This talk is based on v6.0.0+dp1 and implementations may

    change with upcoming releases.
  8. Attention! This talk is based on v6.0.0+dp1 and implementations may

    change with upcoming releases. already changed
  9. Agenda • Project structure • API • Context • Translations

    • Data Abstraction Layer • Cart • Business Events
  10. Getting the names right • Project template ? • Platform

    ? • Shopware 6 ?
  11. Project template Blueprint for projects Tailored for specific needs e.g.

    • Production (high performance) • Development (debugging) • Cloud hosting specific customization (AWS, GCP, Azure) • Overwrite default config values Project template • Platform • Shopware 6
  12. Platform Mono repository for Shopware 6 modules • One repository

    containing all modules • Easy to make changes across all modules to maintain stability • Split into Many-Repositories • Contributions go here Project template • Platform • Shopware 6 https://github.com/shopware/platform
  13. Many Repositories Composable bundles, that are structured by domain •

    Core • Administration • Storefront • Docs These are read-only. Do not contribute to them. Project template • Platform • Shopware 6
  14. Shopware 6 The Product Project template + • Core •

    Administration • Storefront • Plugins Project template • Platform • Shopware 6
  15. Technical requirements

  16. Technical requirements • Web server running php • PHP >=

    7.2 • MySQL >= 5.7 (MariaDB >= 10.3) ◦ High group_concat_max_len Optional • Node.js >= 8.10 • NPM >= 6.5
  17. API Build headless eCommerce

  18. API != API Building headless eCommerce

  19. API • Admin API • Sync API • Sales Channel

    API
  20. Admin API • Manage your Shop • Used by the

    Administration • CRUD operations for every entity • Action routes for everything else
  21. Admin API • Stateless • Auth via OAuth (JWT) •

    Dynamic OpenAPI 3 schema including all entities • Supports JSON:API ◦ Deduplication built-in ◦ Self-discovery ◦ Implementations for various languages
  22. Sync API or Admin Batch API • Single endpoint in

    Admin API • Multiple actions in one request ◦ upsert ◦ delete • Probably faster with large data sets (in the future)
  23. Sync API or Admin Batch API

  24. Sales Channel API • Storefront functionality ◦ Sell products via

    API ◦ Perform checkout ◦ Manage your account • Authentication with pre-shared key • Dynamic OpenAPI 3 schema for all available routes
  25. Context

  26. Context Crucial information of a request • Immutable object •

    Built from the request • Runtime information
  27. Contexts Context

  28. Sales Channel Context

  29. • 3 levels of inheritance priority ◦ current language ◦

    root language ◦ system language Context Language chain for partial translations
  30. • 3 levels of inheritance priority ◦ current language ◦

    root language ◦ de-DE Context Language chain for partial translations
  31. • 3 levels of inheritance priority ◦ current language ◦

    en-GB ◦ de-DE Context Language chain for partial translations
  32. • 3 levels of inheritance priority ◦ en-US ◦ en-GB

    ◦ de-DE Context Language chain for partial translations
  33. Translations

  34. None
  35. None
  36. Translations Translate all the things • Content • Administration UI

    • Storefront UI
  37. Translations Translate all the things • Content • Administration UI

    • Storefront UI
  38. Content Translations • Built into the Data Abstraction Layer •

    Translated fields can be managed in all languages • Inheritance with partial translations
  39. Data Abstraction Layer

  40. Why? Reasons not to use Doctrine ORM • Difficult to

    optimize • Not suitable for core concepts • Entities not extendable for plugins • Not possible to enforce patterns
  41. Reading data

  42. Adding Criteria

  43. Loading Associations

  44. Aggregating Data

  45. Aggregating Data

  46. Writing data

  47. Writing data

  48. Define your own Entities

  49. Data Abstraction Layer • tag your entity with shopware.entity.definition •

    add a DB migration optional • add a EntityClass • add a CollectionClass if necessary • add a translation definition Define your own Entities
  50. TranslationDefinition

  51. Content Translation - Example

  52. Content Translation - Example

  53. Content Translation - Example

  54. Content Translation - Example

  55. Sales Channel API Entities • SalesChannelDefinitions extend EntityDefinitions • Add

    custom criteria • Add fields
  56. Sales Channel API Entities

  57. Indexer • Denormalization for improved read performance • Denormalized data

    needs synchronisation ◦ Build the whole index ◦ Update the index for updated entities only Synchronizing denormalized data
  58. Indexer

  59. Migrations

  60. Migrations • Blue/Green compatible • 2-Phase Migrations ◦ update ◦

    updateDestructive • usable for Plugins as well Updating the DB schema
  61. Migrations • Must be compatible with old and new application

    ◦ No breaking changes • Application rollback without another DB schema migration 1. Phase: update
  62. Migrations • Contains the breaking changes • Application rollback not

    possible • Last possible rollback point -> last destructive Migration 2. Phase: updateDestructive
  63. Data Abstraction Layer Common obstacles • IDs are binary UUIDs

    • Objects for reading • Arrays for writing • Translated properties must be nullable
  64. Data Abstraction Layer Tools • Debug View Generator • Schema

    Generator • Validation command
  65. Cart

  66. Cart • First component in Shopware 6 • State machine

    • High Performance
  67. Cart Calculation process

  68. Cart Enrichment process

  69. Payment

  70. Payment • Executed after order placed • Synchronous • Asynchronous

  71. Payment asynchronous

  72. Business Events

  73. Business Event • Important business cases • Describes itself •

    Same event dispatcher
  74. Business Event Example: order placed

  75. Actions for Business Events Add actions for events: • Send

    an email • Call an API • Send a Slack message
  76. Business Event Tag for mailing

  77. Actions for Business Events order.placed event dispatcher Plugin X

  78. Actions for Business Events order.placed action event dispatcher send mail

    call API Slack msg event dispatcher Plugin X
  79. Further topics • Filesystem • Custom Fields • Tooling •

    Versioning • Message Queue • Custom Rule Builder rules
  80. None
  81. Questions THANK YOU!