> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fjall.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Application

> Scaffold a new Fjall application on AWS from a tier preset (tinkerer to enterprise) or a custom stack.

## Prerequisites

Complete these first:

* [Install the Fjall CLI](/deployment/cli-installation)
* [Connect an AWS account](/cli/connect) with `fjall connect`
* [Deploy your organisation](/deployment/deploy-organisation) (optional, for multi-account setups)

## Overview

A Fjall application is an infrastructure stack with compute, storage, and networking resources. Pick a tier preset or build a custom stack.

```bash theme={null}
fjall create app
```

This starts the interactive creator. To skip the prompts, pass options directly (see [Non-interactive mode](#non-interactive-mode)).

### Application tiers

The first prompt, "Choose your starting point?", lists six tiers in this order. Resilient and Enterprise require a Pro or Enterprise plan.

| Tier        | Compute                | Database                          | Networking                          | Best for                                  |
| ----------- | ---------------------- | --------------------------------- | ----------------------------------- | ----------------------------------------- |
| Standard    | Fargate                | RDS Instance (t4g.large)          | 3 AZ, 1 NAT Gateway                 | General production workloads              |
| Lightweight | Fargate Spot           | RDS Instance (t4g.small)          | 2 AZ, 1 NAT Gateway                 | Low-traffic applications                  |
| Resilient   | Fargate                | Aurora with readers, KMS, proxy   | 3 AZ, 3 NAT Gateways                | High-availability workloads               |
| Enterprise  | Fargate                | Aurora with 2 readers, KMS, proxy | 3 AZ, 3 NAT Gateways, VPC endpoints | Regulated, compliance-sensitive workloads |
| Tinkerer    | ECS on EC2 (t4g.micro) | RDS Instance (t4g.micro)          | 2 AZ, no NAT Gateway                | Learning and experimentation (free-tier)  |
| Custom      | Interactive selection  | Interactive selection             | Interactive selection               | Specific requirements                     |

Resilient keeps 30-day backup retention. Enterprise adds S3 flow logs (365 days) and 35-day backup retention.

## Interactive flow

After you pick a tier, the creator prompts for the rest. A tiered application asks:

1. **Name your application** (for example, `api`).
2. **Use suggested container?** (only when a monorepo container directory is inferred, or skipped if you passed `--container`).
3. **Include database?**
4. **Restore from an RDS snapshot?** (only when a database is included). If yes, it asks for the snapshot identifier and master username.
5. **Service setup**, looping per service: count, name, type, Dockerfile path, port (unless read from the Dockerfile), and whether the service needs a database connection.
6. **Review**, then select the deployment account.

```bash theme={null}
fjall create app

? Choose your starting point?
  ❯ Standard    Production-ready · 3 AZ, Fargate, RDS Instance
    Lightweight Streamlined · 2 AZ, Fargate Spot, RDS Instance
    Resilient   High-availability · 3 AZ, Aurora, KMS, Proxy
    Enterprise  Maximum capability · 3 AZ, Aurora, KMS, VPC endpoints
    Tinkerer    Free experimental · 2 AZ, ECS on EC2, RDS Instance
    Custom      Blank canvas · Build your way

? Name your application? api
? Include database? Yes
? Provide Dockerfile for "api"? No

Creating standard application: api

✔ Creating application structure
✔ Application structure created at ./fjall/api
✔ Installing dependencies
✔ Dependencies installed successfully

────────────────────────────────────────────────

Success! Your api application has been created.

Next Steps:
Deploy your application: fjall deploy api
Learn more: https://docs.fjall.io/deployment/deploy-application
```

## What gets created

Your application structure:

```
fjall/
└── api/
    ├── infrastructure.ts   # CDK infrastructure code
    ├── package.json       # Dependencies and scripts
    ├── cdk.json          # CDK configuration
    ├── cdk.context.json  # CDK context values
    └── tsconfig.json     # TypeScript configuration
```

### Infrastructure code

The generated `infrastructure.ts` for a standard application includes:

```typescript theme={null}
#!/usr/bin/env node

import {
  App,
  DatabaseFactory,
  ComputeFactory,
  getConfig,
} from "@fjall/components-infrastructure";

const appName = "api";
const app = App.getApp(appName);

app.addTags({
  "fjall:costAllocation:owner": "engineering",
});

const apiStorage = app.addDatabase(
  DatabaseFactory.build("ApiStorage", {
    type: "Instance",
    databaseName: "ApiDatabase",
  }),
);

app.addCompute(
  ComputeFactory.build("ApiCompute", {
    type: "ecs",
    ecrRepository: app.getDefaultContainerRegistry(),
    services: [
      {
        name: "api",
        capacityProvider: "FARGATE",
        containers: [
          {
            port: 3000,
            environment: {
              ENVIRONMENT: getConfig().environment,
              DATABASE_HOST: apiStorage.getHostEndpoint(),
              DATABASE_PORT: `${apiStorage.getHostPort()}`,
              DATABASE_NAME: apiStorage.getDatabaseName(),
            },
            secretsImport: {
              DATABASE_PASSWORD: apiStorage
                .getCredentials()
                .getImport("password"),
            },
          },
        ],
      },
    ],
    connections: [apiStorage],
  }),
);
```

## Non-interactive mode

Pass options directly to skip the prompts. `-n, --name` is required. Every other option has an interactive prompt or a default.

```bash theme={null}
fjall create app \
  -n api \
  -t standard \
  --database
```

### Available options

| Option                  | Description                                                                       | Example                             |
| ----------------------- | --------------------------------------------------------------------------------- | ----------------------------------- |
| `-n, --name`            | Application name (required, 2 to 50 characters)                                   | `-n api`                            |
| `-t, --type`            | Application tier (tinkerer, lightweight, standard, resilient, enterprise, custom) | `-t standard`                       |
| `--pattern`             | Application pattern (`payload` or `staticsite`). See the note below on `nextjs`.  | `--pattern payload`                 |
| `--tier`                | Infrastructure tier for a pattern app (`--pattern-tier` is an alias)              | `--tier standard`                   |
| `--pattern-domain`      | Custom domain for the pattern                                                     | `--pattern-domain example.com`      |
| `--database`            | Include a database                                                                | `--database`                        |
| `--dockerfile`          | Dockerfile path                                                                   | `--dockerfile ./app/Dockerfile`     |
| `--container-port`      | Container port                                                                    | `--container-port 8080`             |
| `--services`            | Service configuration as JSON                                                     | `--services '[{"name":"api"}]'`     |
| `--owner`               | Owner identifier                                                                  | `--owner engineering`               |
| `--network`             | Network preset (none, tinkerer, lightweight, standard, resilient, enterprise)     | `--network standard`                |
| `--snapshot-identifier` | RDS snapshot ID for restoring from a snapshot                                     | `--snapshot-identifier my-snapshot` |
| `--snapshot-username`   | Snapshot master username                                                          | `--snapshot-username admin`         |

<Warning>
  The `nextjs` pattern is not yet deployable. Recent CLI versions no longer offer it in the picker and refuse `--pattern nextjs` at create time; older versions accepted it and failed at deploy. Use `payload` for a Next.js-based app, or [`staticsite`](/patterns/static-site-pattern) for a pre-built static site — its flags (`--source`, `--build-command`, `--output-dir`, `--routing`, `--forms-to`) are covered on the pattern page.
</Warning>

<Note>
  You can create an application on its own or as part of an organisation. For multi-account setups, [deploy the organisation](/deployment/deploy-organisation) first.
</Note>

## Next Steps

<CardGroup cols={2}>
  <Card title="Deploy Application" icon="rocket" href="/deployment/deploy-application">
    Deploy your application to AWS.
  </Card>

  <Card title="Add Resources" icon="plus" href="/deployment/add-resources">
    Extend with databases, storage, and more.
  </Card>

  <Card title="Connect AWS" icon="aws" href="/cli/connect">
    Connect the AWS account your application deploys into.
  </Card>

  <Card title="Deploy Organisation" icon="sitemap" href="/deployment/deploy-organisation">
    Set up multi-account management with Fjall.
  </Card>
</CardGroup>
