Atomic Framework Overview
When to Use
- Starting work in any part of the framework for the first time.
- Tracing the bootstrap chain before editing engine code.
- Choosing which module owns a behavior.
- Understanding how Atomic wraps Fat-Free Framework (F3).
Foundation
Atomic is a modular PHP 8.1+ framework built on top of Fat-Free Framework (bcosca/fatfree-core ^3.9.1).
- F3 owns: router, hive (global key-value store
$f3->get/set), template engine, Cortex ORM.
- Atomic adds: config loading, middleware, plugin management, auth, queue, scheduler, telemetry, theme, and DX tooling on top of F3.
- Runtime state (config, session, DB connections, locale) lives in the F3 hive. Modules communicate through hive keys, not direct coupling.
Bootstrap Chain
engine/index.php
└─ bootstrap/app.php
1. bootstrap/const.php ← ATOMIC_LOADER, ATOMIC_DIR, ATOMIC_ENV, etc.
2. ConfigLoader::init($f3, .env) OR (new PhpConfigLoader($f3))->load()
3. App::instance($f3)
├─ prefly() ← PHP/extension checks, storage writability
├─ register_logger()
├─ register_exception_handler()
├─ register_locales()
├─ register_middleware()
├─ register_routes()
├─ register_core_plugins()
├─ register_plugins()
├─ init_session()
├─ open_connections()
└─ register_user_provider()
4. App\Event\Application::instance()->init()
5. App\Hook\Application::instance()->init()
6. $f3->run()
For CLI:
php atomic <command> # e.g. php atomic schedule/run
# internally: App::instance()->handle_command($argv)
# normalizes "schedule:run" → "/schedule/run" then calls run()
Module Map
engine/Atomic/
├── Core/ ← bootstrap, config, request/response, routing, middleware, crypto, log, guard
├── App/ ← Controller, Model, Page, Storage, PluginManager
├── Auth/ ← login flows, Google/Telegram OAuth, adapters, services
├── Session/ ← SessionManager, SQL + Redis session drivers
├── Queue/ ← job queue, workers, DB/Redis drivers, monitor, applications
├── Scheduler/ ← cron-style task scheduler + Mutex overlap protection
├── Telemetry/ ← diagnostics panel served at /telemetry
├── Theme/ ← Theme boot, Head, Assets, OpenGraph, Schema
├── Hook/ ← WordPress-style add_action/add_filter/do_action/apply_filters
├── Event/ ← dot-notation typed event bus (Event::instance()->on/emit)
├── Lang/ ← i18n, locale files, lang_url(), get_locale()
├── Mail/ ← SMTP wrapper: mail_to()->set_html()->send()
├── Mutex/ ← distributed locking: Mutex::acquire/release/synchronized
├── Plugins/ ← built-in integrations: Monopay, WordPress, WooCommerce, RSS...
├── Files/ ← PDF, XLS, CSV export
├── Cache/ ← DB and Memcached cache drivers
├── Tools/ ← Nonce, Transient, Telegram, AIConnector
├── Validator/ ← model-level validation via Validator + ValidatorModelTrait
├── WebSockets/ ← Workerman-based WebSocket server base class
├── Exceptions/ ← typed exception hierarchy (AtomicException, ...)
├── Enums/ ← PHP 8.1 backed enums: Role, Rule, Currency, Language, LogLevel
├── CLI/ ← console command layer: php atomic <cmd>
├── API/ ← API entrypoint wrapper
├── Codes/ ← Code constants
└── Support/ ← global helper functions (helpers.php)
Routing Quick Reference
// Basic
$app->route('GET /users', 'App\\Http\\Controllers\\Users->index');
// With middleware (array = MiddlewareStack; disables F3 route caching)
$app->route('GET /dashboard', 'App\\Http\\Controllers\\Dashboard->index', ['auth']);
// With TTL cache (seconds; no middleware)
$app->route('GET /posts/@id', 'App\\Http\\Controllers\\Posts->show', 60);
// Parameterized middleware
$app->route('GET /admin', 'App\\Http\\Controllers\\Admin->index', ['auth', 'role:admin']);
Route dispatch by request type:
| Path prefix |
Route file loaded |
CLI (php atomic) |
routes/cli.php |
/api/* |
routes/api.php |
/telemetry/* |
engine/.../Routes/telemetry.php |
| everything else |
routes/web.php |
Route files: routes/web.php, routes/api.php, routes/cli.php, routes/schedule.php.
Key Skills to Load Next
| Task |
Load skill |
| Config, request, middleware, logging |
atomic-framework-core |
| Controllers, models, storage |
atomic-framework-app-auth |
| Auth, session, OAuth |
atomic-framework-app-auth |
| Queue, scheduler, telemetry |
atomic-framework-queue-scheduler-telemetry |
| Theme, head, assets, OpenGraph |
atomic-framework-theme |
| Hooks, events, mail, i18n |
atomic-framework-event-hook-lang-mail |
| Mutex, session state, nonce, transient |
atomic-framework-mutex-session |
| Plugins, integrations |
atomic-framework-plugins |
| CLI commands, API |
atomic-framework-cli-api |
| PDF/XLS, validation, cache, exceptions |
atomic-framework-data |
| AI connector, WebSockets, tools |
atomic-framework-tools-websockets |
Guardrails
- Modules communicate through the F3 hive, not direct cross-module coupling.
- Always identify the owning module first. Never add a feature to the wrong module.
- Do not bypass
App::register_*() lifecycle methods - they exist to wire the correct dependencies in order.
- Load the matching subsystem skill before making non-trivial changes.
1---2name: atomic-framework-overview3description: Use when you need a high-level map of Atomic Framework, its Fat-Free Framework foundation, startup flow, module boundaries, boot sequence, routing conventions, and correct entry points before editing any engine or app code.4---5
6# Atomic Framework Overview
7
8## When to Use
9- Starting work in any part of the framework for the first time.
10- Tracing the bootstrap chain before editing engine code.
11- Choosing which module owns a behavior.
12- Understanding how Atomic wraps Fat-Free Framework (F3).
13
14## Foundation
15Atomic is a **modular PHP 8.1+ framework** built on top of **Fat-Free Framework** (`bcosca/fatfree-core ^3.9.1`).
16
17- F3 owns: router, **hive** (global key-value store `$f3->get/set`), template engine, Cortex ORM.
18- Atomic adds: config loading, middleware, plugin management, auth, queue, scheduler, telemetry, theme, and DX tooling on top of F3.
19- Runtime state (config, session, DB connections, locale) lives in the F3 hive. Modules communicate through hive keys, not direct coupling.
20
21## Bootstrap Chain
22
23```
24engine/index.php
25 └─ bootstrap/app.php
26 1. bootstrap/const.php ← ATOMIC_LOADER, ATOMIC_DIR, ATOMIC_ENV, etc.
27 2. ConfigLoader::init($f3, .env) OR (new PhpConfigLoader($f3))->load()
28 3. App::instance($f3)
29 ├─ prefly() ← PHP/extension checks, storage writability
30 ├─ register_logger()
31 ├─ register_exception_handler()
32 ├─ register_locales()
33 ├─ register_middleware()
34 ├─ register_routes()
35 ├─ register_core_plugins()
36 ├─ register_plugins()
37 ├─ init_session()
38 ├─ open_connections()
39 └─ register_user_provider()
40 4. App\Event\Application::instance()->init()
41 5. App\Hook\Application::instance()->init()
42 6. $f3->run()
43```
44
45For CLI:
46```bash
47php atomic <command> # e.g. php atomic schedule/run
48# internally: App::instance()->handle_command($argv)
49# normalizes "schedule:run" → "/schedule/run" then calls run()
50```
51
52## Module Map
53
54```
55engine/Atomic/
56├── Core/ ← bootstrap, config, request/response, routing, middleware, crypto, log, guard
57├── App/ ← Controller, Model, Page, Storage, PluginManager
58├── Auth/ ← login flows, Google/Telegram OAuth, adapters, services
59├── Session/ ← SessionManager, SQL + Redis session drivers
60├── Queue/ ← job queue, workers, DB/Redis drivers, monitor, applications
61├── Scheduler/ ← cron-style task scheduler + Mutex overlap protection
62├── Telemetry/ ← diagnostics panel served at /telemetry
63├── Theme/ ← Theme boot, Head, Assets, OpenGraph, Schema
64├── Hook/ ← WordPress-style add_action/add_filter/do_action/apply_filters
65├── Event/ ← dot-notation typed event bus (Event::instance()->on/emit)
66├── Lang/ ← i18n, locale files, lang_url(), get_locale()
67├── Mail/ ← SMTP wrapper: mail_to()->set_html()->send()
68├── Mutex/ ← distributed locking: Mutex::acquire/release/synchronized
69├── Plugins/ ← built-in integrations: Monopay, WordPress, WooCommerce, RSS...
70├── Files/ ← PDF, XLS, CSV export
71├── Cache/ ← DB and Memcached cache drivers
72├── Tools/ ← Nonce, Transient, Telegram, AIConnector
73├── Validator/ ← model-level validation via Validator + ValidatorModelTrait
74├── WebSockets/ ← Workerman-based WebSocket server base class
75├── Exceptions/ ← typed exception hierarchy (AtomicException, ...)
76├── Enums/ ← PHP 8.1 backed enums: Role, Rule, Currency, Language, LogLevel
77├── CLI/ ← console command layer: php atomic <cmd>
78├── API/ ← API entrypoint wrapper
79├── Codes/ ← Code constants
80└── Support/ ← global helper functions (helpers.php)
81```
82
83## Routing Quick Reference
84
85```php
86// Basic
87$app->route('GET /users', 'App\\Http\\Controllers\\Users->index');
88
89// With middleware (array = MiddlewareStack; disables F3 route caching)
90$app->route('GET /dashboard', 'App\\Http\\Controllers\\Dashboard->index', ['auth']);
91
92// With TTL cache (seconds; no middleware)
93$app->route('GET /posts/@id', 'App\\Http\\Controllers\\Posts->show', 60);
94
95// Parameterized middleware
96$app->route('GET /admin', 'App\\Http\\Controllers\\Admin->index', ['auth', 'role:admin']);
97```
98
99Route dispatch by request type:
100| Path prefix | Route file loaded |
101|---|---|
102| CLI (`php atomic`) | `routes/cli.php` |
103| `/api/*` | `routes/api.php` |
104| `/telemetry/*` | `engine/.../Routes/telemetry.php` |
105| everything else | `routes/web.php` |
106
107Route files: `routes/web.php`, `routes/api.php`, `routes/cli.php`, `routes/schedule.php`.
108
109## Key Skills to Load Next
110| Task | Load skill |
111|---|---|
112| Config, request, middleware, logging | `atomic-framework-core` |
113| Controllers, models, storage | `atomic-framework-app-auth` |
114| Auth, session, OAuth | `atomic-framework-app-auth` |
115| Queue, scheduler, telemetry | `atomic-framework-queue-scheduler-telemetry` |
116| Theme, head, assets, OpenGraph | `atomic-framework-theme` |
117| Hooks, events, mail, i18n | `atomic-framework-event-hook-lang-mail` |
118| Mutex, session state, nonce, transient | `atomic-framework-mutex-session` |
119| Plugins, integrations | `atomic-framework-plugins` |
120| CLI commands, API | `atomic-framework-cli-api` |
121| PDF/XLS, validation, cache, exceptions | `atomic-framework-data` |
122| AI connector, WebSockets, tools | `atomic-framework-tools-websockets` |
123
124## Guardrails
125- Modules communicate through the F3 hive, not direct cross-module coupling.
126- Always identify the owning module first. Never add a feature to the wrong module.
127- Do not bypass `App::register_*()` lifecycle methods - they exist to wire the correct dependencies in order.
128- Load the matching subsystem skill before making non-trivial changes.