A lean Flutter app using Clean Architecture, Material 3, and Riverpod. The codebase is organized for desktop and mobile targets, with an auth feature (login, session, and API wiring) as the reference vertical slice.
- Flutter 3.x / Dart
^3.11 - Material 3, Roboto and Lato fonts (see
pubspec.yaml) - Riverpod, GetIt, GoRouter
- Dio,
flutter_dotenv flutter_secure_storage,flutter_svg- Mocktail (tests),
flutter_lintsplus strict analyzer language flags inanalysis_options.yaml
.
├── .env.example # Tracked template; bundled as a Flutter asset
├── lib/
│ ├── main.dart
│ ├── app/
│ │ └── app.dart
│ ├── core/
│ │ ├── core.dart
│ │ ├── api_utils/ # ApiBaseService, failures, auth interceptor
│ │ ├── config/ # AppConfig, env loader
│ │ ├── locator/
│ │ ├── navigator/ # GoRouter (e.g. login route)
│ │ ├── secure_storage/
│ │ ├── theme/
│ │ ├── utils/
│ │ └── widgets/
│ └── features/
│ ├── features.dart
│ └── auth/
│ ├── auth.dart
│ ├── data/
│ ├── domain/
│ └── presentation/
├── test/
│ ├── helpers/
│ ├── unit/features/auth/data/
│ └── widget/features/auth/presentation/views/
├── analysis_options.yaml
├── pubspec.yaml
└── README.mdEach feature owns its UI, business rules, repository contract, and data implementation.
presentation -> domain <- dataapp: bootstrap and rootMaterialApp.router.core: shared infrastructure (DI, HTTP, env, routing, theme, secure storage).features: vertical modules; today this isauth(login flow and session models).
Example flow:
LoginView
-> auth providers (Riverpod)
-> AuthRepository
-> AuthRemoteDataSource
-> ApiBaseServiceKeep core small. Add shared code only when more than one feature needs it.
Good core candidates: app config, dependency injection, API client and failures, navigation, secure storage, logging, theme, and cross-cutting utilities.
Every folder that exposes reusable Dart files should have a barrel file.
Use exactly these two root-barrel imports when you need shared core plus feature exports (same order and URIs as lib/features/auth/data/datasource/auth_remote_datasource.dart):
import 'package:zedu/core/core.dart';
import 'package:zedu/features/features.dart';If you rename the app in pubspec.yaml, update the package: name in both lines to match.
Export chain:
leaf files -> layer barrel -> feature barrel -> features.dart
shared core files -> core.dartRules:
- Add new exports whenever you add a reusable file.
- Prefer
core/core.dartfor shared app infrastructure. - Prefer
features/features.dartwhen code needs feature-level exports. - Inside a feature, use the narrowest useful barrel when
features.dartwould create an import cycle—often a layer barrel (data/data.dart,domain/domain.dart,presentation/presentation.dart) or a subfolder barrel.
Narrower than features.dart: import that feature’s barrel first, e.g. lib/features/auth/auth.dart. Reach for layer or subfolder barrels only when you need a smaller slice to break a cycle or keep dependencies obvious.
Env keys are read from dotenv after loadAppEnv() in main.dart. The repo bundles the tracked .env.example as a Flutter asset, so a fresh clone builds and runs without creating a local .env. loadAppEnv() still prefers .env when it is present in the asset bundle, then falls back to .env.example.
- Edit
.env.examplefor values that should ship with the repo. - Prefer CI variables or
--dart-definefor local or production overrides (avoid committing secrets). - If you need a local
.env, add it back toflutter.assetsinpubspec.yaml; it then takes precedence over.env.example.
API_BASE_URL=https://api.staging.zedu.chat/api/v1/
USE_MOCK_DATA=falseUSE_MOCK_DATA accepts true / false (also 1 / 0, yes / no).
--dart-define overrides dotenv when you need non-file config:
flutter run --dart-define=API_BASE_URL=https://api.example.com --dart-define=USE_MOCK_DATA=falseDefaults when neither .env / .env.example nor defines set a value (see AppConfig.fromEnvironment):
API_BASE_URL=https://api.staging.zedu.chat/api/v1/
USE_MOCK_DATA=falseThe repository root is the Flutter project (pubspec.yaml and lib/ at the top level).
git clone https://github.com/hngprojects/zedu-desktop.git
cd zedu-desktopA fresh clone needs no env file: the tracked .env.example is bundled automatically.
flutter pub get
flutter runFor local overrides, pass --dart-define values (see Overrides for CI or release builds).
On Windows, run the app with one command from the repository root, in PowerShell:
.\run_windows.ps1The script works on a fresh clone and on an existing setup. It checks the current state at every step and skips, repairs or redoes its work, including the Agora SDK fix in your Pub cache, so you do not need any manual steps first. The first run downloads the large Agora SDKs and takes a while. If PowerShell blocks scripts, run powershell -ExecutionPolicy Bypass -File .\run_windows.ps1. Use .\run_windows.ps1 build for a debug build and .\run_windows.ps1 --release for release. It needs Flutter, Visual Studio with Desktop development with C++, and Windows Developer Mode. The full guide, with a manual fallback, is in windows-setup-locally.md.
Tested with Flutter 3.47.7 and Visual Studio 2026 Community (Desktop development with C++). Run every command in PowerShell, do not run Flutter as administrator, and never commit or share your .env file.
The script handles these build errors, and the guide explains each one:
Cannot extract through symlinkfrom the Agora pluginNo file or variants found for asset: .enverror STL1011inaudioplayers_windowsfile cannot create directory: C:/Program Files/zeduduring installCannot open include file: 'AgoraMediaBase.h'when the clone path is too longCannot open source file ... cpp_client_wrapper\core_implementations.ccafter a build from a long pathFailed to install nuget package Microsoft.Windows.ImplementationLibrarywhenapi.nuget.orgis unreachable
dart format lib test
flutter analyze
flutter testUse flutter analyze for this project so the Flutter SDK and bundled assets resolve correctly.
Tests mirror the app layout:
test/helpers: reusable test setup (e.g.TestMaterialApp)test/unit: datasources, repositories, and servicestest/widget: views and important UI flows
Mock dependencies at the layer boundary being tested.
Open Billing & Plans to see the organization's AI credit balance. Billing
and the user menu use the same balance provider: a loaded balance of 0 is
displayed as zero rather than replaced with the cached account balance. The
existing cached-account fallback remains in use during initial loading and in
the error state.
The regression tests keep a cached balance of 100, then load 0 or 25
through the credits notifier and check that Billing and the user menu agree:
flutter test test/widget/features/credits/presentation/views/buy_credits_view_test.dartwindows/packaging/ builds Zedu Desktop as an MSIX package and tests it on a clean VM. Run the scripts from the repo root in PowerShell (Windows PowerShell 5.1 or PowerShell 7). A Get-Item : Could not find item ...\AppData line during the build comes from a plugin's symlink resolver (super_native_extensions) and is harmless.
Requirements:
- Flutter.
- Visual Studio with "Desktop development with C++", including C++ ATL.
- The Windows 10/11 SDK, for
makeappx.exeandsigntool.exe. - A local
.env(Copy-Item .env.example .env). Its values are bundled into the package, so keep it free of secrets.
.\windows\packaging\package_msix.ps1 -SignThis runs flutter build windows --release, stages the Release folder together with the MSVC runtime, fills in windows/packaging/AppxManifest.template.xml and packs build\msix\Zedu_<version>.msix.
- Version: taken from
pubspec.yaml(0.1.0+1becomes0.1.0.0). Use-Versionto override it. -SkipBuild: reuses the last release build.-VsInstance: pins CMake to a Visual Studio install. Use it if several are installed and the build fails withatlstr.hnot found.
The manifest declares the zedu:// protocol and the microphone and webcam capabilities used for voice notes and calls. Tile and splash images live in windows/packaging/Assets. Regenerate them after an app icon change with windows\packaging\make_msix_logos.ps1.
-Sign signs with a self-signed certificate, CN=Zedu Desktop Test, created once in your CurrentUser\My store. It also writes build\msix\zedu_test.cer. To install on a test machine, run an admin PowerShell:
Import-Certificate -FilePath zedu_test.cer -CertStoreLocation Cert:\LocalMachine\TrustedPeople
Add-AppxPackage -Path Zedu_0.1.0.0.msixStore builds use the Partner Center identity (-IdentityName, -Publisher) and are uploaded unsigned.
vm_test_msix.ps1 reverts a VMware Workstation VM to a snapshot, then:
- copies in the package and certificate, and trusts the certificate;
- installs the package and checks the Start menu entry;
- launches the app, then opens a
zedu://link; - checks the event log for
zedu.exeerrors, uninstalls, and reverts.
$env:ZEDU_VM_GUEST_PASSWORD = '<guest login>'
$env:ZEDU_VM_PASSWORD = '<VM encryption password, Windows 11 + vTPM only>'
.\windows\packaging\vm_test_msix.ps1 -VmxPath "E:\VMs\Win11\Windows 11 x64.vmx" -SnapshotName "Clean Base" -GuestUser testerTake the snapshot with that guest user (an administrator) signed in at the desktop. Logs, screenshots and summary.txt go to build\msix\vm-test\<timestamp>\, and the script exits with code 1 if any check fails.