# Create New Project

Is it under a new domain?

- If **yes** →
  First [Create_New_Domain](Create_New_Domain.md),
  before continuing here

Variables to fill in by human:

- {Projectname} = e.g. moramontage
- {Production-Domain} = e.g. moramontage.de
- {Preview-Domain} = e.g. preview.moramontage.de
- {Assets-Domain} = e.g. assets.moramontage.de
- {Port} = e.g. 3030
  Must be a new number that doesn't exist yet, see [Projects](Projects.md)

## 1. Project Creation: Manual Steps

### 1.1 Notion Project

Add a new entry at [Projects](Projects.md)

- Name, domain, url, preview url, etc

### 1.2 DNS

- Go to Cloudflare DNS Records settings, e.g. [https://dash.cloudflare.com//moramontage.de/dns/records](https://dash.cloudflare.com//moramontage.de/dns/records)
- Add DNS entry:
  - Record Type: A
  - Name: {the first part of a Preview-Domain, e.g. preview}
  - IPv4 address: 89.58.26.144
  - Proxy status: Turn off (DNS only)
  - TTL: Auto
  - Comment (Record Attributes): "opencode.leonardomora.de preview server"
  - Click blue "Save" button

### 1.3 Create Github Repo

- [https://github.com/orgs/Contentoren/repositories](https://github.com/orgs/Contentoren/repositories)
- Click "New Repository" green button
- Important: Make sure "Contentoren" is selected in the Owner dropdown
- Repository name: Enter project name
- Click "Create Repository" green button

## 2. KI Instructions for New Projects

Variables to fill in by human:

- {Projectname} = ***(Replace and fill in)***
- {Domain} = ***(Replace and fill in)***
- {Port} = ***(Replace and fill in)***

### 2.1 Set Up Caddy

In /home/leo/.caddy
Update the Caddyfile to add the new project
{Preview-Domain} should point to {Port}
Run `caddy validate -c /home/leo/.caddy/Caddyfile`
Run caddy validate and restart caddy systemd service as user

Validate with curl that the new domain and page of the vite dev/preview server is reachable under the new domain

### 2.2 Create Folders and Git Repo

in
/home/leo/projects
or
/home/leo/projects_customer


```bash
git init --initial-branch=main

git remote add origin git@github.com:Contentoren/{Projektname}
git branch -M main
git push -u origin main
```

### 2.3 Create Web Project

Create a website project (package.json, vite, git ignore, tsconfig, systemd service) in {Projectname}, use as reference {e.g. betaconsulting, allgroups-site or moramontage}.

Port should be {Port}, and for vite allowed hosts: {Preview-Domain}

Make sure that:

- tsgo compiles successfully
- systemd service runs as user
- vite build builds the project successfully

### 2.4 Assets / Images and Videos

See:

[Install Image/Video/Font Management](../Prompts/Technical/Image_Video_Font_Management.md)

## 3. Production Deployment

### 3.1 Automatically Build Project on Git Changes

Visit CF Workers & Pages:

[https://dash.cloudflare.com//workers-and-pages/create](https://dash.cloudflare.com//workers-and-pages/create)

- Click "Create Application" blue button
- "Continue with Github"
- "Select a repository" → Select project name → Click "Next"
- Enter:

Project name: {Projectname}

Build command: `bun build`

Deploy command: `bunx wrangler deploy`

Build for non-production branches → empty, uncheck
Env variables:
NODE_ENV = production

Click blue "Deploy" button

### 3.2 Set Custom Domain

- CF → Compute → Workers & Pages → Select project → Settings
e.g. [https://dash.cloudflare.com//workers/services/view/moramontage/production/settings](https://dash.cloudflare.com//workers/services/view/moramontage/production/settings)
- On the Settings page:
  - For Custom domain → Click pencil icon
  - Enter desired Production domain, e.g. `moramontage.de`
  - Click blue "Update Domain" button
