Schรฉma de Flux

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    MAD LORDS STUDIO IA - ARCHITECTURE               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
      โ”‚  Client iOS  โ”‚
      โ”‚  React Nativeโ”‚
      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚ HTTPS/REST
             โ–ผ
      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
      โ”‚   API        โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ–บโ”‚  Auth Service       โ”‚
      โ”‚   Gateway    โ”‚       โ”‚  (JWT + OAuth2)     โ”‚
      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ–ผ                 โ–ผ                โ–ผ                โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Prompt  โ”‚    โ”‚ IA 2D     โ”‚   โ”‚ Pipeline   โ”‚   โ”‚ Printer     โ”‚
โ”‚ Engine  โ”‚    โ”‚ Stable-   โ”‚   โ”‚ 2D โ†’ 3D    โ”‚   โ”‚ Integration โ”‚
โ”‚ (Brief) โ”‚    โ”‚ Diffusion โ”‚   โ”‚ Tripo AI   โ”‚   โ”‚ SDK         โ”‚
โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
     โ”‚               โ”‚               โ”‚                 โ”‚
     โ”‚               โ–ผ               โ–ผ                 โ–ผ
     โ”‚        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚              PostgreSQL + Redis            โ”‚
              โ”‚     (Users, Projects, Assets, Queue)       โ”‚
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                    โ”‚
                                    โ–ผ
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ”‚           Object Storage (S3)              โ”‚
              โ”‚  (Images 2D, Modรจles 3D, Fichiers STL)     โ”‚
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Stack Technologique

01

Frontend Mobile

  • React Native โ€” Application iOS native
  • Expo SDK 51 โ€” Build & distribution
  • Three.js โ€” Rendu 3D interactif
  • React Navigation 6 โ€” Navigation fluide
  • Reanimated 3 โ€” Animations performantes
  • AsyncStorage โ€” Persistance locale
02

Backend API

  • Python 3.11+ โ€” Langage principal
  • FastAPI โ€” Framework API REST
  • Celery โ€” Tรขches asynchrones
  • SQLAlchemy โ€” ORM base de donnรฉes
  • Pydantic โ€” Validation des donnรฉes
  • Uvicorn โ€” Serveur ASGI
03

Bases de Donnรฉes

  • PostgreSQL 15 โ€” Donnรฉes relationnelles
  • Redis 7 โ€” Cache & queue
  • S3 โ€” Stockage objets (assets)
  • AWS Secrets Manager โ€” Secrets sรฉcurisรฉs
04

Services IA

  • Stable Diffusion XL โ€” Gรฉnรฉration 2D fine-tunรฉe
  • Tripo AI โ€” Conversion 2D โ†’ 3D
  • RunPod/Replicate โ€” Infรฉrence GPU
  • ComfyUI โ€” Pipeline IA orchestrรฉ
  • Fine-tuning LoRA โ€” Style Mad Lords
05

Intรฉgration 3D

  • Blender 4.x โ€” Scripts automatisรฉs mesh
  • OpenMesh โ€” Validation gรฉomรฉtrique
  • Formlabs SDK โ€” Imprimante Form 4
  • PreForm API โ€” Prรฉparation impression
  • STL Validator โ€” Check fabricabilitรฉ
06

Infrastructure

  • AWS ECS โ€” Containers managรฉs
  • AWS RDS โ€” PostgreSQL managรฉ
  • AWS ElastiCache โ€” Redis managรฉ
  • CloudFlare โ€” CDN & WAF
  • GitHub Actions โ€” CI/CD

Pipeline de Gรฉnรฉration 2D

De l'Intention au Prompt Optimisรฉ

Le moteur de prompt guidรฉ transforme les choix utilisateur en prompt technique optimisรฉ pour Stable Diffusion.

class GuidedPromptEngine:
    """Convertit les choix utilisateur en prompt IA optimisรฉ"""
    
    def build_prompt(self, brief: JewelryBrief) -> str:
        components = []
        
        # Type de bijou
        components.append(f"{brief.jewelry_type} jewelry piece")
        
        # Vocabulaire Mad Lords selon l'univers
        style_mapping = {
            "desert_sun": "desert sun aesthetic, warm golden tones, sand textures",
            "moon_stars": "celestial motifs, moon phase, silver luminance",
            "serpents": "snake coils, reptilian scales, mystical serpent",
            "sacred": "sacred geometry, ancient symbols, spiritual sigils",
        }
        components.append(style_mapping.get(brief.universe))
        
        # Matรฉriaux et finitions
        components.append(f"{brief.metal} metal, {brief.finish} finish")
        
        # Paramรจtres techniques LoRA
        lora_trigger = "<lora:madlords_style_v1:0.8>"
        
        return self._assemble(components, lora_trigger)

Stable Diffusion XL Fine-Tunรฉ

Modรจle SDXL enrichi par entraรฎnement LoRA sur le catalogue Mad Lords :

Pipeline 2D โ†’ 3D

De l'Image au Modรจle Imprimable

# ร‰tape 1: Conversion via Tripo AI
POST /api/tripo/generate
{
    "image_url": "s3://madlords/renders/ring_001.png",
    "mode": "jewelry_detailed",
    "output_format": "glb"
}

