1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
//! Arcature — one full-stack web framework over the certified Rust ecosystem.
//!
//! Arcature is a high-level application framework that composes the certified
//! Arcature subsystem crates (Inertia, database, auth, cache, storage, mail,
//! jobs, pages, observability, API) behind a single facade, while preserving a
//! guaranteed escape hatch down to the raw Axum/Tower/Tokio ecosystem
//! underneath.
//!
//! # Getting started
//!
//! A normal application depends on the `arcature` crate with the capabilities
//! it needs, and drives the framework through [`Application`]. The simplest
//! stateless app — compiles with no features beyond the kernel:
//!
//! ```no_run
//! use arcature::prelude::*;
//!
//! async fn hello() -> &'static str {
//! "hello"
//! }
//!
//! # // `serve` is generic over `axum::serve::Listener`; an expert user brings
//! # // their own runtime. The `macros` feature's `run()` helper binds a
//! # // TcpListener for the common case (shown in the ignore block below).
//! ```
//!
//! With the `macros` feature, `#[arcature::main]` and `Application::run()`
//! remove the need for a direct `tokio` dependency:
//!
//! ```ignore
//! use arcature::prelude::*;
//!
//! async fn hello() -> &'static str {
//! "hello"
//! }
//!
//! #[arcature::main]
//! async fn main() -> Result<()> {
//! Application::new()
//! .routes(Routes::new().route("/", get(hello)))
//! .run()
//! .await
//! }
//! ```
//!
//! `Application` is the high-level composition root: it owns framework
//! lifecycle, request-pipeline assembly, and subsystem coordination. It sits
//! *above* the low-level [`App`] kernel, which remains the raw Axum-compatible
//! seam for expert use.
//!
//! # The two layers
//!
//! ```text
//! Application — high-level framework facade (lifecycle, composition)
//! |
//! App<S> — low-level HTTP kernel (raw Axum/Tower interop)
//! |
//! Axum / Tower — the upstream ecosystem
//! ```
//!
//! - **[`Application`]** — the normal user entry point. Owns routing
//! assembly, the request pipeline (pre-routing proxy, post-routing
//! middleware, fallback pages), and — when subsystem features are enabled —
//! deterministic startup and graceful shutdown of database, cache, storage,
//! mail, jobs, and observability.
//! - **[`App`]** — the low-level HTTP kernel. A thin wrapper over
//! [`axum::Router`] that forwards to `axum::serve`. Use it directly when you
//! want raw Axum/Tower with no framework opinions.
//!
//! # Features
//!
//! The facade re-exports each certified subsystem behind a Cargo feature, so a
//! minimal application pulls no heavyweight runtime:
//!
//! ```toml
//! [dependencies]
//! arcature = { version = "2026.1.0", features = ["inertia", "db", "pages", "observe"] }
//! ```
//!
//! `default = []` keeps the bare HTTP kernel. `fullstack` enables every runtime
//! subsystem (but never auto-connects to a service — features are compile-time
//! capabilities, not runtime permission). See the crate `Cargo.toml` for the
//! full feature graph.
//!
//! # Advanced: the raw escape hatch
//!
//! Arcature hides complexity without hiding capability. Expert code can still
//! reach Axum, Tower, and every subsystem crate directly:
//!
//! ```no_run
//! use arcature::App;
//! use arcature::axum::routing::get;
//! use arcature::axum::Router;
//!
//! async fn hello() -> &'static str { "hello" }
//!
//! // Build a raw Axum router, wrap it in the kernel, serve it.
//! # #[tokio::main] async fn main() -> std::io::Result<()> {
//! let router: Router = Router::new().route("/", get(hello));
//! # let _ = router;
//! # Ok(()) }
//! ```
//!
//! [`axum::Router`] is re-exported as [`axum`] so downstream code targets the
//! certified version through Arcature. Use [`App::into_router`] /
//! [`App::from_router`] to move between the kernel and a raw router.
//!
//! [Axum]: https://docs.rs/axum
// Re-export the certified `axum` crate so downstream code uses the escape
// hatch through Arcature's pinned dependency (e.g. `arcature::axum::routing`).
pub use axum;
// Low-level HTTP kernel (Phase 1) — the raw Axum/Tower seam.
// High-level Application engine (engine phase) — the composition root.
// A1: the DX layer runtime contracts (DxComponent trait) and the
// `arcature-dx` proc-macro re-exports. Gated behind the `dx` feature so
// applications opt in to the application programming model. The module is
// private; its public items are re-exported at the crate root below.
// The curated prelude is a public module so applications write
// `use arcature::prelude::*;` (engine spec §19).
pub use App;
pub use Application;
pub use ApplicationBuilder;
pub use EngineError;
pub use ProxyFn;
pub use Result;
// `Resources` is the typed handle bundle passed to the `state_fn` closure of
// `run_with_lifecycle` / `serve_with_lifecycle`. It is re-exported at the
// crate root so application code can name the type (e.g. in helper function
// signatures). Only available when the `macros` feature + at least one
// lifecycle subsystem is enabled.
pub use Resources;
pub use Routes;
// Re-export the Axum method-routing constructors at the crate root so the
// `routes!` macro expansion can reference them via `::arcature::get`, etc.
// This is the same certified upstream function, forwarded verbatim.
pub use ;
// Re-export `from_fn` at the crate root so the `routes!` macro's middleware
// expansion (`::arcature::from_fn(mw)`) resolves. Also useful for
// applications that wire `from_fn` middleware directly.
pub use from_fn;
// Re-export axum's `Redirect` response type at the crate root so the
// `redirect!` macro expansion can reference it via `::arcature::Redirect`.
pub use Redirect;
// Facade modules — namespaced re-exports of the certified subsystem crates.
// `facade` is private; its `pub mod` children are re-exported at the crate
// root so a normal application reaches them as `arcature::inertia`,
// `arcature::db`, etc. Each re-export is feature-gated so only enabled
// subsystems appear on the public surface, and no `pub use` fires under
// `--no-default-features` (engine spec §18/§34/§55). Explicit per-feature
// re-exports (rather than a glob) keep the public surface auditable.
pub use api;
pub use auth;
pub use cache;
pub use db;
pub use inertia;
pub use jobs;
pub use mail;
pub use observe;
pub use pages;
pub use storage;
// A1: the Arcature DX layer (ADR-0003). Behind the `dx` feature:
// - `DxComponent` (type namespace) — the runtime trait that
// `#[derive(DxComponent)]` generates an impl for.
// - `DxComponent` (macro namespace) — the derive macro re-exported from
// `arcature-dx` so applications write `#[derive(arcature::DxComponent)]`
// without importing `arcature_dx` directly.
// The trait and derive macro share the name `DxComponent` because they
// live in different namespaces (the same pattern as `serde::Serialize` the
// trait and `serde::Serialize` the derive). The `arcature_dx` crate itself
// is also re-exported so attribute macros (when added in later A-phases)
// are reachable as `arcature::arcature_dx::<MacroName>`.
pub use arcature_dx;
pub use DxComponent;
pub use ApplicationGraph;
pub use ControllerMethod;
pub use DxComponent;
pub use Empty;
pub use GraphError;
pub use Json;
pub use ModuleDescriptor;
pub use ModuleNode;
pub use Page;
pub use RouteDescriptor;
pub use RouteMethod;
pub use Validated;
// A7: the route model binding contract and Bound<T> extractor. Behind
// `dx` + `db` (for the RouteModel trait, which references Db) and `api`
// (for Bound<T>, which produces Problem responses on 404/400/500).
pub use Bound;
pub use DbFromState;
pub use RouteModel;
// A9: the auth/policies/session/flash DX layer (ADR-0004). Behind `dx` +
// `auth` (auth extractors need `tower_sessions::Session` from
// `arcature-auth`). The `#[policy]` macro generates `impl DxComponent`
// only — the developer writes `impl Policy<M>` by hand (the authorization
// logic is business behavior the macro must not guess or hide).
//
// `AuthUser` / `UserLoader` are the application identity contracts — the
// application implements them for its user type. `Auth<U>`,
// `OptionalAuth<U>`, and `AuthManager<U>` are genuine Axum
// `FromRequestParts` extractors. `Session` and `Flash` are ergonomic
// wrappers over `tower_sessions::Session`. `Policy<M>` is the explicit
// authorization trait. `AuthzError` is the typed 403 error.
pub use policy;
pub use ;
pub use ;
pub use ;
// A10: the middleware attribute macro and error-mapping layer. `#[middleware]`
// validates a function signature (`pub`, `async`, return type present) and
// passes it through unchanged so it remains a genuine Axum `from_fn`
// middleware. `ErrorMapFn` is the type-erased response-mapping function
// installed via `Application::error_mapping(...)`. Behind `dx`.
pub use middleware;
pub use ErrorMapFn;
// A11: the event/listener DX layer. `#[derive(Event)]` generates
// `impl DxComponent` + `impl Event` for typed application events. `#[listener(
// Event)]` validates a function signature and generates a `ListenerBinding`
// const for `arc check` inspection. `Dispatcher` is the type-erased in-process
// event dispatcher — listeners run sequentially in registration order. Behind
// `dx` + `serde` (events are type-erased via `serde_json::Value`).
pub use Event;
pub use listener;
pub use ;
// A12: the jobs/scheduler/commands DX layer. `#[derive(Job)]` generates
// `impl DxComponent` + `impl Job` + a `JobModel` const for typed enqueue.
// `#[job_handler]` validates a function signature and generates a
// `JobBinding` const for `arc check` inspection. `#[command("name")]`
// generates a `CommandBinding` const. `Scheduler` is the managed
// recurring-job enqueuer with `CancellationToken` lifecycle. `CommandRegistry`
// is the type-erased command dispatcher for `arc run`. Behind `dx` + `jobs`
// (and `serde` for the `Job` derive — payloads are type-erased via
// `serde_json::Value`, matching the A11 `Dispatcher` and the `arcature-jobs`
// `Registry` patterns).
pub use Job;
pub use command;
pub use job_handler;
pub use Job;
pub use ;
// A14: the testing DX layer. `#[test(app = <expr>)]` wraps an
// `async fn(app: TestApp)` into a `#[tokio::test]` that builds a `TestApp`
// from the caller's router expression — removing the `TestApp::new(...)`
// boilerplate while keeping the test honest (a real socket, a real HTTP
// client). Behind `dx` (the proc-macro re-export). The macro expansion
// references `::arcature_test::` paths that resolve in the downstream crate,
// so the caller must depend on `arcature-test`; `arcature` itself does not
// depend on `arcature-test` (the dependency direction is
// arcature-test → axum, not arcature-test → arcature → axum; §16).
pub use test;
// return `Json<T>` / `Page<T>` can derive `Serialize` without a direct
// `serde` dependency. This mirrors the prelude re-export (engine spec §44).
pub use ;
// A5: the certified validator surface at the crate root so `#[request]`
// can generate `#[derive(::validator::Validate)]` and controllers can
// bound on `T: Validate`. The `derive` feature is on, so both the trait
// and the derive macro are accessible through `::arcature::Validate`.
pub use Validate;
// A6: the page and resource DX macros. `#[page("name")]` generates
// `impl ClientData`, `Serialize` derive, and a `PageContract` const.
// `#[resource]` generates `impl ClientData` and `Serialize` derive. Both
// require the `inertia` feature (for `ClientData` / `PropsSchema` /
// `ContractType` / `PageContract`) and the `dx` feature (for the proc-macro
// re-export). `page!` constructs a `Page<T>` with a compile-time
// `ClientData` assertion.
pub use page;
pub use page_macro;
pub use resource;
// A7: the #[route_model] attribute macro. Behind `dx` + `db` (the macro
// generates an `impl RouteModel` that references `::arcature::db::Db` and
// `::arcature::db::sea_orm`).
pub use route_model;
// A8: the typed services/providers DX layer (ADR-0004). Behind the `dx`
// feature — services and providers are pure composition over application
// state, not tied to any specific subsystem. The `#[service]` macro
// generates `impl DxComponent`, `impl Service`, and `impl Resolve<S>`. The
// `#[provider]` macro generates `impl DxComponent` (the developer writes
// `impl Provider` by hand — the init logic is business behavior).
//
// `Resolve<S>` is the typed resolution trait (no runtime container). `Db`
// gets a `Resolve<S>` impl behind `dx` + `db` (via the existing
// `DbFromState<S>`). Other resources get manual one-line impls from the
// application. `Inject<T>` is the Axum extractor that calls `T::resolve`.
pub use provider;
pub use service;
pub use Inject;
pub use Provider;
pub use Resolve;
pub use Service;
// `#[arcature::main]` re-exports the certified Tokio multi-thread runtime macro
// so a normal application needs no direct `tokio` dependency merely for
// `#[tokio::main]` (engine spec §23). Expert users may still bring their own
// runtime and call the async `Application::serve` / `App::serve` APIs without
// this feature.
pub use main;