# hitsz-tmg/filmagent architecture

> Architecture diagram of the GitHub repository hitsz-tmg/filmagent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hitsz-tmg/filmagent
- Repository: https://github.com/hitsz-tmg/filmagent

## Overview

##### Main Components

a) Agent Layer
- Director Agent
- Screenwriter Agent
- Actor Agent
- Cinematographer Agent

b) Processing Stages
- Idea Development Stage
- Scriptwriting Stage
- Cinematography Stage

c) External Systems
- Unity 3D Environment
- ChatTTS System
- LLM Service (OpenAI API)

##### Input Layer
- Topic Input
- Configuration Files (env.txt)
- Location Definitions (/Locations folder)

##### Core Processing Layer
- Multi-Agent Collaboration System
- Collaboration strategies (Critique-Correct-Verify, Debate-Judge)
- Script Generation Pipeline
- Camera Control System

##### Integration Layer
- Unity Integration
- Audio Generation System
- File Management System

##### Output Layer
- Generated Scripts (script.json)
- Actor Profiles (actors_profile.json)
- Audio Files (.wav)
- Final Video Output

Key Elements to Highlight:

##### Data Flow
- Sequential nature of the three stages

##### Component Interactions
- How agents communicate during collaboration
- Integration points with external systems
- Data storage points

##### The data transformation pipeline

Important Technical Details to Include:

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        Topic[Topic Input]
        Config["System Config"]:::config
        click Config "https://github.com/HITsz-TMG/FilmAgent/blob/main/FilmAgent/env.txt"
        Locations["Location Definitions"]:::locations
        click Locations "https://github.com/HITsz-TMG/FilmAgent/tree/main/FilmAgent/Locations"
    end

    subgraph "Agent Layer"
        Director["Director Agent"]:::agent
        click Director "https://github.com/HITsz-TMG/FilmAgent/blob/main/FilmAgent/Prompt/director_1.txt"
        Screenwriter["Screenwriter Agent"]:::agent
        click Screenwriter "https://github.com/HITsz-TMG/FilmAgent/blob/main/FilmAgent/Prompt/screenwriter_1.txt"
        Actor["Actor Agent"]:::agent
        click Actor "https://github.com/HITsz-TMG/FilmAgent/blob/main/FilmAgent/Prompt/actor.txt"
        Cinematographer["Cinematographer Agent"]:::agent
        click Cinematographer "https://github.com/HITsz-TMG/FilmAgent/blob/main/FilmAgent/Prompt/cinematographer.txt"
    end

    subgraph "Processing Stages"
        IdeaDev["Idea Development"]:::stage
        Script["Scriptwriting"]:::stage
        Cinema["Cinematography"]:::stage
    end

    subgraph "External Systems"
        Unity["Unity 3D Environment"]:::external
        ChatTTS["ChatTTS System"]:::external
        LLM["LLM Service"]:::external
        click LLM "https://github.com/HITsz-TMG/FilmAgent/blob/main/FilmAgent/LLMCaller.py"
    end

    subgraph "Integration Layer"
        CameraControl["Camera Control System"]:::integration
        click CameraControl "https://github.com/HITsz-TMG/FilmAgent/blob/main/FilmAgent/Locations/shots.json"
        AudioGen["Audio Generation"]:::integration
        click AudioGen "https://github.com/HITsz-TMG/FilmAgent/blob/main/FilmAgent/GenerateAudio.py"
        Pipeline["Main Processing Pipeline"]:::integration
        click Pipeline "https://github.com/HITsz-TMG/FilmAgent/blob/main/FilmAgent/main.py"
    end

    subgraph "Output Layer"
        Scripts["Generated Scripts"]:::output
        click Scripts "https://github.com/HITsz-TMG/FilmAgent/blob/main/FilmAgent/scripts/*/*/script.json"
        ActorProfiles["Actor Profiles"]:::output
        click ActorProfiles "https://github.com/HITsz-TMG/FilmAgent/blob/main/FilmAgent/scripts/*/*/actors_profile.json"
        AudioFiles["Audio Files (.wav)"]:::output
        FinalVideo["Final Video Output"]:::output
    end

    Topic --> Pipeline
    Config --> Pipeline
    Locations --> Pipeline

    Pipeline --> Director
    Director --> IdeaDev
    IdeaDev --> Screenwriter
    Screenwriter --> Script
    Script --> Actor
    Actor --> Cinema
    Cinema --> Cinematographer

    Cinematographer --> CameraControl
    CameraControl --> Unity
    Actor --> AudioGen
    AudioGen --> ChatTTS
    ChatTTS --> AudioFiles

    Director --> LLM
    Screenwriter --> LLM
    Actor --> LLM
    Cinematographer --> LLM

    IdeaDev --> Scripts
    Script --> ActorProfiles
    Cinema --> FinalVideo

    %% Collaboration Flow
    Director <--> Screenwriter
    Screenwriter <--> Actor
    Actor <--> Cinematographer

    %% Styles
    classDef agent fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef stage fill:#90EE90,stroke:#333,stroke-width:2px
    classDef external fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef integration fill:#E6E6FA,stroke:#333,stroke-width:2px
    classDef output fill:#F0F0F0,stroke:#333,stroke-width:2px
    classDef config fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef locations fill:#DDA0DD,stroke:#333,stroke-width:2px
```
