Skip to content

Scaffold: .NET MAUI + React HybridWebView with clean architecture - #1

Merged
MatthewHsu1 merged 19 commits into
mainfrom
scaffold/maui-react-hybrid
Jun 30, 2026
Merged

MatthewHsu1 merged 19 commits into
mainfrom
scaffold/maui-react-hybrid

Conversation

@MatthewHsu1

Copy link
Copy Markdown
Owner

Summary

Scaffolds a cross-platform .NET MAUI app that hosts a React (Vite + TypeScript) UI via the native HybridWebView, organized with clean-architecture layering. One end-to-end vertical slice (Users) proves the architecture and the JS↔C# bridge work together.

Architecture

Inward dependency rule: Domain ← Application ← Infrastructure ← Maui

Project Responsibility
src/AppName.Domain Entities + ports (User, IUserRepository) — zero dependencies
src/AppName.Application Use cases (GetUsersUseCase, AddUserUseCase), UserDto, DI
src/AppName.Infrastructure EF Core/SQLite (AppDbContext, UserRepository via IDbContextFactory), DI
src/AppName.Maui Host: HybridWebView, DI composition root, CreateWindow, UsersBridge (JS↔C#)
src/web Vite + React + TS UI, typed bridge client, Vitest tests, UsersList feature
tests/* xUnit per C# layer
  • The Vite build emits into src/AppName.Maui/Resources/Raw/web (gitignored); an MSBuild target (BuildReactApp) runs it before the MAUI build, skippable via -p:SkipReactBuild=true.
  • Central NuGet version management (Directory.Packages.props); shared props (Directory.Build.props).
  • DbContext uses IDbContextFactory (no captive long-lived context, since MAUI has no request scope).

Tests

  • C#: Domain 4/4, Application 2/2, Infrastructure 1/1 (real SQLite round-trip)
  • React: 2/2 (bridge client, mocking window.HybridWebView)
  • CI (.github/workflows/ci.yml): dotnet-tests + web-tests on every PR.

Known issue

NU1903 — transitive SQLitePCLRaw.lib.e_sqlite3 high-severity advisory (GHSA-2m69-gcr7-jv3q) via EF Core SQLite. Affects all published versions (no upstream patch); inherent to EF Core SQLite. Documented in the README with mitigation options.

Notes

  • The MAUI host project's target build requires platform SDKs (Android SDK/JDK for android; macOS for iOS/Mac Catalyst; Windows for the Windows target). CI builds/tests the platform-neutral layers + the React app.
  • Design spec and implementation plan are under docs/superpowers/.

🤖 Generated with Claude Code

SoleFitnessUS and others added 19 commits June 29, 2026 16:47
Creates AppName.Maui project: MAUI app with HybridWebView (HybridRoot="web",
DefaultFile="index.html") serving React from Resources/Raw/web. MauiProgram
wires AddApplication() + AddInfrastructure(dbPath). App resolves MainPage from
DI. Workload: maui-android (includes MAUI core, controls, templates).
Override CreateWindow(IActivationState?) returning new Window(_mainPage) to
replace the soft-deprecated Application.MainPage setter (Obsolete in .NET 10).
- Switch Infrastructure DI to AddDbContextFactory<AppDbContext> (singleton factory,
  each operation creates+disposes its own DbContext — safe in MAUI's single-scope env)
- UserRepository now injects IDbContextFactory and uses await using per method
- UserRepositoryTests uses a TestDbContextFactory for a genuine cross-context round-trip
- Add trailing newlines to Domain and Infrastructure test csproj files
- Remove dead .counter CSS selector from index.css (no .counter elements rendered)
- Normalize tab indentation in AppName.Maui.csproj hand-added Target/PropertyGroup blocks
@MatthewHsu1
MatthewHsu1 merged commit 5786cea into main Jun 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants