Case studies and Mini Project on Web App Development

Chapter 14
AI-Enabled Applications and Emerging Web Trends

Diploma in Full Stack Programming
Case studies and Mini Project on Web App Development   •   Diploma

AI-Enabled Applications and Emerging Web Trends

Introduction

Artificial intelligence has moved from specialist research laboratories into ordinary web applications. Search systems interpret intent rather than merely matching words; recommendation engines personalise content; conversational assistants guide users through services; and content-processing tools classify, summarise, translate, extract, and generate information. At the same time, web development is changing through progressive web applications (PWAs), edge computing, WebAssembly, low-code platforms, and increasingly demanding expectations concerning privacy, accessibility, security, sustainability, and professional competence.

For a full-stack programmer, the central challenge is not simply to call an AI API. It is to design a dependable socio-technical system in which AI is useful, observable, secure, affordable, and subject to human control. An application must validate inputs and outputs, protect personal data, handle failure, measure quality, and communicate the limits of automation to users.

This chapter presents practical foundations for designing AI-enabled web applications and evaluating emerging web technologies. It focuses on decisions that are appropriate for diploma-level development: selecting a suitable technique, integrating an external service, building a safe user experience, testing the result, and assessing whether a new technology solves a real problem.

Learning Objectives

After studying this chapter, a learner should be able to:

  1. Explain how search, recommendation, assistant, and content-processing features are implemented in web applications.
  2. Distinguish deterministic application logic from probabilistic AI behaviour.
  3. Integrate an AI API using validation, authentication, rate limiting, error handling, logging, and cost controls.
  4. Apply privacy, security, accessibility, fairness, transparency, and human-oversight principles.
  5. Compare PWAs, edge computing, WebAssembly, and low-code tools for appropriate use cases.
  6. Design and evaluate a small AI-enabled web application using measurable acceptance criteria.
  7. Identify emerging skills required of modern full-stack developers.

1. AI Features in Web Applications

1.1 Search and intelligent retrieval

Traditional keyword search generally compares a query with indexed text. It is predictable and inexpensive, but it may fail when users use synonyms, misspellings, natural language, or incomplete descriptions. Intelligent search may combine several techniques:

  • Lexical retrieval, which matches terms using an inverted index.
  • Filtering, which restricts results by category, price, date, location, or permissions.
  • Semantic retrieval, which represents text as vectors so that conceptually similar items can be found even when words differ.
  • Re-ranking, which orders an initial result set using relevance signals such as textual similarity, popularity, freshness, and user context.
  • Answer generation, which produces a natural-language response from retrieved and authorised sources.

A safe design separates retrieval from generation. The system first obtains relevant documents, then supplies only those documents to a response model. This retrieval-augmented generation pattern can reduce unsupported answers, although it does not guarantee correctness. Each document should have an identifier, access-control metadata, source date, and, where possible, a citation shown to the user.

Search quality should be evaluated using a representative test set. Precision is the proportion of returned results that are relevant:

Precision = relevant retrieved items ÷ total retrieved items

Recall is the proportion of all relevant items that were retrieved:

Recall = relevant retrieved items ÷ total relevant items

These measures assume that relevance judgments have been defined and that a test collection is available. A search service often balances precision and recall rather than maximising only one. In user-facing search, response time, accessibility, freshness, and permission correctness are also essential.

1.2 Recommendation systems

A recommendation feature proposes products, articles, courses, or actions. Common approaches include:

  • Popularity-based recommendation: recommends generally popular items and is useful for a new system, but is not personalised.
  • Content-based recommendation: compares item attributes with the user’s interests.
  • Collaborative filtering: uses patterns of interaction among users and items.
  • Hybrid recommendation: combines several signals to address weaknesses such as cold-start problems.
  • Context-aware recommendation: considers time, device, location, task, or current session.

