Skip to content

Architecture ​

One page for every option

This page covers every choice of --Persistence, --Auth, --IncludeTests and --Aspire. A label says which options a part is for; the copy in your app's docs/ folder has only yours. ApiHost stands for your app's name.

The Todo feature is a working example of each pattern. Copy it when you add your own features (see Add a feature).

Backend ​

With accounts

  • Endpoints. Each endpoint is a static method with [WolverineGet] or [WolverinePost]. Wolverine finds it automatically and injects what it asks for. See src/ApiHost/Features/Todos/.
  • Validation. CreateTodoValidator (FluentValidation) runs before the endpoint. An invalid request gets a 400 response with ProblemDetails, which the React form displays.
  • Messages and the outbox. Completing a Todo returns a TodoCompleted message from the endpoint. Wolverine saves it in the same database transaction as the change (the transactional outbox) and TodoCompletedHandler handles it in the background, even after a restart.
  • Marten Event sourcing. A Todo is a stream of events (TodoCreated, then TodoCompleted). The complete endpoint uses Wolverine's aggregate handler workflow: [WriteAggregate] loads the Todo from its events, and the method returns the events to append. An inline snapshot projection keeps a Todo document up to date for queries.
  • Scheduled messages. "Remind me…" on a Todo calls POST /api/todos/{id}/remind, which schedules a TodoReminderDue message for later (Features/Todos/RemindTodoEndpoint.cs). Scheduled messages are stored in PostgreSQL, so reminders still fire after a restart. When it's due, TodoReminderDueHandler pushes a todo-reminder to the browser, unless the Todo was completed in the meantime.
  • Realtime updates. Creating or completing a Todo sends a todo-changed message to the browser over SignalR (TodoChanged, routed in Program.cs), and every open tab refetches. Each user only receives updates about their own Todos.
  • Code generation. Wolverine generates code for each endpoint and handler. In Development it does so at runtime, so changes need no extra step; dotnet publish generates it ahead of time and Production loads it ready-made, failing at startup if any is missing.
  • Accounts. ASP.NET Core Identity with JWT access tokens and rotating refresh tokens; see Accounts.

Without accounts

  • Endpoints. Each endpoint is a static method with [WolverineGet] or [WolverinePost]. Wolverine finds it automatically and injects what it asks for. See src/ApiHost/Features/Todos/.
  • Validation. CreateTodoValidator (FluentValidation) runs before the endpoint. An invalid request gets a 400 response with ProblemDetails, which the React form displays.
  • Messages and the outbox. Completing a Todo returns a TodoCompleted message from the endpoint. Wolverine saves it in the same database transaction as the change (the transactional outbox) and TodoCompletedHandler handles it in the background, even after a restart.
  • Marten Event sourcing. A Todo is a stream of events (TodoCreated, then TodoCompleted). The complete endpoint uses Wolverine's aggregate handler workflow: [WriteAggregate] loads the Todo from its events, and the method returns the events to append. An inline snapshot projection keeps a Todo document up to date for queries.
  • Scheduled messages. "Remind me…" on a Todo calls POST /api/todos/{id}/remind, which schedules a TodoReminderDue message for later (Features/Todos/RemindTodoEndpoint.cs). Scheduled messages are stored in PostgreSQL, so reminders still fire after a restart. When it's due, TodoReminderDueHandler pushes a todo-reminder to the browser, unless the Todo was completed in the meantime.
  • Realtime updates. Creating or completing a Todo sends a todo-changed message to the browser over SignalR (TodoChanged, routed in Program.cs), and every open tab refetches.
  • Code generation. Wolverine generates code for each endpoint and handler. In Development it does so at runtime, so changes need no extra step; dotnet publish generates it ahead of time and Production loads it ready-made, failing at startup if any is missing.

Frontend ​

With accounts

  • Routes. React Router in framework mode, as a single-page app with no rendering server. src/Client/src/routes.ts maps each URL to a route module in routes/, which default-exports the page. root.tsx is the HTML document, and App.tsx the frame around every page (header, navigation, footer, in components/Layout.tsx). Each page's code loads when it's first visited, so the first page view downloads less JavaScript.
  • Pre-rendered public pages. The build renders the public pages (the home page, by default) into real HTML, so search engines and link previews see their content without running JavaScript, and a CDN can cache them. The app then takes over in the browser (hydration). Every other page starts from a fallback page. Code that runs while a public page renders must not use window or document, since pre-rendering runs it in Node; use them in effects and event handlers.
  • Page titles and search engines. Each route module's handle sets its page title and whether search engines may index it (components/PageMeta.tsx); only the home page may by default, and every other page gets noindex. src/pages.ts lists every page's path and which are public: the build pre-renders those and writes the list into client-routes.json, from which the API answers 404 for other paths and builds sitemap.xml. A unit test checks it matches routes.ts. The default description and link-preview tags are in root.tsx: describe your product there.
  • Server data. TanStack Query caches the Todo list (features/todos/todoQueries.ts). Changes and SignalR messages invalidate it, which refetches it.
  • The API client (lib/api/client.ts) is typed from the API's OpenAPI document (lib/api/schema.d.ts, regenerated with npm run gen:api while the API runs). It adds the access token to each request and, on a 401, refreshes the tokens once and retries.
  • One deployable. In development, the Vite dev server forwards /api (including the SignalR WebSocket) to the API, so the browser talks to one origin and no CORS is needed. In production, the API serves the built client from wwwroot.

Without accounts

  • Routes. React Router in framework mode, as a single-page app with no rendering server. src/Client/src/routes.ts maps each URL to a route module in routes/, which default-exports the page. root.tsx is the HTML document, and App.tsx the frame around every page (header, navigation, footer, in components/Layout.tsx). Each page's code loads when it's first visited, so the first page view downloads less JavaScript.
  • Pre-rendered public pages. The build renders the public pages (the home page, by default) into real HTML, so search engines and link previews see their content without running JavaScript, and a CDN can cache them. The app then takes over in the browser (hydration). Every other page starts from a fallback page. Code that runs while a public page renders must not use window or document, since pre-rendering runs it in Node; use them in effects and event handlers.
  • Page titles and search engines. Each route module's handle sets its page title and whether search engines may index it (components/PageMeta.tsx); only the home page may by default, and every other page gets noindex. src/pages.ts lists every page's path and which are public: the build pre-renders those and writes the list into client-routes.json, from which the API answers 404 for other paths and builds sitemap.xml. A unit test checks it matches routes.ts. The default description and link-preview tags are in root.tsx: describe your product there.
  • Server data. TanStack Query caches the Todo list (features/todos/todoQueries.ts). Changes and SignalR messages invalidate it, which refetches it.
  • The API client (lib/api/client.ts) is typed from the API's OpenAPI document (lib/api/schema.d.ts, regenerated with npm run gen:api while the API runs).
  • One deployable. In development, the Vite dev server forwards /api (including the SignalR WebSocket) to the API, so the browser talks to one origin and no CORS is needed. In production, the API serves the built client from wwwroot.

Documentation for v0.8.0. Released under the MIT licence.