Building a Video Generation SaaS with an AI Agent: A 3-Hour Hands-On Experiment in Long-Horizon Tasks
This article documents a hands-on experiment testing whether a single AI coding agent can autonomously build a production-ready SaaS prototype—a platform that generates short marketing videos from uploaded images—within three hours. Using a Specification-Driven Development (SDD) approach, the author demonstrates how the agent handled system architecture design, database modeling with row-level security, asynchronous task queues, and JWT-based authentication, while highlighting both the breakthroughs and the challenges encountered along the way.
From “Writing Code” to “System Engineering”
Recent releases of next-generation large language models have shifted their marketing focus away from “how good-looking the generated web pages are” toward three more ambitious capabilities: Agentic behavior, Long-Horizon Task execution, and System Engineering. The official claim is that models can autonomously break down system-level requirements like a senior architect, maintaining contextual coherence across multi-hour automation tasks.
Whether this claim holds cannot be verified by watching demo videos alone. So I designed a sufficiently complex experiment: tasking an AI coding agent with building a SaaS platform prototype from scratch—one that lets users upload images and automatically generates short e-commerce videos. I chose this use case because it sits at a commercial sweet spot for AI applications. Short-form video content is in high demand, and a large number of cross-border e-commerce sellers don’t care about workflow details. They care about three things: the cost per video, whether they can batch-produce content daily, and whether a ready-to-use platform exists. In the AI era, “teaching someone to fish” is less effective than simply “giving them the fish.” A product that end users can adopt out-of-the-box is the most appropriate test of engineering capability.
This requirement is fundamentally not a “writing code” problem—it’s a “system architecture” problem. To make it commercially viable, the following had to be addressed simultaneously:
- Backend: designing service interfaces and business-layer separation;
- Database: table schema modeling and row-level security (RLS) configuration;
- Task scheduling: since video generation can take minutes, an asynchronous queue with status polling and timeout fallback was needed;
- Authentication and billing: phone-number verification code login, JWT token issuance, and a user credit system for deduction and reconciliation.
By previous experience, this would take a five-person team several weeks. My goal this time: can a single agent, with my occasional human intervention, get it running within a few hours?
Methodology: Using SDD to Constrain the Execution Flow
Simply telling the model to “build me a SaaS” would likely produce a demo page. To force system-level capability, I adopted a Specification-Driven Development (SDD) approach, explicitly defining the execution order in the prompt and requiring the model to strictly follow three phases:
- Research phase: Output a requirements analysis document covering user roles, core use cases, boundary conditions, and non-functional requirements (concurrency, generation timeout limits, failure retry strategy). Writing code was forbidden at this stage.
- Architecture phase: Based on research conclusions, produce technical selection and architecture design—service decomposition, data models, async task flow diagrams, and authentication schemes—along with a self-review of weak points.
- Development phase: Break the work into independently verifiable sub-tasks, implement them one by one, and output self-test notes after each module.
The value of this process is that it decomposes a “long-horizon task” into milestones with clear acceptance criteria, giving the model a reference point at every step while providing me with checkpoints for human review. The core constraints in the actual prompt were roughly as follows:
Role: Senior Full-Stack ArchitectProcess: Strictly follow Research → Architecture → DevelopmentRules:- Output a document at each phase; proceed only after my confirmation- Database must include RLS policy design- Video generation tasks must use an async queue with polling endpoints- All APIs must include error code definitions and idempotency notes
Key Module Implementations
Backend Services and Data Models
The model chose a mainstream Python async web framework for the API service, organized as a three-layer structure: routes → service layer → data access layer. For data modeling, the core tables included users, credit transactions, generation tasks, and video artifacts. Notably, it proactively provided an RLS policy: by binding the user ID to a database session variable, it ensures that any query can only access the current user’s data rows. This is a security baseline for multi-tenant SaaS. The SQL sketch:
ALTER TABLE generation_tasks ENABLE ROW LEVEL SECURITY;CREATE POLICY tenant_isolation ON generation_tasksUSING (user_id = current_setting('app.user_id')::uuid);
Asynchronous Task Queue and Polling
Video generation is a typical long-running operation that cannot synchronously block HTTP requests. The model’s approach: the submission endpoint only creates a task record and pushes it to a message queue. A separate worker process consumes the queue and invokes the video generation capability. The frontend polls a status endpoint using the task ID. The state machine covers five states—queued, generating, succeeded, failed, and timed out—with failure retry and credit-refund logic built in. Deduction only happens after a task truly succeeds, preventing users from paying for failed jobs. This is a detail many demos overlook but one that is essential for commercial deployment.
Authentication and Billing
Login uses phone-number verification codes. Upon successful verification, a JWT is issued, with unified validation and refresh logic in middleware. The credit system and task tables maintain auditability through a transaction ledger—every deduction leaves a trace and supports reconciliation.
Real-World Experience and Pitfalls
Running the full pipeline took about three hours. The overall impression: the agent successfully maintained need-context over a long task. Naming conventions and API definitions stayed consistent across phase documents, and cross-module changes triggered proactive updates to related code. This level of coherence was difficult to achieve with the single-turn dialogue style of earlier coding experiences.
There were pitfalls as well. First, generation was time-consuming, and on the day of the experiment, a surge of users slowed response times considerably—some steps required patience. Second, the architecture documentation was occasionally too “idealistic”; for instance, it made optimistic assumptions about third-party video generation API calls, requiring manual corrections to retry and degradation strategies. Third, the human checkpoints mid-task were essential. Allowing the process to run entirely unsupervised risks early decisions drifting off course, and the later you correct them, the higher the cost.
Conclusion
This experiment changed my assessment of AI programming. It may genuinely be entering the next phase. As models acquire task decomposition, long-context maintenance, and system-level planning capabilities, the developer’s role is shifting from “the one who writes code” to “the one who defines specifications and performs acceptance.” The clearer the specification, the higher the quality of the agent’s output. This is likely the core working pattern for AI-assisted programming in the next stage.
