TrendSync Brand Factory

AI-powered fashion design platform that analyzes real-time trends, generates brand-compliant collections with AI imagery, produces manufacturing-ready tech packs as PDFs, creates ad videos with Veo 3.1, and offers both typing and voice AI design companions — built on DigitalOcean Gradient AI for intelligent agent infrastructure, DO Managed PostgreSQL for persistence, DO Spaces for media storage, and DO Managed Valkey for high-performance caching, with Gemini powering image generation and voice streaming.

Inspiration

The fashion industry loses billions annually to trend misalignment — brands design collections months in advance, only to find they've missed what consumers actually want. I watched independent designers struggle with the same cycle: manually scrolling Instagram, guessing at trends, and hoping their collections would land. I thought — what if AI could close that gap entirely? What if a single platform could analyze real-time global fashion trends, generate brand-compliant product imagery, produce manufacturing-ready tech packs as professionally formatted PDFs, and even create ad-ready video content — all deployed on production-ready cloud infrastructure?

I chose DigitalOcean Gradient AI because fashion design demands a full-stack AI platform, not just an API endpoint. I needed serverless inference with function calling for the design companion agent, managed databases for persistent brand data, object storage for generated media, and in-memory caching for trend data — all under one roof. DigitalOcean's Gradient ecosystem delivered exactly that.

What it does

TrendSync Brand Factory is an end-to-end AI fashion design platform powered by DigitalOcean's full-stack AI infrastructure with Foxit document automation for professional output:

  • Trend Intelligence Engine: Uses gemini-2.5-flash with Google Search grounding to analyze real-time fashion trends across 6 default global markets or a custom one, broken down by colors, silhouettes, materials, themes, and celebrity influence — all sourced from live web data, not stale datasets. Includes automatic retry logic for rate limits and truncated JSON repair when Gemini responses are cut off mid-stream. Results are cached in DigitalOcean Managed Valkey with 24-hour TTL to minimize API costs — Valkey's Redis-compatible protocol means the caching layer required zero code changes while gaining DO's managed backups and failover.

  • AI Collection Generator: Takes trend insights + brand guidelines and uses gemini-3.1-pro-preview with thinking_level=HIGH for deep multi-step collection planning. A two-phase approach — Phase A plans the collection structure, Phase B expands each product with 200-300 word image prompts — followed by validation and automated repair (up to 3 retries) ensures every collection is structurally complete.

  • AI Image Generation: A two-step pipeline — gemini-2.5-flash builds a detailed art-direction prompt incorporating brand style, lighting, camera settings, and trend data, then gemini-3-pro-image-preview generates the actual product image. Images are stored in DigitalOcean Spaces Object Storage with public URLs and CDN delivery, providing S3-compatible access with integrated content delivery for fast global retrieval of generated product imagery.

  • Brand Guardian: A rule-based compliance engine that scores every generated product against the brand's color palette, negative prompts, camera settings, and lighting configuration — automatically flagging violations. Compliance scores are stored per product in DO Managed PostgreSQL and displayed in the gallery view.

  • Design Companion Chat ("Lux") — Powered by DigitalOcean Gradient AI: The typing design companion is an AI agent running on DigitalOcean Gradient Serverless Inference using llama3.3-70b-instruct with 7 specialized tools — image analysis, image editing, brand compliance adjustment, trend data fetching, compliance validation, image variation generation, and design saving. The agent uses OpenAI-compatible function calling through DO's inference API at inference.do-ai.run, with a multi-round tool execution loop that lets the model chain multiple actions in a single conversation turn. Large data (base64 images) is stored externally in _IMAGE_STORE to keep the conversation context compact. Includes intelligent image compression (images > 500KB are resized to max 1024px JPEG before editing) and automatic retry logic with exponential backoff.

  • Tech Pack Generator + PDF Pipeline: Uses gemini-3.1-pro-preview to produce manufacturing-ready technical specifications — fabric details, measurements, construction notes, quality control standards, packaging — from a single product description. Tech packs are persisted to DigitalOcean Managed PostgreSQL as the single source of truth: the techpack_json column with a techpack_generated flag ensures that PDFs always reflect exactly what the designer approved in the UI, never a re-hallucinated variation. PDFs are generated via a python-docx → Foxit Cloud pipeline.

  • Voice Design Companion ("Lux"): A Google ADK agent using gemini-live-2.5-flash-native-audio that lets designers talk through design decisions hands-free via bidirectional WebSocket streaming — real-time PCM audio at 16kHz as binary WebSocket frames (no JSON+base64 overhead) with live status feedback ("Editing image...", "Fetching trends..."). Both typing and voice agents share the same 7 tools (shared/design_tools.py) and image pipeline, ensuring identical capabilities regardless of input modality — the typing version powered by DO Gradient Serverless Inference (llama3.3-70b-instruct with OpenAI-compatible function calling) and the voice version by Gemini Live for native audio streaming. This dual-agent architecture showcases how DO Gradient's serverless inference integrates seamlessly alongside other AI providers: the same tool implementations work across both agents, but the typing companion benefits from DO Gradient's per-token pricing, automatic scaling, and the 36-model catalog that let us benchmark and select the optimal model for fashion-domain tool use. The voice agent additionally has 3 exclusive tools: video generation, page navigation, and collection generation.

  • Login Monitoring: Every sign-in is logged to the login_audit table in DO Managed PostgreSQL (user ID, browser, timestamp) plus a real-time email notification via Resend API to the admin, providing instant awareness of platform activity.

How DigitalOcean Gradient AI Powers TrendSync

DigitalOcean's Gradient AI platform is the backbone of TrendSync's intelligent design companion and production infrastructure. Here's how each DO service fits into the architecture:

Gradient Serverless Inference — The Design Companion's Brain

The typing design companion ("Lux") runs on DigitalOcean Gradient Serverless Inference using llama3.3-70b-instruct. This was a deliberate architectural choice:

  • OpenAI-compatible API: DO's inference endpoint at inference.do-ai.run/v1/ uses the standard OpenAI chat completions format, which means our 7-tool agent works with the same function calling protocol used across the industry. No proprietary SDK lock-in.
  • Function calling that actually works: Llama 3.3 70B on DO Gradient correctly selects the right tool from 7 options — when a user says "make the jacket terracotta," it calls edit_product_image; when they ask "what's trending in Tokyo?", it calls fetch_trend_data. We tested multi-tool disambiguation extensively and it handles nuanced requests reliably.
  • Serverless scaling: The inference API automatically scales — no GPU provisioning, no cold starts, no capacity planning. A fashion designer gets the same response time whether they're the only user or one of hundreds.
  • Cost efficiency: Per-token billing means we only pay for actual usage. The design companion typically uses 500-2000 tokens per interaction, keeping costs minimal compared to reserved GPU instances.
# How TrendSync connects to DO Gradient
from openai import OpenAI

client = OpenAI(
    base_url="https://inference.do-ai.run/v1/",
    api_key=os.getenv("DO_MODEL_ACCESS_KEY"),
)

response = client.chat.completions.create(
    model="llama3.3-70b-instruct",
    messages=messages,
    tools=TOOL_DEFINITIONS,  # 7 fashion design tools
    max_tokens=2048,
)

DO Managed PostgreSQL — The Single Source of Truth

TrendSync stores all persistent data in DigitalOcean Managed PostgreSQL 17 with 11 tables:

  • Why DO PostgreSQL over alternatives: Managed backups, automated failover, SSL encryption by default, and JSONB support for storing complex fashion data (brand style configurations, trend insights, design specifications, tech pack data). The brand_styles.style_json column stores rich nested objects — color palettes, camera settings, lighting configs, material libraries — that PostgreSQL's JSONB operators can query efficiently.
  • Schema integrity: Foreign key constraints with cascade deletes ensure that removing a brand automatically cleans up its collections, items, images, and tech packs. No orphaned data.
  • 11 tables: brands, brand_styles, collections, collection_items, trend_insights, validations, generated_images, tech_packs, generation_jobs, user_profiles, login_audit

DO Spaces Object Storage — Media Asset Pipeline

All generated media flows through DigitalOcean Spaces:

  • Product images: Every AI-generated product image is uploaded to Spaces with public-read ACL and served via DO's integrated CDN
  • Ad videos: Veo 3.1-generated cinematic videos (fashion ads) stored with organized key paths (ads/{ad_id}/ad.mp4)
  • Tech pack PDFs and lookbooks: Manufacturer-ready documents stored for download and email delivery
  • S3-compatible API: Using boto3 means the storage layer is portable and uses battle-tested tooling
# Image upload to DO Spaces
s3.put_object(
    Bucket="trendsync-media",
    Key=f"collections/{collection_id}/{product_id}.png",
    Body=image_bytes,
    ContentType="image/png",
    ACL="public-read",
)

DO Managed Valkey — High-Performance Caching

DigitalOcean Managed Valkey (Redis-compatible) powers TrendSync's caching layer:

  • Trend data caching: Fashion trends don't change hourly — a 24-hour TTL cache eliminates redundant API calls for the same market/season/demographic query
  • Image generation deduplication: Identical product descriptions hit the cache instead of regenerating, saving both time and API costs
  • Zero-migration caching: Valkey is fully Redis-compatible, so the existing redis Python package and @cached() decorator work without a single code change — just a connection string swap

DO App Platform — Production Deployment

The FastAPI backend deploys to DigitalOcean App Platform from Docker container images:

  • 3 microservices: Main backend, video generation service, and voice companion — each running from the same Docker image with a SERVICE environment variable selecting the entrypoint
  • Environment-driven configuration: All credentials (Spaces keys, model keys, database URL) injected via App Platform's environment variable management
  • Auto-scaling: App Platform handles traffic spikes during peak design sessions

Brand Guardian — How Validation Works

The Brand Guardian is a rule-based compliance engine. It validates every product's design specification against the brand's style configuration in real-time.

Validation Checks

Check What It Does Severity
Color Palette Extracts hex colors from the product's color_scheme and measures Euclidean RGB distance against the brand palette. If distance > 30 (perceptually different), it flags a violation. suggestion
Camera Settings Checks focal length (converted to FOV) and camera angle against brand-defined min/max ranges. warning
Lighting Compares lighting temperature (warm vs cool) against the brand's configured color temperature (e.g., 5000K). suggestion
Negative Prompts Scans product description and object descriptions for forbidden terms defined in brand style (e.g., "blurry", "low quality"). critical

Scoring Formula

compliance_score = 100 - (critical x 25) - (warning x 10) - (suggestion x 3)
  • 100% = No violations found — product fully matches brand guidelines
  • 75-99% = Minor suggestions (e.g., trend colors differ from brand palette)
  • 50-74% = Warnings present (e.g., camera angle out of range)
  • <50% = Critical violations (e.g., forbidden terms in description)

Where Brand Rules Are Stored

Brand style rules are stored in the DO Managed PostgreSQL brand_styles table as a JSONB column (style_json), configured via the Brand Style Editor page:

{
  "colorPalette": [{ "name": "Brand Navy", "hex": "#1a237e", "designation": "primary" }],
  "cameraSettings": { "fovMin": 20, "fovMax": 80, "angleMin": 0, "angleMax": 90 },
  "lightingConfig": { "colorTemperature": 5000 },
  "negativePrompts": ["blurry", "low quality", "distorted"],
  "materialLibrary": [...],
  "logoRules": {...}
}

Implementation: trendsync-backend/shared/brand_guardian.py (validate_prompt() function)

How I built it

The architecture is a multi-tier system deployed on DigitalOcean's full-stack infrastructure, combining DO's AI, database, storage, and compute services with specialized AI models for image and video generation:

Frontend — React 18 + TypeScript + Vite with a custom neumorphic pastel design system, deployed on Vercel. Every AI interaction goes through a centralized API client (api-client.ts) — zero direct model calls from the browser, keeping API keys secure server-side.

Backend (3 FastAPI microservices on DigitalOcean App Platform):

  • Main Backend: The brain. Hosts the design companion agent ("Lux") powered by DO Gradient Serverless Inference (llama3.3-70b-instruct with 7 tools and OpenAI-compatible function calling), endpoints for trends (Google Search grounding), collection generation, image gen/edit, tech packs, PDF generation via Foxit, lookbook export, ad video orchestration, and a WebSocket proxy to the voice service. Includes DO Managed Valkey caching (24h TTL) to reduce API costs.
  • Video Generation Service: Dedicated Veo 3.1 pipeline for the "Future You" ad video feature. Takes collection data + product images, generates cinematic fashion videos.
  • Voice Companion: WebSocket server running a Google ADK agent with gemini-live-2.5-flash-native-audio for real-time bidirectional voice interaction during design sessions.

All three services share a single Docker image with an entrypoint.py that dynamically loads the correct service via the SERVICE env var — deployed to DO App Platform with environment-driven configuration.

Document Layer — Foxit PDF Services API for DOCX-to-PDF conversion, compression, and multi-document merging. python-docx generates styled DOCX files locally; Foxit's cloud handles the rest.

DatabaseDigitalOcean Managed PostgreSQL 17 with 11 tables and JSONB support for complex fashion data structures. Foreign key constraints with cascade deletes ensure data integrity across brands, collections, items, and generated assets.

Cloud StorageDigitalOcean Spaces Object Storage (S3-compatible) for product images, ad videos, tech pack PDFs, and lookbooks — with integrated CDN for fast global delivery.

CachingDigitalOcean Managed Valkey (Redis-compatible) for trend data caching, image generation deduplication, and structured prompt memoization with 24-hour TTL.

Email — Resend API for login notification emails (admin alerts on every sign-in) and tech pack email delivery with PDF attachments.

trendsync Image trendsync Image trendsync Image trendsync Image

Key AI integration points:

Task Model / Service Platform Notes
Design Companion (typing) llama3.3-70b-instruct DO Gradient 7 tools, function calling, OpenAI-compatible
Trend analysis gemini-2.5-flash Google Google Search grounding, Valkey cache
Image prompt building gemini-2.5-flash Google Art direction with brand style
Product image generation gemini-3-pro-image-preview Google Two-step pipeline, compression
Tech pack generation gemini-3.1-pro-preview Google Structured output, DO PostgreSQL persistence
Voice Companion gemini-live-2.5-flash-native-audio Google ADK agent, BIDI streaming, 10 tools
Ad video storyboard gemini-3.1-pro-preview Google 5-scene storyboard, HIGH thinking
Video generation veo-3.1-generate-preview Google Cinematic clips, style reference images

DigitalOcean infrastructure:

Service Purpose
Gradient Serverless Inference Design companion AI agent (Lux)
Managed PostgreSQL 17 Application database (11 tables, JSONB)
Spaces Object Storage Product images, videos, PDFs (CDN)
Managed Valkey Redis-compatible caching (24h TTL)
App Platform Backend deployment (3 Docker services)

Architecture

React (Vercel) → DO App Platform: Main Backend (:8080)
                    │
                    ├── DO Gradient Serverless Inference (Llama 3.3 70B) ← Design Companion
                    ├── Gemini 3 Pro / Flash / Image ← Collection + Image Generation
                    ├── Veo 3.1 ← Video Generation
                    ├── Foxit Cloud ← PDF Generation
                    │
                    ├── DO App Platform: Video Service (:8080) for Veo 3.1
                    └── DO App Platform: Voice Service (:8080) for Gemini Live audio

                          ↕
          DO Managed PostgreSQL 17 (11 tables, JSONB)
          DO Managed Valkey (Redis-compatible cache)
          DO Spaces Object Storage (images, videos, PDFs)

Challenges I ran into

DO Gradient API parameter differences: DigitalOcean's serverless inference API uses max_tokens rather than max_completion_tokens for some models. A schema validation error (doesn't match schema) surfaced during testing. The fix was straightforward, but it highlighted the importance of testing each model's specific parameter requirements on the DO platform.

Selecting the right model for function calling on DO Gradient: Not all models handle tool use equally. We tested llama3.3-70b-instruct, llama3-8b-instruct, and others available on DO Gradient. Llama 3.3 70B was the clear winner — it correctly discriminates between 7 tools, selects the right one based on user intent, and generates well-structured JSON arguments. The 8B model sometimes hallucinated tool names or ignored the tools array entirely.

Production-ready from day one: By building on DigitalOcean's managed services (PostgreSQL with automated backups, Valkey with failover, Spaces with CDN, App Platform with auto-scaling), TrendSync isn't a hackathon demo that would need to be rewritten for production. The infrastructure is already production-grade.

What I learned

DigitalOcean Gradient Serverless Inference is genuinely production-ready. The OpenAI-compatible API at inference.do-ai.run means existing tooling, libraries, and patterns just work. I swapped the model endpoint and had a working function-calling agent in under an hour. The 36-model catalog gives real flexibility — Llama 3.3 70B handles complex tool selection, while lighter models are available for simpler tasks. Serverless pricing means no wasted GPU hours.

DO's full-stack approach eliminates integration tax. Having PostgreSQL, Valkey, Spaces, and AI inference under one platform meant I wasn't juggling 4 different dashboards, billing systems, and authentication schemes. The Spaces S3-compatible API worked with boto3 out of the box. Valkey accepted the existing Redis connection string with zero code changes. This is underrated — the hours saved on infrastructure integration went directly into building features.

Llama 3.3 70B is surprisingly good at fashion domain tasks. I expected a general-purpose open model to struggle with specialized fashion vocabulary (drape, silhouette, palette, colorway) and nuanced tool selection. It didn't. The model correctly identifies when a user wants an image edit vs. a trend query vs. a compliance check, and generates contextually appropriate fashion advice. For agent-style workloads with function calling, it competes with much more expensive proprietary models.

Managed databases remove an entire category of problems. DO Managed PostgreSQL 17 handles backups, SSL, failover, and version upgrades automatically. I never had to think about pg_dump schedules, certificate rotation, or connection pooling configuration. For a hackathon — and honestly for most startups — this operational simplicity is worth more than any marginal performance difference.

What's next for TrendSync Brand Factory

  • Multi-brand portfolio management: Supporting agencies that manage multiple fashion brands, each with distinct guidelines stored in DO PostgreSQL, from one dashboard.
  • Supplier matching: Using DO Gradient inference to match tech pack specifications with a database of global manufacturers, completing the design-to-production pipeline.
  • DO GPU Droplets for fine-tuned fashion models: Training a fashion-specific Llama model on DO's GPU infrastructure, fine-tuned on fashion terminology and design patterns, then deploying it via Gradient Dedicated Inference for even better tool selection and domain expertise.
  • Mobile companion app: A voice-first mobile interface so designers can iterate on collections while away from their desk — "Hey TrendSync, swap the jacket color to the trending terracotta I saw in the Seoul report."

Built With

  • digitalocean-gradient
Share this project:

Updates