<!-- llms-txt: https://hydron.app/llms.txt -->
<!-- llms-full-txt: https://hydron.app/llms-full.txt -->
<!-- canonical: https://hydron.app/docs/services -->

# Services

A Service in Hydron represents a single deployable component of your application. Most projects have one or more services — for example, a web application might have an API service, a frontend service, and a database service.

## How services are created

Services are created in two ways:

1. **Automatically detected** — When you connect a Git repository, the AI analyzes your code and detects services based on the project structure, entry points, and configuration files
2. **Manually added** — You can add services through the chat or project settings

## Service properties

Each service has the following properties:

| Property | Description |
|----------|-------------|
| **Name** | A unique identifier within the project (e.g., `api-server`, `frontend`) |
| **Type** | The kind of service (web server, worker, database, cache, etc.) |
| **Source** | Where the code comes from (Git repository, Docker image) |
| **Dockerfile** | The Docker configuration for building and running the service |
| **Environment variables** | Configuration values injected at runtime |
| **Ports** | Network ports the service exposes |
| **Health check** | Endpoint and settings for monitoring service health |
| **Dependencies** | Other services this one depends on |

## Viewing services

Services are displayed in the **right sidebar** of the chat interface under the **Services** tab.

![The Services panel showing detected services with their configurations](/images/docs/sidebar-services.png)

## Accepting and rejecting services

After code analysis, detected services are in a **pending** state. You need to review and either **accept** or **reject** each one:

- **Accept** — Include this service in the infrastructure plan and deployment
- **Reject** — Exclude this service from deployment

Only accepted services are included when generating infrastructure plans.

## Environment variables

Each service can have its own set of environment variables. These are injected into the Docker container at runtime.

### Adding environment variables

You can add environment variables in several ways:

- **Automatically detected** — The AI extracts variables referenced in your code during analysis
- **Through the chat** — Tell the AI: "Set DATABASE_URL to postgres://..."
- **Through the sidebar** — Click on a service and add variables in the configuration panel

### Variable enrichment

Hydron can automatically enrich environment variables by detecting common patterns:

- Database connection strings
- API keys and secrets
- Port configurations
- Service discovery URLs (connecting your services to each other)

### Shared secrets

When multiple services need the same environment variable (e.g., a shared database URL), Hydron can automatically configure cross-service references so you only define the value once.

## Dockerfiles

Every service needs a Dockerfile to define how it's built and run. Hydron handles this in three ways:

1. **Existing Dockerfile** — If your repository already has a Dockerfile, Hydron uses it
2. **AI-generated** — The AI creates an optimized Dockerfile based on the detected framework
3. **Custom** — You can provide or edit a Dockerfile through the chat

### Editing Dockerfiles

Ask the AI to modify the Dockerfile for any service:

- "Use a multi-stage build for the frontend service"
- "Change the Node.js version to 20-alpine"
- "Add a health check command to the API Dockerfile"

## Service dependencies

Services can depend on other services. For example:

~~~
api-server ──depends on──> postgres
api-server ──depends on──> redis
frontend   ──depends on──> api-server
~~~

Dependencies affect:

- **Startup order** — Dependent services start after their dependencies
- **Networking** — Dependent services can reach their dependencies via internal DNS
- **Health checks** — A service isn't considered healthy until its dependencies are healthy

## Locking services

You can **lock** a service to prevent accidental changes. A locked service:

- Cannot have its Dockerfile modified
- Cannot have environment variables changed
- Cannot be removed from the project

This is useful once you've finalized a service's configuration and don't want it accidentally modified during further iterations.
