Building and Open-Sourcing an AI Comic Drama App in 8 Days

    This article walks through the engineering practice of building a minimum viable AI comic drama application in eight days and releasing it as open source. It covers the five-layer architecture, structure-first data contracts, layered prompting with local validation and partial retries, character consistency techniques, token budget and cost governance, core implementation choices, and the open-source collaboration assets required. Readers will find reusable conclusions for turning content generation demos into deliverable products.

    1. Background and Goals

    In content production, “comic drama” sits between comics and short-form video: it needs continuous visual storytelling, stable character designs, readable dialogue pacing, and engineering properties that support batch production. Traditional workflows depend on collaboration among illustrators, writers, and editors, which keeps per-episode costs high and iteration slow. LLM-based content generation can automate the first half of the pipeline, from idea to storyboard, and significantly shorten the trial-and-error cycle.

    The goals of this practice were limited to three points. First, deliver a runnable minimum viable version within eight days. Second, use LLMs throughout the pipeline for script writing and shot planning. Third, open source the project after completion and accept external collaboration and feedback. Note that the “eight days” here was not pure coding time; it covered the full cycle of requirement convergence, prompt tuning, and rework on generation quality.

    2. Overall Architecture

    The system is split into five layers that communicate through explicit data contracts, preventing errors from propagating downstream during generation.

    1. Input layer: accepts a one-sentence theme, genre tags, target episode count, and duration from the user.
    2. Script generation layer: produces structured script data rather than long-form natural language.
    3. Storyboard breakdown layer: splits the script into a shot sequence annotated with shot size, camera movement, emotion, and dialogue.
    4. Visual generation layer: calls image generation per shot with character consistency constraints.
    5. Composition and export layer: handles subtitle layout, voice-over timeline alignment, final export, and cover generation.

    The key design principle is “structure first.” Letting the model directly output natural language descriptions of the finished video makes downstream parsing extremely fragile; requiring the model to output fixed-structure JSON confines uncertainty to the field level.

    1. {
    2. "episode": 1,
    3. "title": "The Seventh Letter on a Rainy Night",
    4. "scenes": [
    5. {
    6. "scene_id": 3,
    7. "shot": "medium_close_up",
    8. "camera": "slow_push_in",
    9. "emotion": "hesitation",
    10. "characters": ["protagonist"],
    11. "dialogue": [{"role": "protagonist", "text": "This letter should not be opened by me."}],
    12. "duration_ms": 4200
    13. }
    14. ]
    15. }

    3. Layered Prompting and Structured Output Constraints

    In practice, prompts are the part most likely to get out of control. A single giant prompt looks convenient, but it easily causes genre drift and format breakage across multiple generation rounds. A more reliable approach is layering:

    • System layer: defines the role, output format, and prohibitions, and stays unchanged.
    • Worldview layer: injects character settings, era background, and language style, and can be version controlled.
    • Task layer: describes only the problem and emotional arc of the current episode.
    • Correction layer: when validation fails, returns only the erroneous fields and repair requirements instead of resending the full context.

    Combined with structured output constraints and local validation, this forms a “generate-validate-repair” loop. The validator only checks required fields, enum value ranges, and total duration, without making semantic judgments, which keeps it lightweight.

    1. Validation failed: the value of scenes[2].shot is not in the allowed enum
    2. Repair requirement: re-output only scenes[2], and choose shot from [wide, medium, close_up, medium_close_up]

    This “partial retry” strategy kept wasted tokens very low in practice, because a failure does not require resending the entire episode script.

    4. Character Consistency and Visual Controllability

    The biggest visual risk in comic drama is character drift. Engineering practice usually does not rely on the “prayer-like” effect of a single prompt, but combines three measures. First, maintain a fixed appearance description for each character and inject it as an immutable fragment. Second, fix a baseline of random seed and generation parameters to reduce unnecessary variation. Third, build a reference image library for key characters and provide visual references during generation. Stacking the three noticeably improves consistency, but manual selection and regeneration entry points must still be retained.

    Camera language needs constraints too. Making shot size, camera movement, and emotion finite enums rather than free text allows the downstream composition module to parse reliably and makes batch style replacement easier.

    5. Token Budget and Cost Governance

    The cost structure of content generation apps differs from that of regular Q&A apps: one finished episode involves dozens of structured generation calls plus rework retries. Cost governance must therefore be designed upfront rather than reviewed after the bill arrives.

    • Budget tiers: set both a call-count limit and a token limit per task; on exceeding either, degrade to “script only, no visuals.”
    • Cache reuse: cache stable prefixes such as worldview and character settings; repeated requests with identical storyboard parameters hit local results directly.
    • Context trimming: carry only a history summary relevant to the current shot instead of the full prior context.
    • Failure circuit breaker: stop retrying after consecutive validation failures reach a threshold and hand over to a human, avoiding wasted consumption.
    • Observability: log the input and output size, latency, and result status of each call to produce analyzable reports.

    The value of this mechanism is turning an “unpredictable bill” into a “predictable per-episode cost,” making stable product pricing possible.

    6. Implementation Highlights

    The technology choices stay restrained: the backend provides task orchestration and state management, generation tasks are queued asynchronously, and the frontend shows progress via polling or a persistent connection. The generation pipeline is described by a state machine with states including pending, generating, validation failed, awaiting manual confirmation, and completed, so a failure at any step does not pollute downstream data.

    Object storage holds intermediate artifacts and final videos; logging and monitoring with alerting track failure rates and latency distribution; a message queue handles peak shaving. These are common cloud capability categories, and the concrete implementation can be replaced with a team’s existing infrastructure.

    Duration alignment is an easily underestimated detail. Voice-over length and shot duration often do not match, so the composition stage needs timeline stretching or frame padding; otherwise the viewing experience feels disjointed.

    7. Open Source and Collaboration

    Open sourcing does not end with pushing the code. To let external developers genuinely participate, four kinds of assets are needed: clear directory and module boundary documentation, reproducible local setup steps, sample data of generation results, and contribution guidelines with issue templates. Compliance boundaries must also be stated upfront: copyright ownership of training and generated content, the legality of asset sources, and obligations to label generated content should all be declared in the documentation to avoid later disputes.

    8. Lessons Learned

    The main reason the eight-day delivery worked was not coding speed but well-controlled scope: only one main path was built, while style expansion and community interaction were deferred. Three reusable conclusions stand out. Structured data contracts are the stabilizer for generation apps; partial retries and caching are the key to cost control; finite enums and reference constraints are the engineering solution to visual consistency. Getting these three solid moves a content generation app from “demo-ready” to “delivery-ready.”