A recommendation is not automatically beneficial. Excessive personalisation can narrow users’ choices, expose sensitive inferences, or create unfair visibility. A professional implementation should provide explanations such as “Because you viewed beginner JavaScript courses,” allow preference changes, and include diversity rules. Evaluation should consider relevance, novelty, coverage, user satisfaction, and business outcomes rather than clicks alone. A high click-through rate can result from misleading titles or addictive design and therefore is not a complete measure of quality.

1.3 Assistants and conversational interfaces

An assistant accepts natural-language requests and may answer questions, retrieve records, call approved tools, or guide a workflow. A robust assistant has at least six layers:

  1. Interface layer: chat, voice, or embedded help panel.
  2. Conversation layer: session state, turn management, and clarification.
  3. Policy layer: permitted topics, prohibited actions, and escalation rules.
  4. Retrieval or tool layer: access to approved data and operations.
  5. Model layer: language understanding and response generation.
  6. Monitoring layer: logs, feedback, safety events, and performance measures.

The model should not receive unrestricted database access. Instead, the server exposes narrow, typed functions such as findOrder(orderId) or createSupportTicket(summary). Each function validates authorisation and input independently. Important actions—refunds, account changes, deletion, or publication—should require confirmation and may require a human employee.

1.4 Content processing

AI can classify support tickets, extract entities from forms, detect language, translate text, summarise documents, moderate user submissions, and convert speech to text. These tasks vary in risk. A spelling suggestion is usually low risk; automatically rejecting a benefit application is high risk. The level of testing, explanation, human review, and auditability should increase with potential harm.

A useful pipeline is:

ingest → validate → preprocess → analyse → verify → store or present → monitor

Validation includes file-type checking, size limits, malware scanning, character encoding checks, and permission verification. Verification can include confidence thresholds, schema validation, source comparison, and human review. AI output should be treated as untrusted data, not as executable instructions.

2. Integrating AI APIs Professionally

2.1 A reference architecture

A typical application contains a browser client, an application server, an AI provider, and application data stores. The browser sends a narrowly defined request to the server. The server authenticates the user, applies policy, removes or masks unnecessary personal information, calls the provider, validates the response, records suitable telemetry, and returns a safe result.

The provider key must remain on the server. A browser-exposed secret can be copied, abused, and charged to the organisation. The server should also enforce quotas independently of the provider because provider limits do not replace business-level controls.

A minimal server-side sequence is:

  1. Authenticate the user and check authorisation.
  2. Validate request structure, length, type, and permitted content.
  3. Apply rate limits and an estimated budget check.
  4. Minimise, redact, or pseudonymise sensitive data.
  5. Construct a constrained instruction and attach approved context.
  6. Call the provider with a timeout and retry policy.
  7. Validate the response against an expected schema.
  8. Apply moderation, business rules, and confidence or escalation checks.
  9. Return the result with an explanation of limitations where appropriate.
  10. Record non-sensitive operational metrics.

2.2 Structured output and validation

Free-form model output is difficult to integrate safely. If a system requires a list of three topics, the server should request a structured object and validate it with a schema. Validation must check required fields, data types, maximum lengths, allowed enumerations, and business constraints. A valid JSON document can still contain false or unsafe claims, so syntactic validation is necessary but insufficient.

For example, a course assistant might require:

{
  "answer": "string",
  "sources": ["string"],
  "needsHumanReview": true
}

The server must reject unexpected fields if they create risk, escape output before displaying it as HTML, and never interpret model-generated text as SQL, shell commands, HTML, or application permissions.

2.3 Reliability and failure handling

AI providers can be unavailable, slow, inconsistent, or temporarily rate-limited. A production application therefore needs a timeout, bounded retries with backoff, a fallback response, and an incident log. Retrying every failure can increase cost and overload the provider. Retries are appropriate mainly for transient failures, not for invalid requests or rejected content.

