Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cc258f8
update .gitignore to exclude /infra/charts
juanArias8 Mar 5, 2026
bf9c2a3
add CLAUDE.md with project guidelines and development instructions
juanArias8 Mar 5, 2026
11ddc19
update Dockerfiles to use node:20-slim and simplify dependencies inst…
juanArias8 Mar 5, 2026
95d5270
update dependencies: bump torch to >=2.0.0, diffusers to >=0.28.0, an…
juanArias8 Mar 5, 2026
c4f7171
feat(s3): implement presigned URLs for S3 file access
juanArias8 Mar 5, 2026
6cc005b
feat(artwork-card): move click handler to container div
juanArias8 Mar 5, 2026
3105483
feat(artwork-form): normalize title from prompt if artwork title is m…
juanArias8 Mar 5, 2026
2bbda20
feat(imagine-menu): refactor feature rendering and improve UI handling
juanArias8 Mar 5, 2026
83c56a5
feat(imagine-base): improve component structure and UI updates
juanArias8 Mar 5, 2026
3ae4cbc
refactor(styles): migrate SCSS/SASS to Tailwind CSS in morpheus-clien…
juanArias8 Mar 5, 2026
1876ff0
refactor: remove morpheus-data shared library, inline code into morph…
juanArias8 Mar 5, 2026
f070fa0
perf(worker): cache settings, switch to DPM++ scheduler, parallelize …
juanArias8 Mar 5, 2026
63a59ea
perf(worker): reuse named Ray actors to eliminate per-request model r…
juanArias8 Mar 5, 2026
1dbf635
perf(worker): add per-actor warmup pass to pre-compile CUDA kernels a…
juanArias8 Mar 5, 2026
946b9e1
fix(worker): start Ray Serve directly in start.sh, remove broken depl…
juanArias8 Mar 5, 2026
2636305
refactor(worker): remove deprecated legacy worker components
juanArias8 Mar 5, 2026
2d47886
chore(gitignore): add blank line for formatting consistency
juanArias8 Mar 5, 2026
1d3981a
feat(styles): add Excalidraw component styles for Excalidraw integration
juanArias8 Mar 5, 2026
4a0cfad
chore(gitignore): update ignore patterns for secret-related files
juanArias8 Mar 5, 2026
6674ebd
refactor(client): replace vendored Excalidraw with @excalidraw/excali…
juanArias8 Mar 12, 2026
dc8c72b
feat(worker): add Firebase integration for file storage
juanArias8 Mar 12, 2026
7db1f79
fix(worker): pin accelerate and update dependencies
juanArias8 Mar 12, 2026
a637fa5
chore(worker): add .dockerignore file
juanArias8 Mar 12, 2026
dacd060
refactor(worker): improve logging by excluding sensitive fields from …
juanArias8 Mar 12, 2026
ac4f1a4
feat(worker): add GPU timeout and implement actor eviction
juanArias8 Mar 12, 2026
622428d
fix(utils): handle missing blob errors in getFileBlobFromURL
juanArias8 Mar 12, 2026
21f3c20
chore(deps): update yarn.lock to remove unused dependencies
juanArias8 Mar 12, 2026
a361658
docs(readme): add local service URLs section
juanArias8 Mar 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@

