Development environment setup
Steps required to run the server, the panel, and the mobile agent on a machine from scratch.
2.1 Requirements
Section titled “2.1 Requirements”| Tool | Version | Note |
|---|---|---|
| Dart SDK | ^3.12.2 |
All packages; Docker image dart:3.12.2 |
| Flutter | ^3.44.4 |
Panel and agent; CI uses 3.44.4 |
| Serverpod CLI | 4.1.2 | dart install serverpod_cli 4.1.2 |
Android SDK + adb |
For the agent; emulator or physical device | |
| Docker | not needed | Development and tests use embedded PostgreSQL |
PostgreSQL is not installed separately. Thanks to database.dataPath in
config/development.yaml and config/test.yaml, Serverpod starts its own embedded PostgreSQL 16
under .serverpod/<mod>/pgdata. Redis is disabled in all modes.
2.2 Repository structure
Section titled “2.2 Repository structure”The root pubspec.yaml is a pub workspace:
wonkru_mdm/ pubspec.yaml workspace (name: _) wonkru_core_server/ Serverpod module: shared enums, DTOs, catalog wonkru_core_client/ generated client of the module wonkru_mdm_server/ server wonkru_mdm_client/ generated client (not edited by hand) wonkru_mdm_flutter/ admin panel wonkru_mdm_mobil/ Android agent (not a workspace member, has its own lock)Application source: wonkru_mdm. Documentation: docs.wonkrumdm.com.
2.3 Secrets: config/passwords.yaml
Section titled “2.3 Secrets: config/passwords.yaml”Generate local development secrets from the application repository root:
flutter pub getdart run wonkru_mdm_server/tool/create_dev_passwords.dartThe command creates a development: block with independent random values and
refuses to overwrite an existing file. Configure other run modes separately;
production deployment uses deploy/vps/init-env.sh to create its own secrets.
The file is not committed to git. Create it if it does not exist; one block is needed for each
mode. Values must be random and long (e.g. openssl rand -base64 48).
development: database: '<random>' redis: '<random>' serviceSecret: '<random>' emailSecretHashPepper: '<random>' jwtHmacSha512PrivateKey: '<random>' jwtRefreshTokenHashPepper: '<random>' passwordHashPepper: '<random>' storageSigningKey: '<at least 32 characters, optional>'
test: database: '<random>' redis: '<random>' emailSecretHashPepper: '<random>' jwtHmacSha512PrivateKey: '<random>' jwtRefreshTokenHashPepper: '<random>' passwordHashPepper: '<random>'
# staging: and production: blocks with the same keys (except redis)Each key can also be provided with the SERVERPOD_PASSWORD_<key> environment variable.
2.4 Starting the server and the panel
Section titled “2.4 Starting the server and the panel”cd wonkru_mdm_serverserverpod startserverpod start:
- Opens embedded PostgreSQL and applies pending migrations.
- Starts the server; on file changes it generates code and hot reloads.
- Opens the panel in Chrome at
http://localhost:8099vialib/driver.dart(serverpubspec.yaml→serverpod.flutter_apps.wonkru_mdm). Ctrl+R reopens the panel.
On first launch the panel shows a “set up first admin” form. Enter an email and password to create the first admin, then sign in.
In development, account registration and password-reset verification codes are written to the server log.
Ports (development)
Section titled “Ports (development)”| Service | Port | Note |
|---|---|---|
| API (RPC + device stream) | 8090 | The panel and agent connect here |
| Insights | 8081 | Serverpod Insights |
| Web server | 8082 | Compiled panel, /storage, /downloads/local-ca |
Panel (flutter run) |
8099 | Fixed; in allowedOrigins for the cookie |
| Embedded PostgreSQL | 8090 | Unix socket only (.serverpod/development/run), does not listen on TCP |
| Test DB | 9090 | Embedded |
The API and the embedded DB show the same port number, but they do not conflict because the DB
does not listen on TCP. If you start an external Postgres with docker-compose.yaml, it conflicts
with the API on 8090; change the port if you are going to use compose.
Connecting to the development database
Section titled “Connecting to the development database”Embedded PostgreSQL listens only on a unix socket:
psql -h "$PWD/.serverpod/development/run" -p 8090 -U postgres wonkru_mdm(from the wonkru_mdm_server directory; password passwords.yaml → development.database.)
Running the panel separately
Section titled “Running the panel separately”cd wonkru_mdm_flutterflutter run -d chrome --web-port=8099Login does not work on any port other than 8099.
2.5 Connecting the mobile agent to the local server
Section titled “2.5 Connecting the mobile agent to the local server”Emulator
Section titled “Emulator”The emulator reaches the host machine via 10.0.2.2. That is why
webServer.publicHost: 10.0.2.2 in development.yaml is left this way (the APK/file/certificate
download addresses in the policy are generated from this host).
cd wonkru_mdm_mobilflutter run --debug --dart-define-from-file=config.json --dart-define=HOST=10.0.2.2adb shell dpm set-device-owner com.wonkrumdm/.core.receivers.MdmDeviceAdminReceiverDo not add a Google account to the emulator image.
Physical device
Section titled “Physical device”The device must be on the same network as the computer and must reach the server via the LAN IP:
- In
config/development.yaml, locally (without committing) change theapiServer.publicHostandwebServer.publicHostvalues to the machine’s LAN IP. HOSTinwonkru_mdm_mobil/config.jsonmust be the same IP.- Let the machine’s firewall open 8090 and 8082 to the LAN.
- Factory reset the device (without adding an account), install the APK, and assign Device Owner (Mobile agent).
localhost and 10.0.2.2 do not work on a physical device; the device enrolls but cannot
download APKs and files.
Enrollment
Section titled “Enrollment”The agent’s setup screen asks for the server address and the enrollment key. Instead of typing
the key (WNKR-XXXX-XXXX-XXXX), scan the panel’s enrollment QR from the setup screen’s camera
button, push it with tool/adb_enroll.sh, or set ENROLLMENT_KEY in config.json. The key is
under Settings → Device Enrollment Key in the panel. Before enrollment, create a policy in the
panel and make it the default; a device without a policy cannot complete setup.
HTTPS and self-signed certificate (optional)
Section titled “HTTPS and self-signed certificate (optional)”You can use HTTP for development. To use HTTPS with your own CA, save the CA certificate in
PEM format at wonkru_mdm_server/certs/local-ca.crt. The server makes it available at
/downloads/local-ca. For Docker Compose and first-time Android enrollment, follow the
TLS guide. HTTPS with your own TLS certificate
2.6 Code generation and migration
Section titled “2.6 Code generation and migration”While serverpod start is running, code is generated automatically on model (*.spy.yaml) or
endpoint changes. If the table schema changes, create a migration and apply it before using
the new schema. For manual code generation or migration creation, run:
cd wonkru_mdm_server && serverpod generatecd wonkru_mdm_server && serverpod create-migrationA destructive change needs --force. lib/src/generated/ and wonkru_mdm_client/ are not edited
by hand.
2.7 Checklist
Section titled “2.7 Checklist”After a change, in this order:
cd wonkru_mdm_server && dart analyze && dart format .cd wonkru_mdm_server && dart testcd wonkru_mdm_flutter && flutter analyze && flutter testcd wonkru_mdm_mobil && flutter analyze && flutter testTests do not need Docker.
2.8 IDE and CI
Section titled “2.8 IDE and CI”.vscode/tasks.json: theserverpod_starttask..vscode/launch.json: attach to the panel and the server, and a “full stack” compound that launches both together..github/workflows/:analyze.yml,format.yml,tests.yml. All three are triggered only manually (workflow_dispatch) and cover only the server. There is no CI for the panel and the agent.