Building Front-End Applications with AI: A Practical Workflow and Evaluation Framework
This article presents a systematic approach to building front-end applications with AI, using an earnings-season monitoring web app as a working example. It covers how to turn a one-line request into a structured specification, how to evaluate different AI generation approaches with a consistent framework, how iterative agent loops work, and how to extend a front-end prototype into a full-stack application. It also addresses practical concerns such as quota management, dependency locking, checkpointing, and security baselines that matter when prototypes move into real engineering work.
1. Background and Problem Definition
More and more developers are describing requirements in natural language and letting AI generate runnable application prototypes directly. This approach can produce page structures, visual styles, and basic interactions in a short time, dramatically shortening the path from an idea to a visible interface.
However, whether a prototype can move into the engineering phase depends on three questions: Is the requirement description complete? Can the generated result be verified? Is subsequent iteration controllable? Judging by demo effect alone makes it easy to overestimate how complete the generated result actually is. This article uses an earnings-season monitoring web application as an example to show how to systematically go from requirements to delivery.
The core needs of such an application typically include: displaying revenue, net profit, and year-over-year and quarter-over-quarter changes per company; supporting filtering and sorting by sector and report period; and raising alerts when key metrics cross defined thresholds. These requirements sound simple, but there are many details to clarify around data formats, outlier handling, and interaction behavior.
2. Requirement Breakdown: From One Sentence to an Executable Specification
The quality of AI-generated output depends heavily on the precision of the input. A request like “build an earnings monitoring page” leaves too many blanks for the generator to fill in on its own, and the result often diverges from expectations. Before generating anything, you should organize the requirements into a structured specification. A practical specification usually has four parts.
Feature list: Enumerate every page, every component, and every action a user can perform—for example, summary cards, a company detail table, a trend chart, plus operations like filtering, sorting, and setting alert thresholds.
Data model: Define field names, types, units, and time granularity. Is revenue in dollars or thousands of dollars? Is year-over-year growth a percentage or a decimal? Is the report period a quarter or a calendar month? These details must be written down explicitly, or different modules will easily end up with inconsistent conventions.
Interaction rules: Define how loading, empty, and request-failure states are displayed. Many prototypes only cover the happy path; missing these states leads to blank screens or errors in real use.
Visual constraints: Specify colors, font sizes, grid widths, and layout requirements at different screen sizes.
Here is a simplified specification example:
app: earnings-monitorpages:- name: dashboardcomponents: [summary_cards, company_table, trend_chart]data_model:company:symbol: stringreport_period: daterevenue: number # unit: 10k USDnet_profit: number # unit: 10k USDrevenue_yoy: number # decimal form; 0.12 means 12%interactions:filter_by: [sector, report_period]sort_by: [revenue_yoy, net_profit]alert:metric: revenue_yoyoperator: "<"threshold: -0.10states:loading: skeletonempty: prompt the user to adjust filter conditionserror: show a retryable error message
Sample data should also cover edge cases, such as missing values, negative growth, losses, cross-period comparisons, and companies with identical names. Validating only with ideal data makes it easy for the generated result to break against real data.
3. An Evaluation Framework for Side-by-Side Comparison
Giving the same requirement to different generation approaches can produce very different results. Without a unified evaluation standard, conclusions tend to reflect personal preference rather than actual capability. Before comparing, define evaluation dimensions and use the same prompts, the same sample data, and the same acceptance test cases.
| Dimension | How to Check | Pass Criteria |
|---|---|---|
| Feature completeness | Check each item against the spec | All listed features are operable |
| Runnability | Install dependencies and start via the standard flow | Starts without manual patching |
| Visual consistency | Check each page against visual constraints | Colors, spacing, and font sizes are uniform |
| Interaction correctness | Run filter, sort, and alert test cases | Results match expected data |
| Error handling | Inject missing values, empty data, API errors | Page does not crash; messages are clear |
| Modifiability | Request two small requirement changes | Changes are scoped, no cascading errors |
| Iteration cost | Record rounds and time to reach a usable state | Few rounds, predictable time |
Randomness also matters during evaluation. The same prompt can produce different results across multiple generations. For key conclusions, sample multiple runs and observe stability instead of relying on a single demo.
4. How Iterative Task Execution Works
Mature AI coding tools generally follow a “plan, generate, check, fix” loop. Compared to generating an entire project in one shot, this mode is closer to how engineers actually work: build the skeleton first, then fill in details step by step, adjusting at each step based on feedback.
The core logic can be expressed in pseudocode:
function build_app(spec, max_rounds):plan = make_plan(spec)for round in 1..max_rounds:code = generate_code(plan)write_files(code)result = run_checks() # build, unit tests, page smoke testsif result.passed:return codeplan = revise_plan(plan, result.errors)raise error("max rounds exceeded; human intervention required")
This logic contains three key design points.
Feedback signals must be decidable. Whether the build succeeds, whether tests pass, and whether the page renders correctly can all be determined programmatically. If the feedback is just “looks fine,” the loop cannot converge.
A round limit is essential. An unbounded automatic loop can burn resources repeatedly on the same error. Once the limit is exceeded, the process should stop and hand off to a human rather than keep trying.
Each round’s changes must be traceable. It is recommended to save a snapshot before each generation round and record changes with version control. If a round introduces problems, you can quickly roll back to the last stable state.
5. From Front-End Prototype to Full Application
A front-end-only prototype typically uses mock data. To make it genuinely usable, you need to add a back end and handle data collection, cleaning, storage, and alerting. The recommended approach is to define the API contract first, then implement front end and back end separately, so neither side makes assumptions about the other’s data format.
An API contract example:
GET /api/companies?report_period=2026-Q3§or=technology{"items": [{"symbol": "EX001","report_period": "2026-Q3","revenue": 12800,"net_profit": 1520,"revenue_yoy": 0.12}],"total": 1}Error responses follow a unified format:{"code": "INVALID_PERIOD","message": "Invalid report period format"}
During development, the front end can switch data sources via configuration, transitioning smoothly between mock data and the real API. The concrete approach is to introduce a data access layer: page components depend only on unified interface functions and never read mock files directly. This way, when the back-end API changes, only the data access layer needs to be modified, not the pages.
The back end typically includes the following general modules:
- Data collection: Periodically pull report data from authorized data sources, paying attention to data licensing terms and update frequency.
- Data cleaning: Normalize units, validate field types, handle missing values, and log the source of anomalous data.
- Data storage: Build indexes by company and report period to ensure efficient conditional queries.
- Monitoring and alerting: Compute metrics against preset rules, push notifications through messaging channels when thresholds are triggered, and record alert history.
Every module should have corresponding tests—especially the cleaning rules, which directly determine whether the displayed results are trustworthy.
6. Quota and Cost Management
When using AI coding tools, resource quotas are a real constraint. A common mistake is submitting a very large task in one go, exhausting the quota midway, which produces incomplete output or even leaves behind half-finished files. A safer approach is to control task granularity and establish a simple budgeting mechanism.
Recommended principles:
- Start small, then scale: Complete the skeleton and one core page first, verify the workflow is viable, then expand to other features.
- Freeze stable parts into code: Once configurations, style variables, and shared components are settled, save them directly in the repository instead of asking the tool to regenerate them every time.
- Cache intermediate results: Specification documents, sample data, and evaluation reports can be reused; they do not need to be re-entered in every task round.
- Log the cost of each task: Include time spent, input size, and number of files produced, so future task costs can be estimated.
A simple budget check:
budget = { weekly_limit: 100, used: 0 }function can_run(estimated_cost):reserve = budget.weekly_limit * 0.2 # reserve 20% for reworkreturn budget.used + estimated_cost <= budget.weekly_limit - reservefunction record(actual_cost):budget.used = budget.used + actual_cost
Reserving quota for rework is important. Generated results rarely meet requirements perfectly on the first attempt, and the correction phase often consumes more resources than the initial generation.
7. Engineering Risks and Reliability
Once a prototype enters the engineering phase, the following risks need attention.
Dependency management. Commit dependency lock files and pin versions of critical dependencies to ensure consistent installation results across environments. Without locked versions, the same code installed at different times can produce different results.
Interruption recovery. Long-running generation and modification tasks can be interrupted by network issues, quota limits, or human intervention. Commit a checkpoint after every verifiable step, so that after an interruption you can resume from the most recent checkpoint instead of starting over.
Overwrite protection. Before an automated tool modifies files, it should check whether target files have uncommitted changes. Files outside the scope of the current task should not be overwritten directly.
Security baseline. Sensitive information such as keys and access tokens should be injected via environment variables or a secrets management service—never written into code or logs. Data rendered from APIs must be escaped to prevent cross-site scripting. The API layer should validate query parameters against an allowlist.
Data accuracy. Earnings data demands high accuracy. The display should annotate the data source, update time, and calculation methodology to prevent user misinterpretation.
8. Practical Checklist
- Complete a structured specification before generation, covering the feature list, data model, interaction states, and visual constraints.
- Prepare sample data that covers edge cases, and write automatically executable acceptance test cases.
- Evaluate different approaches with unified dimensions and identical inputs, sampling multiple runs before drawing conclusions.
- Set a round limit and decidable feedback signals for the iteration loop, handing off to humans when the limit is exceeded.
- Define the API contract first, then develop front end and back end in parallel, with the front end isolating data sources behind a data access layer.
- Control the granularity of individual tasks, reserve quota for rework, and record the resource consumption of each task.
- Commit dependency lock files and checkpoints to ensure environment consistency and process recoverability.
- Manage sensitive information via environment variables or a secrets service, and annotate data displays with sources and update times.