The user interface should distinguish “the system does not know” from “the service is temporarily unavailable.” It should preserve the user’s work, avoid duplicate side effects, and offer a non-AI path. For a customer-support assistant, that path may be a searchable help centre or a human support form.

2.4 Cost and capacity planning

AI cost is commonly related to input and output tokens, requests, selected model, and additional tools. A simplified estimate is:

Estimated cost = (input tokens ÷ 1,000,000 × input price) + (output tokens ÷ 1,000,000 × output price)

This expression assumes that prices are specified per million tokens and excludes other platform charges. If 10,000 requests each use 800 input tokens and 300 output tokens, monthly usage is 8,000,000 input tokens and 3,000,000 output tokens. With prices of $1.00 per million input tokens and $3.00 per million output tokens, the estimated model cost is $8 + $9 = $17, before hosting and storage.

Actual billing rules differ among providers, so the provider’s current pricing documentation must be checked. Costs can be controlled by limiting context length, summarising old conversation turns, caching stable results, selecting a smaller model for simple tasks, batching offline work, and imposing per-user quotas. Cost dashboards should show usage by feature, tenant, and environment.

3. Privacy, Security, Ethics, and Human Oversight

3.1 Data protection by design

Before sending information to an external service, identify what data is collected, why it is needed, where it is processed, how long it is retained, and who can access it. Data minimisation means sending the least information necessary for the stated task. A support ticket may need the product category and error message but not a customer’s full identity number.

Common controls include encryption in transit and at rest, access control, secrets management, retention limits, audit logs, deletion procedures, and a documented processor agreement where required. Consent is not a universal solution: it must be informed, specific, freely given where applicable, and capable of withdrawal. Organisations must also respect applicable privacy and data-protection law, sector rules, contractual duties, and cross-border transfer requirements.

3.2 Threats specific to AI applications

  • Prompt injection: untrusted text attempts to override system instructions.
  • Data leakage: confidential information appears in prompts, outputs, logs, or training processes.
  • Model manipulation: malicious users exploit weaknesses in classification or moderation.
  • Insecure tool use: generated arguments cause unauthorised actions.
  • Denial of wallet: excessive requests create unexpected provider charges.
  • Overreliance: users accept a fluent but inaccurate answer.
  • Supply-chain risk: an external model, package, or data source changes behaviour.

Defences include separating instructions from retrieved content, least-privilege tools, output encoding, allow-lists, sandboxing, human confirmation, rate limits, red-team testing, and continuous monitoring. No single prompt can provide a complete security boundary.

3.3 Fairness, accessibility, and transparency

AI systems can perform differently across languages, dialects, disability-related communication, demographic groups, and unusual cases. Testing should use representative cases and report error patterns, not merely an average score. Where automated decisions affect people significantly, users should receive understandable information about the process, an opportunity to challenge an outcome, and access to human review where required by policy or law.

Accessibility remains a web responsibility even when AI is present. A conversational interface should have keyboard support, readable contrast, screen-reader labels, text alternatives for voice interaction, clear focus order, and a non-conversational route to essential functions. The system should identify AI-generated assistance honestly and avoid implying human understanding where none exists.

4. A Practical Evaluation Framework

A useful evaluation considers five dimensions:

DimensionQuestionsExample measures
UtilityDoes the feature solve the intended user problem?Task completion, satisfaction
QualityAre results relevant and accurate?Precision, recall, factual review
ReliabilityDoes it behave acceptably under failure?Error rate, latency, uptime
SafetyCan it cause or enable harm?Policy violations, escalation rate
SustainabilityIs it affordable and maintainable?Cost per task, energy and support effort

Evaluation should occur before, during, and after deployment. Offline test sets help compare versions. Pilot releases and feature flags limit exposure. Production monitoring detects distribution changes, provider changes, and new attack patterns. A useful acceptance criterion is measurable and tied to a user task—for example, “At least 90% of reviewed answers cite an approved source and fewer than 2% contain a material unsupported claim.” The sample, review method, time period, and definition of “material” must be documented.

