# Connect resources to an app

> Combine managed PostgreSQL, AI inference, and private file storage in a single application.

Source: https://docs.stacksync.com/enterprise-os/applications/connect-resources

EOS resources work together through your application's server-side configuration. A partner portal can store its records in PostgreSQL, send model requests with an inference key, and upload documents to a storage bucket.

Create resources in the intended workspace, then configure your app with the credentials for those resources. A dashboard sharing grant lets a teammate manage a resource; your running application connects using its database credentials or scoped API key.

| Resource            | What the app receives                                | How it connects                             |
| ------------------- | ---------------------------------------------------- | ------------------------------------------- |
| PostgreSQL database | Dedicated connection string or connection parameters | Standard PostgreSQL driver or ORM.          |
| AI inference        | Inference API key and selected model ID              | EOS chat-completions API or compatible SDK. |
| Storage bucket      | Bucket API key with required scopes                  | EOS storage API or CLI file commands.       |

## 1. Provision the resources

Use the dashboard's **Create database**, **Create API key**, and **Create bucket** actions, or the CLI:

```sh
eos workspace current
eos database create 'Partner portal production' --json
eos inference keys create 'Partner portal AI' --limit 25 --every 1 --unit months --json
eos storage buckets create 'partner-portal-files' --region EU --json
```

Database and key creation can return credentials. Capture those responses privately rather than in shared logs. Give each app its own credentials so you can manage its access and spending independently.

For storage, create a key for the returned bucket ID:

```sh
eos storage keys create BUCKET_ID 'Portal backend' --scopes read,write,list
```

Add `delete` only if the application needs to remove files. AI and storage key values are shown once at creation; sharing the resource later does not reveal the original key.

## 2. Make the application read its configuration

Choose clear variable names, for example:

```text
DATABASE_URL
STACKSYNC_AI_KEY
STACKSYNC_AI_MODEL
STORAGE_API_KEY
```

Use project-specific names when several projects share your development environment. Read the values in the backend; never place secret values in public frontend environment variables.

A Node.js application might read `process.env.DATABASE_URL` when initializing its PostgreSQL client. Its AI client uses `STACKSYNC_AI_KEY` and the EOS inference base URL. Its storage client sends `STORAGE_API_KEY` as a bearer credential to the storage API.

## 3. Supply the variables when deploying

With values already loaded securely in your shell environment:

```sh
eos deploy --dry-run --project=partner-portal   "--variable=DATABASE_URL=$DATABASE_URL"   "--variable=STACKSYNC_AI_KEY=$STACKSYNC_AI_KEY"   "--variable=STACKSYNC_AI_MODEL=$STACKSYNC_AI_MODEL"   "--variable=STORAGE_API_KEY=$STORAGE_API_KEY"
```

After reviewing the dry run, run the same command without `--dry-run`. A dry run does not persist configuration. Keep shell tracing off when passing secrets. You can also edit the variable JSON in the app's **Deployments** tab and deploy a new version.

## 4. Verify the complete workflow

Open the app and exercise a representative action: create a record, make an AI request, and upload a file. Check the database table, inference request log, and bucket file list in EOS. Then review the app's [managed authentication](/enterprise-os/applications/managed-authentication) and share it with its intended users.

See [database connections](/enterprise-os/databases/connect-and-query), [AI integration](/enterprise-os/ai-inference/connect), and [storage API keys](/enterprise-os/storage/api-access) for resource-specific instructions.