# ร‰tape 2: Post-traitement Blender (script Python)
bpy.ops.wm.open_mainfile(filepath="raw_model.glb")
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.remove_doubles(threshold=0.0001)      # Fusion vertices
bpy.ops.mesh.fill_holes(sides=64)                  # Fermeture trous
bpy.ops.object.modifier_add(type='SOLIDIFY')       # ร‰paisseur minimale
bpy.ops.export_mesh.stl(filepath="output.stl")

# ร‰tape 3: Validation STL pour joaillerie
class STLValidator:
    MIN_WALL_THICKNESS = 0.8   # mm - minimum pour fonte or
    MAX_OVERHANGS = 45         # degrรฉs - supportable sans structures
    
    def validate(self, stl_path: str) -> ValidationResult:
        mesh = trimesh.load(stl_path)
        
        checks = {
            "manifold": mesh.is_watertight,
            "wall_thickness": self._check_thickness(mesh),
            "overhangs": self._check_overhangs(mesh),
            "volume": mesh.volume > 10,  # mmยณ minimum
        }
        
        return ValidationResult(
            valid=all(checks.values()),
            details=checks
        )

Intรฉgration Imprimante 3D

Impression 3D Joaillerie

Imprimantes Compatibles

Modรจle Technologie Prรฉcision
Formlabs Form 4 MSLA 25 ฮผm
Asiga MAX X DLP 27 ฮผm
Envision One cDLM cDLM 25 ฮผm

Rรฉsine de Production

Formlabs Castable Wax 40 โ€” Rรฉsine spรฉciale pour fonte ร  cire perdue, brรปlage propre, dรฉtails fins jusqu'ร  50ฮผm.

SDK Formlabs

class FormlabsPrinterSDK:
    
    async def prepare_print(
        self, 
        stl_path: str,
        resin: str = "castable_wax_40"
    ) -> PrintJob:
        # Upload vers PreForm
        job = await self.preform.upload(
            stl_path,
            orientation="auto",
            supports="auto_light"
        )
        
        # Estimation temps et rรฉsine
        estimate = await job.estimate()
        
        return PrintJob(
            id=job.id,
            duration=estimate.time,
            resin_ml=estimate.resin,
            layer_height=0.025  # 25ฮผm
        )
    
    async def start_print(self, job_id: str):
        return await self.printer.start(job_id)
    
    async def get_status(self, job_id: str):
        return await self.printer.status(job_id)

Sรฉcuritรฉ & Conformitรฉ

Authentification

  • JWT tokens avec rotation
  • OAuth2 / Apple Sign-In
  • Rate limiting (100 req/min)
  • Session invalidation

Chiffrement

  • TLS 1.3 en transit
  • AES-256 au repos
  • AWS Secrets Manager
  • Rotation clรฉs automatique

Conformitรฉ

  • RGPD compliant
  • Droit ร  l'oubli
  • Export donnรฉes
  • Logs d'audit

Modรจle de Donnรฉes

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚      USERS      โ”‚       โ”‚    PROJECTS     โ”‚       โ”‚     ASSETS      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค       โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค       โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ id (PK)         โ”‚โ”€โ”€โ”€โ”€โ”€โ”€<โ”‚ user_id (FK)    โ”‚โ”€โ”€โ”€โ”€โ”€โ”€<โ”‚ project_id (FK) โ”‚
โ”‚ email           โ”‚       โ”‚ id (PK)         โ”‚       โ”‚ id (PK)         โ”‚
โ”‚ invitation_code โ”‚       โ”‚ jewelry_type    โ”‚       โ”‚ type (2d/3d/stl)โ”‚
โ”‚ created_at      โ”‚       โ”‚ universe        โ”‚       โ”‚ s3_path         โ”‚
โ”‚ profile_data    โ”‚       โ”‚ budget          โ”‚       โ”‚ version         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ”‚ metal           โ”‚       โ”‚ validation      โ”‚
                          โ”‚ stones          โ”‚       โ”‚ created_at      โ”‚
                          โ”‚ status          โ”‚       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚ brief_json      โ”‚
                          โ”‚ prompt          โ”‚       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                          โ”‚ created_at      โ”‚       โ”‚    PAYMENTS     โ”‚
                          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
                                   โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€>โ”‚ project_id (FK) โ”‚
                                                     โ”‚ id (PK)         โ”‚
                                                     โ”‚ type (20/30/50) โ”‚
                                                     โ”‚ amount          โ”‚
                                                     โ”‚ stripe_id       โ”‚
                                                     โ”‚ status          โ”‚
                                                     โ”‚ paid_at         โ”‚
                                                     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Pipeline CI/CD

GitHub Actions Workflow

name: Deploy Mad Lords Backend

on:
  push:
    branches: [main, staging]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run Tests
        run: |
          pytest tests/ --cov=app
          
  build:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - name: Build Docker Image
        run: docker build -t madlords-api .
      - name: Push to ECR
        run: aws ecr push madlords-api:${{ github.sha }}
        
  deploy:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to ECS
        run: |
          aws ecs update-service \
            --cluster madlords-prod \
            --service api \
            --force-new-deployment

Environnements

Environnement Branche URL
Production main api.madlords.studio
Staging staging staging-api.madlords.studio
Dev develop dev-api.madlords.studio