5. Emerging Web Trends

5.1 Progressive web applications

A PWA is a web application enhanced with capabilities such as installability, offline behaviour, background processing, and push notifications. A service worker can intercept requests and serve cached assets, while a web app manifest describes the application’s name, icons, and display mode.

PWAs are valuable when users need intermittent connectivity, quick repeat access, or a single cross-platform codebase. They are not automatically equivalent to native applications. Browser support, operating-system restrictions, notification policies, storage limits, and device integration must be tested on the target platforms. A sound offline strategy identifies which data may be cached, how stale data is labelled, how synchronisation conflicts are resolved, and how private data is protected on a shared device.

5.2 Edge computing

Edge computing moves selected computation and content closer to users, often through distributed points of presence. It can reduce network round-trip time and support location-aware processing. Suitable tasks include static delivery, authentication checks, lightweight personalisation, request routing, and some media or data transformations.

Edge deployment also introduces challenges: distributed debugging, limited runtimes, data consistency, regional processing rules, cold starts, and vendor dependence. Sensitive AI inference should not be moved to the edge merely because it is fashionable. The decision should compare latency benefit, privacy requirements, operational complexity, and cost.

5.3 WebAssembly

WebAssembly (Wasm) is a portable binary instruction format that runs in a sandboxed environment. It can bring performance-sensitive modules written in languages such as Rust, C, or C++ to the browser or server. Examples include image processing, audio analysis, scientific computation, and local machine-learning inference.

Wasm is not a replacement for JavaScript or a guarantee of security. Applications still need permission controls, memory-safety practices in source languages, input validation, and performance testing. Download size, startup time, interoperability, debugging, and browser capability are practical considerations. Local inference can improve privacy by keeping data on the device, but it may increase battery use and require a suitable model.

5.4 Low-code and no-code development

Low-code platforms can accelerate forms, workflows, dashboards, and integrations. They are useful for prototypes, internal tools, and standard business processes. However, visual development does not eliminate requirements analysis, testing, security, accessibility, data governance, or version control. Organisations should assess exportability, integration limits, licensing, auditability, identity management, and vendor lock-in.

Professional developers increasingly work as platform evaluators, integrators, reviewers, and maintainers. The correct question is not whether low-code is “good” or “bad,” but which components can be delegated safely and which require custom engineering.

6. Illustrative Case Study: CampusHelp AI

Background

CampusHelp is an illustrative case involving a college help portal. Students previously searched separate pages for fees, timetables, library rules, and technical support. The college proposed an assistant that could answer questions from approved documents and create a support ticket when necessary.

Problem analysis

The initial proposal—“connect a chatbot to all college data”—was rejected because it lacked permission boundaries, source control, and an escalation process. The team identified three lower-risk tasks: document search, frequently asked questions, and ticket drafting. It excluded final decisions about disciplinary matters, fee waivers, and academic progression.

Approach and solution

The team created a document catalogue containing title, owner, effective date, review date, audience, and access classification. A retrieval service returned passages only from documents authorised for the current student. The assistant received those passages and was instructed to answer only from them, cite document titles, and say when evidence was insufficient.

The server validated message length, applied per-user rate limits, removed unnecessary personal information, and stored only operational logs. Ticket creation used a typed server function. Before submission, the student saw the proposed category and summary and had to confirm. High-risk topics were routed to staff.

The team tested 200 representative questions: 120 answerable questions, 40 unanswerable questions, and 40 adversarial or ambiguous questions. Reviewers assessed citation correctness, answer usefulness, privacy violations, and escalation behaviour. The system was released to a small pilot with a visible feedback control and a non-AI search link.

Outcome

The pilot reduced time spent locating common information and exposed weaknesses in outdated documents. Several apparently “AI errors” were actually content-governance failures: pages had conflicting dates or no named owner. The college therefore introduced document review reminders and ownership responsibilities. The assistant was retained for low-risk guidance, while staff continued to handle exceptions and consequential decisions.

