Skip to content

Apps ​

The photodrop Project from Quickstart has one App named app. The App owns the binary that serves GET /api/v1/users/42 from Your First Route, along with its commands and the dependencies those commands use.

What the App Owns ​

Keep feature code under internal/ and choose what the App exposes under app/. Most Projects can start with one App and add packages as they grow.

LocationWhat It Owns
internal/users/The user controller, service, and tests
app/Routes, commands, schedules, and lifecycle hooks for the default App
app/wire/Providers and the code that constructs the App
cmd/app/main.goThe binary entrypoint

Enabled components determine which files exist. Edit App-owned files such as app/routes.go and app/wire/inject_services_app.go. GoForj preserves them when it renders the Project again. Files marked DO NOT EDIT, such as app/wire/wire_gen.go, are regenerated from their inputs.

Build the App ​

Run forj build from the Project root to refresh component code, run Wire and API indexing, and compile bin/app. In Local Development, forj dev runs that build as needed.

  • Render after changing the selected components or starter kit in .goforj.yml, then build. See the SQLite setup for an example.
  • Build after changing Go source, provider sets, supported drivers, or named resources. These changes can affect constructor calls, generated accessors, or API artifacts.
  • Restart after changing startup settings such as a port or the active driver when the binary already supports it.

See Generation Commands for individual generators and Configuration for setting ownership. If a generated file needs to change for every Project, update its framework template or generator and verify the rendered output.

When to Add Another App ​

Add an App when part of the Project needs its own binary, routes, or dependency graph. A staff API can share feature packages with the default App while controlling its own access and deployment.

bash
forj make:app admin --components web-api

The command creates cmd/admin/, app/admin/, and app/admin/wire/ in the same Go module and records the selected components in .goforj.yml. Running forj admin make:controller reports puts its code in internal/reports and connects its provider and routes to admin. See the make:app reference for flags and development enrollment.

Select an App ​

An unprefixed App command selects app. After adding an HTTP-enabled admin App, list the registered routes for each.

bash
forj route:list
forj admin route:list

The first table shows the users route from Your First Route if you added it. The second shows the routes registered in admin. Each App builds to its own binary, bin/app or bin/admin.

GoForj discovers additional Apps through entrypoints such as cmd/admin/main.go and their composition files. The App metadata in .goforj.yml records component and starter kit choices. dev.apps selects which Apps run under forj dev. The default App comes first, followed by additional Apps alphabetically. Their default listener ports follow that order.

Runtime and Resource Boundaries ​

One App can run HTTP, workers, and schedules together or in separate processes. A runtime-capable binary launched without arguments starts its combined run command. A CLI-only binary shows help. See Run the App for process choices and shared backends.

If multiple Apps use one physical database, give one App ownership of the migration stream. See Resources for logical resource names and how additional Apps scope them.

Continue with Dependency Injection to follow the constructor calls behind the users route.