.idea
.DS_store
secrets.env
*-secrets.yaml
*secrets*.yaml
*.module.css*
etc/cloudflare/**/*.yml
etc/cloudflare/**/*.json
*.pyc
node_modules
.vscode/settings.json
/infra/charts/**
171 changes: 171 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

Morpheus is an open-source web platform for AI image generation using Stable Diffusion. It is a multi-service monorepo where each service is independently containerized and orchestrated via Docker Compose locally, and deployed to AWS EKS in production.

## Services and Architecture

```
morpheus-client (Next.js, port 3000)
morpheus-admin (Next.js, port 3001)
morpheus-collaborative (Node.js/Socket.io, port 3002)
|
morpheus-server (FastAPI, port 8001)
| | |
PostgreSQL (5432) AWS S3 morpheus-worker (Ray, ports 8000/8265)
|
Firebase (Auth/Collab)
```

- **morpheus-server** is the FastAPI backend. It owns all SQLAlchemy models, Pydantic schemas, Alembic migrations, and S3/Firebase repository implementations.
- **morpheus-worker** runs a Ray cluster for GPU-accelerated Stable Diffusion inference.
- The client uses Firebase for authentication and Socket.io for real-time collaboration.

## Development Commands

### Starting the environment

```bash
# Copy secrets templates and fill in values
cp morpheus-server/secrets.env.dist morpheus-server/secrets.env
cp morpheus-client/env.local.dist morpheus-client/.env.local
cp morpheus-client/env.local.dist morpheus-admin/.env.local

# Apply DB migrations (required before first start)
docker compose run --rm api alembic upgrade head

# Start all services
docker compose up

# Start specific services
docker compose up api client admin
```

### Backend (morpheus-server)

```bash
# Run all tests
docker compose run --rm api pytest

# Run a single test file
docker compose run --rm api pytest tests/test_module.py

# Run a single test
docker compose run --rm api pytest tests/test_module.py::test_function

# Lint
docker compose run --rm api flake8 --max-line-length 120 --exclude app/migrations/ .

# Format
docker compose run --rm api black --line-length 120 --exclude app/migrations/ .
```

### Database migrations

```bash
# Auto-generate a migration from model changes
docker compose run --rm api alembic revision --autogenerate -m "Description"

# Apply pending migrations
docker compose run --rm api alembic upgrade head
```

### Frontend (morpheus-client / morpheus-admin)

```bash
# Lint
docker compose exec client yarn lint
docker compose exec admin yarn lint

# Direct yarn usage (outside Docker)
cd morpheus-client && yarn dev # port 3000
cd morpheus-admin && yarn dev # port 3001
```

### Collaborative server

```bash
docker compose exec collaborative yarn test:code # ESLint
docker compose exec collaborative yarn fix # Prettier + ESLint fix
```

### Building Docker images

```bash
docker compose build api
docker compose build client admin collaborative

# Build all
docker compose build
```

### Model management CLI

```bash
docker compose --profile manage build # build the model-script service
docker compose run --rm model-script --help
docker compose run --rm model-script s3 list
docker compose run --rm model-script db register <server> <target>
```

## Code Architecture Details

### morpheus-server structure

```
app/
api/ # FastAPI route handlers (thin layer, delegates to services)
services/ # Business logic
models/ # SQLAlchemy ORM models and Pydantic schemas
repository/ # Database and S3 repository classes
registry/ # Model registry (HuggingFace, S3)
database/ # DB engine, session, init data
integrations/ # Third-party integrations
utils/ # Image helpers, timer, decorators
config.py # Pydantic Settings (reads from secrets.env)
app.py # FastAPI app setup, router registration
migrations/ # Alembic migrations
main.py # Uvicorn entry point
```

### Key configuration

| File | Purpose |
|------|---------|
| `morpheus-server/secrets.env` | Backend secrets (DB, Firebase, AWS, Ray URL) |
| `morpheus-client/.env.local` | Frontend env (API URL, Firebase config, WS URL) |
| `morpheus-server/app/config.py` | Pydantic Settings class |
| `morpheus-worker/models.yaml` | Ray Serve deployment configuration |
| `docker-compose.yaml` | Service orchestration for local dev |

### Python code standards

- Black formatter with `--line-length 120`
- Flake8 with `--max-line-length 120 --exclude app/migrations/`
- Alembic migrations live in `morpheus-server/migrations/`

### TypeScript/JavaScript code standards

- ESLint for both frontend apps and collaborative server
- Prettier for collaborative server (`yarn fix`)

## Commit conventions

Follow Conventional Commits:
- `feat:` new feature
- `fix:` bug fix
- `chore:` tooling/deps
- `docs:` documentation
- `refactor:` restructuring
- `test:` tests
- `perf:` performance

## Infrastructure

- Production runs on AWS EKS (Kubernetes), provisioned with Terraform in `infra/`
- Helm charts are in `infra/charts/`
- CI/CD is via GitHub Actions (`.github/workflows/`); `monorepo/cicd.py` detects which services changed to run targeted pipelines
- Monitoring: Sentry (errors), Ray Dashboard (port 8265), Prometheus/Grafana (production)
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,18 @@ The Morpheus project will be running on your local machine at localhost:3000 (cl
localhost:8001 (api). Morpheus uses some Stable Diffusion models by default, if you want to change the setup you
can do it from the administration panel.

## Local Service URLs

Once running, the services are available at:

| Service | URL |
|---|---|
| Frontend (morpheus-client) | http://localhost:3000 |
| Admin panel (morpheus-admin) | http://localhost:3001 |
| Backend API (morpheus-server) | http://localhost:8001 |
| Worker panel (Ray Dashboard) | http://localhost:8265 |
| PGAdmin | http://localhost:8002 |

# Development

## Running the backend tests
Expand Down
41 changes: 5 additions & 36 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.8"
services:
postgres:
image: postgres:15-alpine
Expand Down Expand Up @@ -30,8 +29,6 @@ services:
build:
context: morpheus-server
dockerfile: ./Dockerfile
args:
- TAG=${TAG:-latest}
image: morpheus-server:latest
env_file:
- morpheus-server/secrets.env
Expand All @@ -47,22 +44,6 @@ services:
depends_on:
postgres:
condition: service_healthy
datalib:
condition: service_completed_successfully

datalib:
build:
context: morpheus-data
dockerfile: ./Dockerfile
args:
DOCKER_BUILDKIT: 1
image: monadicalsas/morpheus-data:${TAG:-latest}
volumes:
- ./wheels:/wheels
- ./morpheus-data:/app
depends_on:
postgres:
condition: service_healthy

client:
build:
Expand Down Expand Up @@ -124,10 +105,11 @@ services:
api:
condition: service_started
healthcheck:
test: [ "CMD-SHELL", "ray status" ]
interval: 5s
timeout: 5s
retries: 10
test: [ "CMD-SHELL", "curl -sf http://localhost:8000/ > /dev/null" ]
interval: 15s
timeout: 10s
retries: 20
start_period: 60s
# If you don't have a gpu, comment the deploy section below
deploy:
resources:
Expand All @@ -136,14 +118,6 @@ services:
- count: 1
capabilities: [ gpu ]

worker-ray-deployer:
image: morpheus-worker:latest
command: bash -c "sleep 10 && ray job submit -- serve deploy models.yaml"
environment:
- RAY_ADDRESS=http://worker-ray:8265
depends_on:
worker-ray:
condition: service_healthy

cloudflare-api:
image: cloudflare/cloudflared
Expand Down Expand Up @@ -171,8 +145,6 @@ services:
build:
context: morpheus-server
dockerfile: ./scripts/models/Dockerfile
args:
- TAG=${TAG:-latest}
image: morpheus-script-model:latest
profiles: [ "manage" ]
env_file:
Expand All @@ -181,9 +153,6 @@ services:
- ./morpheus-server:/opt/api
stdin_open: true
tty: true
depends_on:
datalib:
condition: service_completed_successfully

volumes:
pg_data:
Expand Down
16 changes: 3 additions & 13 deletions morpheus-admin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
ARG BUILD_ENV="copy"
FROM debian:latest as base
ARG BUILD_ENV="no_copy"
FROM node:20-slim as base

ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
ENV NODE_MAJOR=18

ENV CLIENT_ROOT "/app"

# Install system requirements
RUN apt-get update && apt-get install -y \
curl ca-certificates curl gnupg && \
rm -rf /var/lib/apt/lists/*

RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update && apt-get install nodejs -y

RUN npm install --global npm yarn next sass
RUN npm install --global next sass

WORKDIR ${CLIENT_ROOT}

Expand Down
10 changes: 0 additions & 10 deletions morpheus-admin/components/atoms/Brand/Brand.module.scss

This file was deleted.

3 changes: 1 addition & 2 deletions morpheus-admin/components/atoms/Brand/Brand.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { CSSProperties } from "react";
import styles from "./Brand.module.scss";

interface BrandProps {
onClick?: () => void;
Expand All @@ -10,7 +9,7 @@ const Brand = (props: BrandProps) => {
return (
<h2
onClick={props.onClick}
className={`headline-1 ${styles.morpheusTitle}`}
className="morpheus-title"
style={props.styles}
>
Morpheus Admin
Expand Down
19 changes: 0 additions & 19 deletions morpheus-admin/components/atoms/Separator/Separator.module.scss

This file was deleted.

9 changes: 4 additions & 5 deletions morpheus-admin/components/atoms/Separator/Separator.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from "react";
import styles from "./Separator.module.scss";

export const Separator = () => {
return (
<div className={styles.separator}>
<div className={styles.separatorLine} />
<span className={`caption-1 white ${styles.separatorText}`}>OR</span>
<div className={styles.separatorLine} />
<div className="w-full h-auto flex items-center text-center my-8">
<div className="flex-1 border border-[#f1f1f1]" />
<span className="caption-1 white mx-6">OR</span>
<div className="flex-1 border border-[#f1f1f1]" />
</div>
);
};
Loading
Loading