Learning points

  1. Retrieval quality depends on source quality and access metadata.
  2. Narrow tools are safer than unrestricted system access.
  3. Human review is a design feature, not merely a fallback.
  4. Evaluation must include unanswerable and adversarial questions.
  5. Governance of content is as important as model selection.

7. Professional Practice and Future Skills

A modern full-stack developer should be able to read an API contract, protect secrets, design a database schema, write automated tests, use version control, and deploy observable services. AI-enabled work adds prompt and context design, structured output validation, evaluation-set construction, data classification, model-risk thinking, and cost monitoring.

Teams should maintain a decision record explaining why a model or platform was selected, what data it receives, which tasks it may perform, and when a human must intervene. They should define ownership for incidents, model updates, provider changes, data deletion, and user complaints. Continuous learning is essential because APIs, regulations, browser capabilities, and attack techniques evolve.

The most durable principle is technology neutrality: start with a user problem and measurable requirement, then choose the simplest dependable mechanism. A conventional search index may be better than a generative model; a responsive website may be better than a PWA; server-side processing may be safer than edge execution. Emerging technology is valuable when it improves the system’s outcomes, not merely because it is new.

Chapter Summary

AI-enabled web applications include intelligent search, recommendation, conversational assistance, and content processing. Each feature combines user-interface design, data management, application logic, and probabilistic services. Retrieval should be separated from generation, tools should be narrowly authorised, and outputs should be validated as untrusted data.

Professional API integration requires server-side secret management, input and output validation, rate limiting, timeouts, bounded retries, fallback paths, monitoring, and cost estimation. Privacy requires data minimisation, appropriate retention, access control, and awareness of legal and contractual duties. Ethical design includes fairness testing, accessibility, transparency, user control, and human review for consequential decisions.

PWAs support installability and offline experiences; edge computing can reduce latency; WebAssembly supports portable high-performance modules; and low-code tools accelerate suitable workflows. Each introduces trade-offs involving security, governance, support, portability, performance, and cost. Effective developers evaluate these technologies against real requirements and measurable outcomes.

Key Terms

Artificial intelligence: Software that performs tasks commonly associated with human intelligence.

Semantic retrieval: Finding information by conceptual similarity rather than exact word matching.

Retrieval-augmented generation: Generating an answer using information retrieved from approved sources.

Recommendation system: Software that proposes items, content, or actions to a user.

Collaborative filtering: Recommendation based on interaction patterns among users and items.

Assistant: An interface that interprets requests and may provide information or perform approved actions.

Structured output: A response conforming to a defined schema and data format.

Prompt injection: An attempt to manipulate an AI system through untrusted instructions in input data.

Human oversight: Review, intervention, or approval by a person responsible for an automated process.

Data minimisation: Collecting and processing only the information necessary for a stated purpose.

Rate limiting: Restricting request frequency to protect services and control cost.

Precision: The proportion of retrieved results that are relevant.

Recall: The proportion of relevant results that are retrieved.

Progressive web application: A web application enhanced with installability, caching, and related platform capabilities.

Service worker: A browser-managed script that can intercept requests and support caching or background tasks.

Edge computing: Processing data closer to users or devices rather than only in a central location.

WebAssembly: A portable binary instruction format for executing compiled code in a web environment.

Low-code development: Building applications with substantial use of visual configuration and prebuilt components.

Model drift: A change in system performance caused by changing data, behaviour, or operating conditions.

Observability: The ability to understand system behaviour through logs, metrics, traces, and feedback.

Review Questions

Short Answer Questions

  1. What is the difference between lexical retrieval and semantic retrieval?
  2. Why should an AI provider key not be placed in browser-side JavaScript?
  3. State two controls that can reduce unexpected AI API costs.
  4. What is the purpose of a service worker in a PWA?
  5. Why should AI output be treated as untrusted data?

