Skip to content

Commit b1f835b

Browse files
authored
Merge pull request #150 from dotkernel/v7-overhaul
V7 overhaul
2 parents ef3c8cb + d06b0a0 commit b1f835b

7 files changed

Lines changed: 54 additions & 123 deletions

File tree

docs/book/v7/introduction/architecture-at-a-glance.md renamed to docs/book/v7/architecture-at-a-glance.md

Lines changed: 38 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,16 @@ Understanding the core structure is essential before diving into development.
55

66
## The Core vs App Split (Since v6.0)
77

8-
Since version 6.0, Dotkernel API is organized into two distinct layers:
8+
Since version 6.0, Dotkernel API is organized into two distinct layers: Core and App.
99

10-
### Core Layer
10+
| Layer | Purpose | Items | Location |
11+
|-------|-----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|---------------|
12+
| Core | The backbone of your application, the system-level infrastructure that handles fundamental concerns | Authentication & Authorization, Database, Common Services, Shared Entities | src/Core/src/ |
13+
| App | The project-specific features, "business logic" of your application | Routes, Handlers, Custom Services, Input Filters, Custom Middleware, Error Reporting | src/App/src/ |
1114

12-
The **Core** is the backbone of your application—system-level infrastructure that handles fundamental concerns:
15+
## Architecture
1316

14-
- Authentication & Authorization: OAuth2-based authentication with RBAC (Role-Based Access Control)
15-
- Database Setup: Doctrine ORM configuration, entity definitions, and repositories
16-
- Common Services: Mail service, error reporting, caching
17-
- Shared Entities: Admin/User entities, roles, permissions
18-
19-
Location: `src/Core/src/`
20-
21-
You typically don't modify Core unless you're updating system behavior or adding shared infrastructure features.
22-
23-
### App Layer
24-
25-
The **App** is where you build your project-specific features—the "business logic" of your application:
26-
27-
- Routes: Endpoint definitions specific to your use case
28-
- Handlers: PSR-15 request handlers (like controllers, but single-action focused)
29-
- Custom Services: Business logic and data processing
30-
- Input Filters: Request validation rules
31-
- Custom Middleware: Application-specific middleware
32-
- Error Reporting: Frontend error collection endpoints
33-
34-
Location: `src/App/src/`
35-
36-
You spend most development time here, implementing your API's features and business logic.
37-
38-
## Headless CMS Architecture
39-
40-
Dotkernel API is built toward a Headless Platform architecture.
17+
Dotkernel API is built toward a **Headless Platform** architecture.
4118
Out of the box, it is a modular monolith that can be split into modules and microservices.
4219

4320
```quote
@@ -71,7 +48,7 @@ Out of the box, it is a modular monolith that can be split into modules and micr
7148
└───────────────────────────────────┘
7249
```
7350

74-
## Modular Design
51+
## Modular Monolith Architecture
7552

7653
Applications are organized into modules, each handling a specific domain.
7754

@@ -114,60 +91,13 @@ Here's how a typical request flows through Dotkernel API:
11491

11592
## Key Components
11693

