v0.21

cli

introduction

dframework includes a command line interface accessible via the dstrn binary. it provides commands for scaffolding new projects, managing the database, generating application files, analyzing architecture, and running an interactive shell.

1dstrn help

available commands

scaffolding

command description
dstrn init <dir> [--ai] scaffold a minimal project with optional ai helpers
dstrn serve run the server in the current directory
dstrn tinker open an interactive repl shell with models preloaded
dstrn key:generate generate a random encryption key

database

command description
dstrn migrate run all pending migrations
dstrn migrate:status display migration status
dstrn migrate:rollback rollback the last migration batch
dstrn migrate:make <table> create a new migration template
dstrn seed run all seeders
dstrn seed:make <Name> create a new seeder template
dstrn drop drop the database with confirmation
dstrn advisor [--apply] inspect unindexed relationships and generate migrations

generators

command description
dstrn make:model <Name> create a new model
dstrn make:controller <Name> create a new controller
dstrn make:middleware <Name> create a new middleware
dstrn make:command <Name> create a new console command
dstrn make:job <Name> create a new background job
dstrn make:component <Name> create a new view component

system

command description
dstrn run <CommandName> run a user command from console/commands
dstrn dispatch <JobName> [--payload] dispatch a background job from the command line with an optional json payload
dstrn logs:clear clear or archive log files with date filtering
dstrn deploy generate production deployment and service configurations
dstrn cert:obtain obtain let's encrypt ssl certificates
dstrn cert:renew renew expiring ssl certificates
dstrn cert:status display certificate validity and expiration details
dstrn docs:publish publish framework documentation to your project
dstrn ai:publish publish agentic documentation helpers

native

command description
dstrn simulate --<platform> run in a platform simulator
dstrn build --target <platform> build a production binary
dstrn make:plugin <Name> scaffold a cross platform native plugin
dstrn native:status display native config and readiness
dstrn native:doctor full environment diagnostic
dstrn native:clean [--<platform>] clean native build artifacts

architecture

command description
dstrn graph display the application dependency graph
dstrn lint detect architecture violations
dstrn dead find unreachable dead code
dstrn doctor compute a project quality score
dstrn lang:lint check translation parity and view keys

creating a project

the init command scaffolds a new project with the standard directory structure, a default configuration file, a sample route, and a basic view.

1dstrn init my-app

passing the --ai flag includes agentic documentation helpers in the generated project.

1dstrn init my-app --ai

running the server

the serve command starts the application server in the current directory.

1dstrn serve

this loads the application configuration, imports all route files, boots the socket server, starts the scheduler, and begins listening for http requests. the startup banner displays the application url and port.

tinker

the tinker command opens an interactive shell with the full application context loaded. all models are automatically imported and available as globals.

1dstrn tinker
1dframework> const users = await User.all();
2dframework> users.length
342
4dframework> await User.where('role', 'admin').get();

the shell persists command history to .tinker_history in your project root. all framework facades (DB, Config, Session, Auth, Log, etc.) are available in the context.

database advisor

the advisor command inspects your database schema and model definitions to detect missing indexes on foreign keys, junction tables, and frequently filtered column pairs.

1dstrn advisor
1 ADVISOR analyzing 12 tables...
2
3 WARN tracks: unindexed foreign key 'album_id'
4 CREATE INDEX idx_tracks_album_id ON tracks (album_id);
5
6 WARN track_artists: unindexed junction pair '(track_id, artist_id)'
7 CREATE INDEX idx_track_artists_track_id_artist_id ON track_artists (track_id, artist_id);

to automatically scaffold and execute a migration with all recommended indexes, pass the --apply flag:

1dstrn advisor --apply

this creates a timestamped migration file exporting up and down functions with table.index() and table.dropIndex() calls, then immediately runs dstrn migrate.

user commands

creating a command

scaffold a new command file using the make:command generator.

1dstrn make:command PruneExpiredSessions

this creates console/commands/PruneExpiredSessions.js. the generated file exports a class with a handle() method where you write the command logic. the command has access to all framework globals.

1export default class PruneExpiredSessions {
2 async handle() {
3 const cutoff = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
4 await DB.table('sessions').where('updated_at', '<', cutoff).delete();
5 Log.info('expired sessions pruned');
6 }
7}

running a command

execute any command from console/commands using the run command.

1dstrn run PruneExpiredSessions

dframework imports the command class, instantiates it, calls handle(), and reports the elapsed execution time on completion.

commands are also used by the scheduler. any command referenced in console/Schedule.js is resolved from the same console/commands directory.

logs management

the logs:clear command provides flexible log file management with date range filtering, environment targeting, archiving, and a preview mode.

1dstrn logs:clear
2dstrn logs:clear --env=prod
3dstrn logs:clear --before=2026-01-01
4dstrn logs:clear --after=2026-05-01 --archive
5dstrn logs:clear --preview
flag description
--env=prod or --env=dev target a specific environment log directory
--before=YYYY-MM-DD clear logs before the specified date
--after=YYYY-MM-DD clear logs after the specified date
--archive compress logs into a zip instead of deleting
--preview show which files would be affected without acting

