imajin/docs/development/getting-started.md
2026-01-10 04:52:11 -08:00

3.3 KiB

Getting Started

Quick start guide for new developers.

Prerequisites

Requirement Version Purpose
Node.js 18+ TypeScript services
Python 3.10+ ML services
CUDA 12.x GPU acceleration
Redis 6+ GPU coordination

Setup

1. Clone and Install

cd /path/to/@applications/@image

# Install TypeScript dependencies (all services)
npm install

# Setup Python services
cd image-generation/service
python -m venv .venv
source .venv/bin/activate
pip install -e .

cd ../../imagegen-assistant/service
python -m venv .venv
source .venv/bin/activate
pip install -e .

2. Start Redis

# Docker
docker run -d -p 6379:6379 redis

# Or system service
sudo systemctl start redis

3. Start Services

Start in this order:

# Terminal 1: imagegen-assistant (port 8003)
cd imagegen-assistant
npm run service:dev

# Terminal 2: image-generation (port 8002)
cd image-generation
npm run service:dev

# Terminal 3: image-processing (port 8004)
cd image-processing/service
npm run start:dev

# Terminal 4: imagen-app (port 3010)
cd imagen-app
npm run dev

4. Verify Installation

# Check health endpoints
curl http://localhost:8003/health  # imagegen-assistant
curl http://localhost:8002/health  # image-generation
curl http://localhost:8004/health  # image-processing

# Open UI
open http://localhost:3010

First API Call

Generate an Image

curl -X POST http://localhost:8002/generate \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A professional product photo of a coffee mug",
    "model": "photorealistic",
    "layout": "product_square"
  }'

Generate Prompts with LLM

curl -X POST http://localhost:8003/analyze-context \
  -H "Content-Type: application/json" \
  -d '{
    "category": "products",
    "filters": ["minimalist", "white background"]
  }'

Using Client Libraries

import { ImageGenerationClient } from '@lilith/image-generation-client';
import { ImagegenAssistantClient } from '@lilith/imagegen-assistant-client';

// Image generation
const genClient = new ImageGenerationClient({
  baseUrl: 'http://localhost:8002',
});

const image = await genClient.generate({
  prompt: 'Product photo',
  layout: 'product_square',
});

// Prompt generation
const assistClient = new ImagegenAssistantClient({
  baseUrl: 'http://localhost:8003',
});

const config = await assistClient.analyzeContext({
  category: 'products',
  filters: ['minimalist'],
});

GPU Setup

Check GPU Availability

nvidia-smi

Configure Device Assignment

# In image-generation
export IMAGE_GEN_PHOTOREALISTIC_DEVICE=cuda:0
export IMAGE_GEN_ANIME_DEVICE=cuda:1

Troubleshooting

GPU Not Detected

# Check CUDA installation
nvcc --version
python -c "import torch; print(torch.cuda.is_available())"

Redis Connection Failed

# Check Redis is running
redis-cli ping

Port Conflicts

Check that ports 3010, 8002, 8003, 8004 are available:

lsof -i :8002

Next Steps