How openclassrooms-student-center/p9-ameliorez-organisation-salesforce-pour-votre-entreprise works
Project type and purpose
• This is a Salesforce DX metadata-driven customization project.
• Purpose: extend a Salesforce org by adding custom objects (Order, Account fields), business logic (Apex classes and triggers) and a Lightning Web Component (LWC) to display or manipulate orders.
File structure
• Top-level:
• config/ – scratch org definition (project-scratch-def.json)
• force-app/main/default/ – all Salesforce metadata
• manifest/ – package.xml for deployments
• .github/workflows/ – CI/CD workflow (main_deploy)
• sfdx-project.json, package.json – Salesforce DX and npm config
• Within force-app/main/default:
• classes/ – Apex controllers and business logic
– MyTeamOrdersController.cls (Apex controller for LWC)
– UpdateAllAccounts.cls (batch or utility class) + test
• triggers/ – record-triggered automation
– CalculMontant.trigger (compute something on Order)
– UpdateAccountCA.trigger (update Account revenue)
• lwc/orders/ – Lightning Web Component
– orders.js/.html, metadata, tests
• objects/ – custom object definitions
– Account/fields/Chiffre_d_affaire__c
– Order/fields/{NetAmount__c, ShipmentCost__c}
README for additional insights
• Deployment workflow via Salesforce CLI (sf project deploy start)
• Target sandbox or scratch org
• Verification steps: ensure objects, fields, classes, triggers, and LWC are deployed
Main components
a. Salesforce Platform (deployed scratch or sandbox org)
b. Data Model
• Account (standard object + custom field Chiffre_d_affaire__c)
• Order (standard object + custom fields NetAmount__c, ShipmentCost__c)
• Underlying Salesforce relational database
c. Business Logic Layer (Apex)
• MyTeamOrdersController – exposes data/services to LWC via @AuraEnabled methods
• UpdateAllAccounts – batch or utility job to recalculate revenue for all accounts
• Triggers:
– CalculMontant.trigger – calculates order totals on insert/update
– UpdateAccountCA.trigger – rolls up Order revenue into Account.Chiffre_d_affaire__c
d. Presentation Layer (Lightning Web Component)
• orders LWC – UI that queries and displays orders, invokes Apex controller
e. Deployment Pipeline & Tooling
• GitHub Actions (main_deploy workflow)
• Salesforce CLI (sf org login, sf project deploy start)
• sfdx-project.json / manifest/package.xml – defines metadata to deploy
Relationships and interactions
• LWC (browser) → calls Apex controller (MyTeamOrdersController) → SOQL → Salesforce DB → returns JSON → LWC UI
• User creates or updates Order record → Salesforce triggers fire (CalculMontant, then UpdateAccountCA) → Apex trigger logic updates Order fields and Account revenue
• UpdateAllAccounts can be invoked (manually or scheduled) to recalculate all Account revenues in bulk
• Deployment: developer pushes changes to GitHub → CI/CD workflow runs → uses Salesforce CLI to push metadata into target org
Architectural patterns & design principles
• MVC within Salesforce:
• Model = sObjects (Order, Account)
• View = LWC component
• Controller = Apex classes (MyTeamOrdersController) and triggers
• Event-driven: record triggers react to data changes
• Metadata-as-code: all org configuration managed via source files and deployed via CLI/CI
• Separation of concerns: UI (LWC) vs business logic (Apex) vs data model
Elements
• “Browser / LWC orders”
• “Apex Controller (MyTeamOrdersController)”
• “Apex Triggers (CalculMontant, UpdateAccountCA)”
• “Batch Job / Utility (UpdateAllAccounts)”
• “Salesforce Data Model (Order, Account)”
• “GitHub Actions / CI-CD”
• “Salesforce CLI”
• LWC → Apex → DB → LWC
• Data change → triggers → DB updates
• GitHub → CI → Salesforce CLI → Org
• Blue for UI components
• Green for business logic (Apex)
• Orange for data model
• Grey for external tools/deployment