Long Answer Questions

  1. Explain a secure architecture for integrating an AI assistant into a full-stack web application.
  2. Compare popularity-based, content-based, collaborative, and hybrid recommendation systems.
  3. Discuss privacy, fairness, accessibility, and human oversight in AI-enabled applications.
  4. Compare PWAs, edge computing, WebAssembly, and low-code tools, including an appropriate use case and limitation for each.
  5. Explain how an organisation should evaluate an AI feature before and after deployment.

Analytical / Application Questions

  1. Design a retrieval-based assistant for a college library. Specify its data sources, permission controls, fallback behaviour, evaluation measures, and human-escalation rules.
  2. A support application receives 20,000 monthly requests, each using 600 input tokens and 250 output tokens. Using input pricing of $1.00 per million tokens and output pricing of $3.00 per million tokens, calculate the estimated model cost before other charges. State the assumptions in your calculation.
  3. A recommendation system increases clicks but produces less diverse results and disadvantages new items. Analyse possible causes and propose technical, product, and governance changes.

Multiple Choice Questions with Answers

Question 1

Which approach most directly reduces unsupported answers in a document-based assistant?

A. Allowing the model unrestricted database access

B. Retrieving authorised source passages and requiring citations

C. Increasing the interface animation speed

D. Removing all user feedback controls

Correct Answer: B. Retrieving authorised source passages and requiring citations

Question 2

Where should an AI provider secret normally be stored in a web application?

A. In public browser JavaScript

B. In a URL query string

C. On a protected server-side environment

D. Inside an HTML comment

Correct Answer: C. On a protected server-side environment

Question 3

What does recall measure in the chapter’s search framework?

A. The proportion of retrieved items that are relevant

B. The proportion of relevant items that were retrieved

C. The average response time of a search

D. The cost of each search request

Correct Answer: B. The proportion of relevant items that were retrieved

Question 4

Which control is most appropriate before an assistant performs an irreversible account action?

A. Human confirmation and server-side authorisation

B. Increasing the model temperature

C. Removing input validation

D. Caching the action indefinitely

Correct Answer: A. Human confirmation and server-side authorisation

Question 5

If a system uses 8,000,000 input tokens at $1 per million and 3,000,000 output tokens at $3 per million, what is the estimated model cost?

A. $11

B. $14

C. $17

D. $24

Correct Answer: C. $17

Question 6

What is a principal purpose of a service worker?

A. To replace all server databases

B. To intercept requests and support caching or background behaviour

C. To expose provider secrets to users

D. To guarantee native-app feature parity

Correct Answer: B. To intercept requests and support caching or background behaviour

Question 7

Which situation best illustrates prompt injection?

A. A user changes the browser window size

B. Untrusted retrieved text attempts to override the assistant’s instructions

C. A server rejects an invalid JSON response

D. A developer updates a CSS stylesheet

Correct Answer: B. Untrusted retrieved text attempts to override the assistant’s instructions

Question 8

What is a major advantage of edge computing?

A. It always eliminates data-protection obligations

B. It can reduce latency by processing nearer to users

C. It guarantees unlimited storage

D. It removes the need for monitoring

Correct Answer: B. It can reduce latency by processing nearer to users

Question 9

Which statement about WebAssembly is correct?

A. It is a portable binary format that can support performance-sensitive modules

B. It is an encryption algorithm for passwords

C. It automatically makes every application secure

D. It is a replacement for all web standards

Correct Answer: A. It is a portable binary format that can support performance-sensitive modules

Question 10

Why should recommendation quality not be judged only by click-through rate?

A. Clicks can never be measured

B. Clicks may increase through misleading or narrow recommendations

C. Recommendations do not affect user experience

D. Click-through rate measures database storage

Correct Answer: B. Clicks may increase through misleading or narrow recommendations

Case studies and Mini Project on Web App Development
Chapter 14 of 15