The Lucid Architecture for Building Scalable Applications at LaraconEU 2016
-
Upload
abed-halawi -
Category
Software
-
view
220 -
download
1
Transcript of The Lucid Architecture for Building Scalable Applications at LaraconEU 2016
The Lucid
Architecture Building Scalable Applications
Abed Halawi - Tech Lead at Vinelab @mulkave
What is an Architecture?
What is an Architecture?
Pattern of connected Structures
Structure & Architecture
Structure
Architecture
An expression of a
What is an architecture?
viewpoint
Why Do We Have Them?
Why Do We Have Them?
Communicate Structures
Controller ✅
Model ✅
View ✅
Service ⁉
Domain ⁉
Why Do We Have Them?
Eradecate Homelessness of Code
0
25
50
75
100
0
25
50
75
100
v1.0 v1.2
😈👺
Why Do We Have Them?
Eradecate Homelessness of Code
Why Do We Have Them?
Illustrate Structures
Request Http Kernel
Closure
Controller
Route Process &
Respond
DDD?Technical Debt 🤑
SOA?
Legacy Code
• No More Legacy Code
• Defines Terminology
• Comprehensive, No Limitations
• Complements Laravel’s Design
• Simple, Yet Sophisticated
• Performs at Scale
What?
How? 🤔
Lucid
Lucid
Lucid • Components
Feature
Job
Service
Lucid • Feature• As described in business, as a class name • Runs Jobs - Steps in the process of accomplishment
CreateArticleFeature
LoginUserFeature
ControllerProcess
& RespondFeature
serve
Lucid • Feature• Controllers serve Features
Lucid • JobA class that does one thing; responsible for the
business logic
• CreateArticleFeature
• Validate Article Input
• Generate Slug
• Upload Files To Cdn
• Save Article
• Respond With Json
Lucid • JobA class that does one thing; responsible for the
business logic
• CreateArticleFeature
• ValidateArticleInputJob
• GenerateSlugJob
• UploadFilesToCdnJob
• SaveArticleJob
• RespondWithJsonJob
Lucid • JobA class that does one thing; responsible for the
business logic
Controller Featureserve
Validate Input
Generate Slug
Upload Files To CDN
Save Article
Respond With JSON
] Process&
] Respond
132
1 2 3
Lucid • Service
Implements Features and serves them through controllers
Website
Api
Backend
Lucid • Service• Website • ListArticlesFeature • GetPublishedArticlesJob • RespondWithViewJob
• Api • ListArticlesFeature • GetPublishedArticlesJob • RespondWithJsonJob
• Backend • CreateArticleFeature • ValidateArticleInputJob • SaveArticleJob • RespondWithViewJob
Lucid • Service• Website • ListArticlesFeature • GetPublishedArticlesJob • RespondWithViewJob
• Api • ListArticlesFeature • GetPublishedArticlesJob • RespondWithJsonJob
• Backend • CreateArticleFeature • ValidateArticleInputJob • SaveArticleJob • RespondWithViewJob
Lucid • Service• Website • ListArticlesFeature • GetPublishedArticlesJob • RespondWithViewJob
• Api • ListArticlesFeature • GetPublishedArticlesJob • RespondWithJsonJob
• Backend • CreateArticleFeature • ValidateArticleInputJob • SaveArticleJob • RespondWithViewJob
Lucid • Service
Http Kernel
WhichService?
Controller Feature
Website
Route
Controller Feature
Api
Route
Controller Feature
Backend
Route
example.com
api.example.com OR example.com/api
admin…com OR example.com/api
Domains
Lucid • Domains
Responsible for the entities; exposing their functionalities through Jobs
Lucid • Domains• Article
• GetPublishedArticlesJob
• SaveArticleJob
• ValidateArticleInputJob
• Cdn
• UploadFilesToCdnJob
• Http
• RespondWithJsonJob
Lucid • Layers
Service Domain Data
F
A
T
U
R
E
E
J
O
B
M
D
E
L
O
Lucid • Principles ✍1. Controllers serve Features
2. Avoid Cross-Domain Communication
3. Avoid Cross-Job Communication
Getting Started> composer create-project lucid-arch/laravel my-project
1. Init a project
> lucid make:service Api
2. Scaffold a Service
> lucid make:feature Api LoginUser
3. Generate a Feature
> lucid make:job User CheckCredentials
4. Generate a Job
Lucid • Console