deployment and certificates

deploying applications

the deploy command generates production configurations for bare metal deployment with native tls (default), reverse proxy with caddy (--proxy), or edge routing with cloudflare (--edge).

1dstrn deploy --domain=api.example.com --email=admin@example.com
2dstrn deploy --proxy --domain=api.example.com
3dstrn deploy --edge --domain=api.example.com
4dstrn deploy --domain=api.example.com --email=admin@example.com --dry-run
5sudo dstrn deploy --domain=api.example.com --email=admin@example.com --install
flag description
--domain=<domains> comma separated target domains
--email=<email> acme registration email for let's encrypt certificates
--proxy generate caddy reverse proxy configuration instead of direct tls
--edge generate plain http configuration with cloudflare guidance
--port=<port> custom application port (default 825 or 443 for direct tls)
--user=<user> system user for systemd service (default current user)
--dir=<dir> working directory path
--dry-run preview generated configurations in console without writing to disk
--install write configuration files directly to system paths (requires root privileges)

managing certificates

the cert command family handles certificate issuance, renewals, and status monitoring.

1dstrn cert:obtain --domain=api.example.com --email=admin@example.com
2dstrn cert:obtain --domain=api.example.com --email=admin@example.com --staging
3dstrn cert:renew --domain=api.example.com --email=admin@example.com
4dstrn cert:status
command description
dstrn cert:obtain --domain=... --email=... obtain a new let's encrypt ssl certificate
dstrn cert:renew --domain=... --email=... renew certificates expiring within 30 days
dstrn cert:status show validity and expiration dates for installed certificates

architecture analyzer

dframework includes a static analysis engine that builds a complete dependency graph of your application. it powers the graph, lint, dead, doctor, and lang:lint commands.

dependency graph

the graph command generates a visual representation of how your application is wired. it shows every http route and socket wire, the controllers they dispatch to, the middleware they pass through, and the models those controllers depend on.

1dstrn graph
1get /users (users.index)
2 └─ AuthMiddleware
3 └─ UserController (User)
4 └─ index()
5
6post /users (users.store)
7 └─ AuthMiddleware
8 └─ UserController (User)
9 └─ store()
10
11chat:message
12 └─ AuthMiddleware
13 └─ ChatController (Message)
14 └─ onMessage()

for machine readable output, pass the --json flag.

1dstrn graph --json

this outputs the full graph as a json object with nodes and edges arrays, suitable for external visualization tools.

architecture lint

the lint command detects structural violations in your application.

IMPORTANT

`dstrn lint` enforces strict architectural boundaries: controllers may not depend on other controllers, models may not depend on controllers, middleware may not depend on controllers, and routes may not depend directly on models.

1dstrn lint

if violations are found, each one is printed with a description.

1 ERROR controller UserController depends on controller AdminController
2 controllers may not depend on controllers

dead code detection

the dead command performs reachability analysis starting from all registered routes and socket wires. it traverses the dependency graph and reports any controllers, models, or middleware that are never referenced by any route.

1dstrn dead
1 ERROR found 2 unreachable components
2
3unused controller
4 LegacyController
5
6unused model
7 TempModel

database tables are excluded from the analysis since they may be accessed through raw queries.

project doctor

the doctor command computes a quality score from 0 to 100 based on three factors:

1dstrn doctor
1 OK health score 95 out of 100
2
3deductions
4 dead code minus 5 (1 unreachable components)

scores of 90 and above are displayed as success, 70-89 as informational, and below 70 as an error.

translation lint

the lang:lint command verifies translation keys across all configured languages and validates references throughout your views and code. it checks for two categories of issues:

1dstrn lang:lint

if issues are found, the command reports the exact files, line numbers, and missing locales:

1 ERROR found 2 translation issues
2
3missing translations in views and code
4 views/index.d:4
5 key 'ui.tagline' is missing in [ja]
6
7asymmetric translation keys across locales
8 locale: ja
9 missing 'ui.tagline' (defined in: en)

if all translations are complete and match view usage, a success status is returned.

the compiler

dframework includes a build time compiler that bundles and minifies the frontend runtime assets.

javascript compilation

the js compiler concatenates the framework's core client side files (the main runtime, native bridge, custom elements, and utility functions), along with any user defined component files found in public/js/components. the combined output is minified with three compression passes, function name mangling, and toplevel mangling. the result is written to public/js/dstrn.js.

in the local environment with debug mode enabled, the __DF_DEBUG__ global is set to true, enabling debug only code paths in the client runtime. in production, these paths are eliminated during dead code elimination.

css compilation

the css compiler concatenates the framework's base styles, utility classes, icon font, and component styles. it then generates responsive variants for each utility class across six breakpoints (sm, md, lg, xl, xxl, ultra) using the prefix\:classname pattern. user defined component css files from public/css/components are included in the output.

the final output is minified by stripping comments, collapsing whitespace, removing unnecessary semicolons, and eliminating zero unit suffixes. the result is written to public/css/dstrn.css.