How microsoft/windows-appsample-customers-orders-database works
Project type and purpose
• Project type: Full-stack desktop + cloud sample
• Purpose: A WinUI 3 (.NET 6) desktop client showcasing MVVM, Azure AD authentication, data access via repository pattern (SQLite or REST), backed by an ASP .NET Core 6 Web API and SQL database (LocalDB or Azure SQL).
File structure
• ContosoApp: WinUI 3 front-end using MVVM
• ContosoModels: Shared data models (Customer, Order, Product, etc.)
• ContosoRepository: Repository interfaces + two implementations—Sql (EF Core over SQLite/SQL Azure) and Rest (HTTP client to Web API)
• ContosoService: ASP .NET Core Web API (Controllers → EF Core DbContext → SQL database)
• Assets: Sample SQLite DB, SQL schema script
• Config files: appsettings.json (Service), Constants.cs (Repo endpoints & AAD client IDs)
README for additional insights
• Authentication: Azure AD via MSAL
• Patterns: MVVM in UI; Repository pattern abstracts data source; List/details and form layouts
• Technologies: WinUI 3, .NET 6, Entity Framework Core, ASP NET Core Web API, MSAL, SQLite, SQL Azure
Main components & relationships
a. Frontend (ContosoApp)
– MVVM layers: Views (XAML), ViewModels, UserControls
– MsalHelper → Azure AD for token acquisition
– RepositoryFactory chooses either SqlRepo or RestRepo based on user setting
b. Repository layer (ContosoRepository)
– IContosoRepository + specific interfaces (ICustomerRepository, etc.)
– Sql implementation (EF Core ⇒ ContosoContext ⇒ SQLite/SQL Azure)
– Rest implementation (HttpHelper ⇒ ASP NET Core Web API)
c. Backend Web API (ContosoService)
– Controllers (CustomerController, OrderController, ProductController)
– EF Core DbContext (SqlContosoRepository)
– Data store: SQL Azure or LocalDB
d. External services
– Azure Active Directory (authentication/authorization)
– Azure SQL (optional production DB)
Architectural patterns & design principles
• MVVM separates UI/ViewModels
• Repository pattern hides data-access details
• Dependency injection in Service and in ContosoApp (via factory or DI container)
• Token caching for MSAL desktop flows
• /details and responsive UI for Windows 11
Minimum elements
• Clear labels: Component names + technology
[User]
↓
[ContosoApp UI (WinUI 3)]───→[Authentication (MsalHelper)]───→[Azure AD]
│
└─→[ViewModels & UserControls]
│
↓
[RepositoryFactory]
├─→[SqlContosoRepository (EF Core)]───→[SQLite file or SQL Azure DB]
└─→[RestContosoRepository (HTTP/JSON)]───→[ContosoService Web API]───→[EF Core DbContext]───→[SQL Azure or LocalDB]
• UI layer (blue)
• Auth (green)
• Data layer (orange)
• External/Cloud (gray)