117-
### Handlers (PSR-15)
118-
119-
Single-action request handlers instead of multi-action controllers:
120-
121-
```quote
122-
src/User/src/Handler/
123-
├─ GetUserCollectionHandler.php (GET /user)
124-
├─ GetUserResourceHandler.php (GET /user/{id})
125-
├─ PostUserResourceHandler.php (POST /user)
126-
├─ PatchUserResourceHandler.php (PATCH /user/{id})
127-
└─ DeleteUserResourceHandler.php (DELETE /user/{id})
128-
```
129-
130-
Benefits: Separation of concerns, easier testing, clearer intent.
131-
132-
### Services
133-
134-
The Business logic layer sits between the handlers and repositories:
135-
136-
```quote
137-
Handler → Service → Repository → Database
138-
```
139-
140-
Services handle:
141-
142-
- Business rules validation
143-
- Data transformation
144-
- Cross-cutting concerns (caching, logging)
145-
146-
### Repositories
147-
148-
Data access layer using Doctrine ORM:
149-
150-
- Query building
151-
- Entity persistence
152-
- Database abstraction
153-
154-
### Input Filters
155-
156-
Request validation using Laminas InputFilter:
157-
158-
```quote
159-
Request → InputFilter → Validation → Handler
160-
```
161-
162-
### Entities
163-
164-
Doctrine ORM entities representing database tables:
165-
166-
```php
167-
#[ORM\Entity]
168-
#[ORM\Table(name: 'user')]
169-
class User { ... }
170-
```
94+
| Component | Purpose | Example | Notes |
95+
|-------------------|-----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------|----------------------------------------------------------------------------------|
96+
| Handlers (PSR-15) | Process incoming HTTP requests, coordinate application logic/services, and return the HTTP response | `GetUserResourceHandler.php`, `PostUserResourceHandler.php` | Some of the benefits are: separation of concerns, easier testing, clearer intent |
97+
| Services | Contains the business logic layer that sits between the handlers and repositories | Business rules validation, Data transformation, Cross-cutting concerns | Execution flow: `Handler → Service → Repository → Database` |
98+
| Repositories | Data access layer using Doctrine ORM | Query building, Entity persistence, Database abstraction | The only component that interacts with the database |
99+
| Input Filters | Filter and validate requests using Laminas InputFilter | Login form, contact us form, `$_GET` and `$_POST` values, CLI arguments | Execution flow: `Request → InputFilter → Validation → Handler` |
100+
| Entities | Represent database tables using Doctrine ORM | `class User { ... }` | Ensure consistency between database and application data |
171101

172102
## Configuration Organization
173103

