How mobile-innowise-group/devpilot works
Project type and purpose
• DevPilot is a command-line interface (CLI) code generator written in Dart.
• Purpose: Prompt the user for specifications, then scaffold a multi-module Flutter project (Core, Core UI, Domain, Data, Navigation, Features).
File structure
• bin/dev_pilot.dart – the CLI entrypoint; invokes the generation workflow.
• lib/src/ – core source:
– services/ (DirectoryService, FileService, InputService, ScriptService)
– validators/ (Validator)
– constants/ (AppConstants)
– templates/ (feature templates, prebuild scripts)
• example/ – demo usage
• doc/api/ – generated API docs
• .github/ – CI pipeline (publish.yml)
• pubspec.yaml – dependencies (dcli, mason_logger, args)
README for additional insights
• Key external libraries: dcli (prompting, file I/O), mason_logger (logging).
• Workflow phases: Input → Validation → Directory scaffolding → File writing → Script execution.
• Outputs: a fully scaffolded Flutter project with a fixed module layout.
Diagramming the main components
a. Components
1. CLI Entrypoint
– bin/dev_pilot.dart
– Uses args package to parse “create” command
2. Input & Validation Layer
– InputService (prompts user via dcli)
– Validator (ensures valid module names, flavors)
3. Core Services
– DirectoryService (creates folders)
– FileService (writes templates into target directories)
– ScriptService (runs any prebuild scripts)
4. Template Store
– lib/src/templates (feature templates, pubspec stub, prebuild script)
5. External Libraries
– dcli (I/O, prompting)
– mason_logger (console logging)
6. Output Artifact
– Generated Flutter project (module directories: core, domain, data, core_ui, navigation, features)
7. CI/Publishing
– .github/workflows/publish.yml (publishes to pub.dev)
b. Relationships & Data Flow
1. User runs “dev_pilot create” → CLI Entrypoint
2. Entrypoint calls InputService → collects project name, modules, flavors
3. InputService passes data to Validator → ensures constraints
4. On success, Entrypoint orchestrates:
• DirectoryService → create root project folder and sub-folders
• FileService → copy and render template files (pubspec.yaml, lib stubs)
• ScriptService → execute prebuild scripts (shell script)
5. Throughout, mason_logger logs status and errors to console
6. Final: user inspects the generated Flutter project
c. Architectural Patterns & Principles
– Layered design: CLI layer → service layer → template engine → persistence (file system)
– Single‐responsibility: each Service class does one job
– Template‐driven code generation
– External libs abstract away I/O and logging
d. Key Technologies & Frameworks
– Dart (language)
– dcli (I/O, prompts, directory/file helpers)
– mason_logger (structured console output)
– args (command parsing)
Detailed capture of architectural elements
– Show error handling: Validator can route back to InputService on invalid input.
– Annotate any major methods or data structures if space permits (e.g., “Template variables: projectName, modulesList”).