3.3 KiB
3.3 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Build & Development Commands
flutter pub get # Install dependencies
flutter analyze # Run static analysis (run after every task)
dart format <paths> # Format code
flutter test # Run tests
flutter run -d <device> # Run app on device
dart run build_runner build # Generate ObjectBox code after entity changes
Important: Run flutter analyze after every task and fix any reported issues before committing.
Architecture Overview
This is a Flutter app for job/task management with MQTT-based backend communication. The app is written in German for end users.
Core Components
AppState (lib/app_state.dart)
- Singleton managing global state:
appUserId, in-memory jobs list - Handles persistence via DatabaseService with coalesced writes
- Emits
jobsUpdatedevents via both StreamController and DartMQ
DartMQ (lib/services/dart_mq.dart)
- Lightweight in-app pub/sub message bus for decoupled communication
- Key topics defined in
MQTopics:connectionStatus,authResponse,jobsResponse,taskEvents,jobsUpdated,chatIncoming,chatOutgoing - UI and services subscribe/publish without direct dependencies
MqttService (lib/services/mqtt_service.dart, aliased as StompService)
- MQTT client connecting to Mosquitto broker at
mqtt-2.assecutor.de:42099 - Handles authentication, job loading, chat messages, task completion
- Message envelope pattern with ACK/retry system for reliable delivery
- Offline message queuing via DatabaseService
- Publishes all server events through DartMQ topics
DatabaseService (lib/services/database_service.dart)
- ObjectBox-based local persistence
- Stores jobs, task status, user data, chat messages, queued MQTT messages
- Entities in
lib/entities/requiredart run build_runner buildafter changes
Data Flow
LoginViewinitiates MQTT connection, sends credentials to/server/login- Server responds on
/client/{appId}/auth→ MqttService publishesMQTopics.authResponse - On success,
AppStatestoresappUserId,JobsViewrequests jobs via/server/{userId}/jobs/assigned - Jobs arrive on
/client/{userId}/jobs→ published toMQTopics.jobsResponse→ persisted → UI refresh viaMQTopics.jobsUpdated - Task updates flow through
/client/{userId}/notifications→MQTopics.taskEvents
Models
- Job (
lib/models/job.dart): Contains pickup/delivery addresses, cargo items, and tasks - Task (
lib/models/task.dart): Abstract base with subtypes:ConfirmationTask,PhotoTask,TodoListTask,SignatureTask,BarcodeTask,CommentTask,GenericTask - ChatMessage (
lib/models/chat_message.dart): Chat with direction, content type, job linking
Views
LoginView→JobsView→CargoItemsView→ Task screensChatsView→ChatDetailsView- Task capture screens in
lib/tasks/: photo, signature, barcode
Key Patterns
- All services are singletons (factory constructors returning
_instance) - MQTT messages wrapped in
MessageEnvelopefor reliable delivery with ACK - UI subscribes to DartMQ topics rather than holding service references
- Jobs are normalized before persistence to ensure consistent data