@@ -177,11 +107,11 @@ config/
177107
├─ pipeline.php (Middleware stack)
178108
├─ container.php (Dependency injection)
179109
└─ autoload/
180-
├─ dependencies.global.php (Service definitions)
181-
├─ authorization.global.php (RBAC rules)
182-
├─ content-negotiation.global.php (Accept/Content-Type)
183-
├─ doctrine.global.php (ORM configuration)
184-
└─ local.php (Environment-specific, ignored by VCS, private config)
110+
├─ dependencies.global.php (Service definitions)
111+
├─ authorization.global.php (RBAC rules)
112+
├─ content-negotiation.global.php (Accept/Content-Type)
113+
├─ doctrine.global.php (ORM configuration)
114+
└─ local.php (Environment-specific, ignored by VCS, private config)
185115
```
186116

187117
## Dependency Injection
@@ -250,25 +180,24 @@ Services are automatically resolved and injected by AttributedServiceFactory.
250180

251181
## Standards & PSRs
252182

253-
Dotkernel API adheres to PHP standards for interoperability:
254-
Core PSRs
255-
256-
- **PSR-7**: HTTP Message Interfaces (Requests/Responses)
257-
- **PSR-11**: Container Interface (Dependency Injection)
258-
- **PSR-15**: HTTP Handlers and Middleware (Request processing)
259-
260-
Supporting PSRs, installed by dependencies:
261-
262-
- **PSR-3**: Logger Interface (Requests/Responses)
263-
- **PSR-4**: Autoloading (File organization)
264-
- **PSR-6**: Caching Interface
265-
- **PSR-13**: Link Definition Interfaces
266-
- **PSR-14**: Event Dispatcher
267-
- **PSR-17**: HTTP Factories
268-
- **PSR-18**: HTTP Client
269-
- **PSR-20**: Clock
270-
271-
This ensures your code can integrate with other PSR-compliant libraries.
183+
Dotkernel API adheres to PHP standards for interoperability.
184+
They ensure that your code can integrate with other PSR-compliant libraries.
185+
186+
| PSR and Specifications | Git Implementation | Level | Description |
187+
|----------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|---------------------------------------------------|
188+
| [PSR-7](https://www.php-fig.org/psr/psr-7) | [php-fig/http-message](https://github.com/php-fig/http-message) | Core | HTTP Message Interfaces (Requests/Responses) |
189+
| [PSR-11](https://www.php-fig.org/psr/psr-11) | [php-fig/container](https://github.com/php-fig/container) | Core | Container Interface (Dependency Injection) |
190+
| [PSR-15](https://www.php-fig.org/psr/psr-15) | [php-fig/http-server-handler](https://github.com/php-fig/http-server-handler), [php-fig/http-server-middleware](https://github.com/php-fig/http-server-middleware) | Core | HTTP Handlers and Middleware (Request processing) |
191+
| [PSR-3](https://www.php-fig.org/psr/psr-3) | [php-fig/log](https://github.com/php-fig/log) | Supporting | Logger Interface (Requests/Responses) |
192+
| [PSR-4](https://www.php-fig.org/psr/psr-4) | [php-fig/log](https://github.com/php-fig/log) | Supporting | Autoloading (File organization) |
193+
| [PSR-6](https://www.php-fig.org/psr/psr-6) | [php-fig/cache](https://github.com/php-fig/cache) | Supporting | Caching Interface |
194+
| [PSR-13](https://www.php-fig.org/psr/psr-13) | [php-fig/link](https://github.com/php-fig/link) | Supporting | Link Definition Interfaces |
195+
| [PSR-14](https://www.php-fig.org/psr/psr-14) | [php-fig/event-dispatcher](https://github.com/php-fig/event-dispatcher) | Supporting | Event Dispatcher |
196+
| [PSR-17](https://www.php-fig.org/psr/psr-17) | [php-fig/http-factory](https://github.com/php-fig/http-factory) | Supporting | HTTP Factories |
197+
| [PSR-18](https://www.php-fig.org/psr/psr-18) | [php-fig/http-client](https://github.com/php-fig/http-client) | Supporting | HTTP Client |
198+
| [PSR-20](https://www.php-fig.org/psr/psr-20) | [php-fig/clock](https://github.com/php-fig/clock) | Supporting | Clock |
199+
200+
> Supporting PSRs are installed by dependencies.
272201
273202
## Security Layers
274203

docs/book/v7/extended-features/core-and-app.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Since version 6.0, the project is split into two main parts: **App** and **Core*
55
When you start a new project, there are chances that the requirements are not defined well.
66
Because of that, your platform needs to be flexible and allow growth in the long term.
77

8-
Our purpose is to reach a **Headless CMS** architecture for easier scalability.
8+
Our purpose is to reach a **Headless Platform** architecture for easier scalability.
99

10-
> Headless CMS is a backend-only content management system that acts primarily as a content repository.
11-
> Compared to traditional CMS platforms (e.g., WordPress) that tightly couple the front end and back end, a headless CMS decouples the content management from the presentation layer.
10+
> The Headless Platform is a backend system that provides data and functionality via an API, completely decoupled from any frontend presentation layer.
11+
> Unlike monolithic platforms like WordPress that bundle the backend and frontend together, a Headless Platform separates content delivery from the presentation layer.
1212
> The content is delivered through APIs allowing any frontend to fetch and display it, which also enables working in parallel on the backend and potentially multiple frontends.
1313
1414
## What is "App" and what is "Core"?

docs/book/v7/introduction/file-structure.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# File structure
22

3-
Dotkernel API follows the [PSR-4](https://www.php-fig.org/psr/psr-4/) standards.
4-
5-
It is a good practice to standardize the file structure of projects.
3+
The Dotkernel API file structure follows the [PSR-4](https://www.php-fig.org/psr/psr-4/) standards.
4+
Standardizing the file structure of your project is considered good practice because it makes it easier to find and navigate the code.
65

76
When using Dotkernel API, the following structure is installed by default:
87

docs/book/v7/introduction/introduction.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ For our API payloads (a value object for describing the API resource, its relati
5454

5555
## CORS
5656

57-
By using `MezzioCorsMiddlewareCorsMiddleware`, the CORS preflight will be recognized and the middleware will start to detect the proper CORS configuration.
57+
By using `Mezzio\Cors\Middleware\CorsMiddleware`, the CORS preflight will be recognized and the middleware will start to detect the proper CORS configuration.
5858
The Router is used to detect every allowed request method by executing a route match with all possible request methods.
5959
Therefore, for every preflight request, there is at least one Router request.
6060

@@ -67,7 +67,7 @@ We use [mezzio/mezzio-authentication-oauth2](https://github.com/mezzio/mezzio-au
6767

6868
It is not unlikely for an API to send emails depending on the use case.
6969
Here is another area where Dotkernel API shines.
70-
Using `DotMailServiceMailService` provided by [dotkernel/dot-mail](https://github.com/dotkernel/dot-mail) you can send custom email templates.
70+
Using `Dot\Mail\Service\MailService` provided by [dotkernel/dot-mail](https://github.com/dotkernel/dot-mail) you can send custom email templates.
7171

7272
## Configuration
7373

@@ -119,7 +119,7 @@ vendor/bin/phpunit --testsuite=FunctionalTests --testdox --colors=always
119119

120120
## Common Pitfalls
121121

122-
> [!IMPORTANT]
122+
> !IMPORTANT
123123
> Remember:
124124
125125
- Change default OAuth2 client credentials in production.
@@ -130,4 +130,9 @@ vendor/bin/phpunit --testsuite=FunctionalTests --testdox --colors=always
130130
## Next Steps
131131

132132
Ready to get started?
133-
Jump to the [Installation Guide](https://docs.dotkernel.org/api-documentation/v7/installation/getting-started/) to set up your first Dotkernel API application.
133+
134+
- Jump to the [Installation Guide](https://docs.dotkernel.org/api-documentation/v7/installation/getting-started/) to set up your first Dotkernel API application.
135+
- Learn the [Upgrade Procedure](https://docs.dotkernel.org/api-documentation/v7/upgrading/upgrading/) between different versions of Dotkernel API.
136+
- Check out the [Architecture at a Glance](https://docs.dotkernel.org/api-documentation/v7/architecture-at-a-glance/).
137+
- Review the [Core Features](https://docs.dotkernel.org/api-documentation/v7/core-features/authentication/).
138+
- Run through the [Tutorials](https://docs.dotkernel.org/api-documentation/v7/tutorials/cors/) for step-by-step instructions on how to use Dotkernel API.

docs/book/v7/introduction/server-requirements.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ Windows is supported for development via WSL2.
88
### Production
99

1010
- Linux (AlmaLinux, Debian)
11-
- BSD (FreeBSD)
12-
- macOS (Intel or Apple Silicon)
1311

1412
### Development
1513

docs/book/v7/transition-from-api-tools/api-tools-vs-dotkernel-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| OSS Lifecycle | Archived | ![OSS Lifecycle](https://img.shields.io/osslifecycle?style=flat&label=&file_url=https%3A%2F%2Fgithub.com%2Fdotkernel%2Fapi%2Fblob%2F7.0%2FOSSMETADATA) |
1010
| Style | REST, RPC | REST |
1111
| Versioning | Yes | [Deprecations](https://docs.dotkernel.org/api-documentation/v7/tutorials/api-evolution/) |
12-
| Documentation | Swagger (Automated) | OpenAPI (Swagger) / Postman (Manual) |
12+
| Documentation | Swagger (Automated) | OpenAPI (Swagger) / Bruno (Manual) |
1313
| Content-Negotiation | Custom | Custom |
1414
| License | BSD-3 | MIT |
1515
| Default DB Layer | laminas-db | doctrine-orm |

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ nav:
1212
- Home: index.md
1313
- v7:
1414
- Introduction: v7/introduction/introduction.md
15+
- "Architecture at a Glance": v7/architecture-at-a-glance.md
1516
- Overview:
1617
- "Server Requirements": v7/introduction/server-requirements.md
1718
- "File Structure": v7/introduction/file-structure.md
18-
- "Architecture at a Glance": v7/introduction/architecture-at-a-glance.md
1919
- "Packages": v7/introduction/packages.md
2020
- "PSRs": v7/introduction/psr.md
2121
- Installation:

0 commit comments

Comments
 (0)