# Deploy Your First Project

This guide walks you through getting your application running on Genie, from code to live environment.

***

## Getting Your Code on the Server

You can bring your code into Genie in several ways:

**Clone from Git** — Use `git clone` in your terminal to pull a repository directly onto your server.

**Upload files** — Use the file manager to upload a zip archive or individual files from your local machine.

**Create from scratch** — Start a new project directly in your Genie workspace using the terminal or file editor.

***

## Install Dependencies

Once your code is on the server, install the required dependencies using the appropriate package manager:

```bash
npm install          # Node.js
pip install -r requirements.txt  # Python
bundle install       # Ruby
go mod download      # Go
```

Your server is a full Linux environment, so any package manager or tool chain works as expected.

***

## Configure Environment Variables

Store sensitive configuration like API keys and database URLs in Genie Secrets.

Once added, they are automatically available as environment variables in your terminal and applications. This keeps credentials out of your codebase.

***

## Run Your Application

Start your application using the standard command for your framework:

```bash
node server.js       # Node.js
python3 app.py       # Python
rails server         # Ruby
go run main.go       # Go
```

Your application runs on your Genie server and is accessible based on your configuration.

***

## Keep It Running

For persistent applications, use a process manager to ensure your app stays running and restarts automatically:

**pm2** — Ideal for Node.js applications. Handles process management, logging, and auto-restart.

**systemd** — The standard Linux service manager. Works with any application and starts automatically on boot.

**screen or tmux** — Quick options for keeping processes running in detached terminal sessions.

***

## Set Up a Database

You can install and run databases directly on your server:

```bash
sudo apt install postgresql    # PostgreSQL
sudo apt install redis-server  # Redis
```

Alternatively, use external managed database services and connect to them through environment variables stored in Secrets.

***

## Expose Your Application

To make your application accessible externally, configure a reverse proxy using nginx:

```bash
sudo apt install nginx
```

Set up nginx to route incoming requests to your application's local port. Genie handles SSL certificates automatically.

***

## Continuous Deployment

For automated deployments, you can set up CI/CD pipelines that connect to your Genie server via SSH or webhooks.

When code is pushed to your repository, the pipeline can pull the latest changes, install dependencies, and restart your application automatically.

***

## Best Practices

* Use environment variables for all configuration
* Set up a process manager from the start
* Enable automatic backups before deploying
* Use Git for version control alongside Genie backups
* Test locally in your Genie terminal before exposing externally
