AI Engineering and Data Analysis · Course book
Chapter 1: From Software to AI Applications
Building an application that uses artificial intelligence is, first of all, building software. The AI part may be a model that writes text, recognises images or answers questions, but it sits inside an ordinary program that has to take input, call services, store data, handle errors and run reliably for real users. This chapter starts from that foundation. It explains how software is planned and built and who does what, how applications are structured, what artificial intelligence, machine learning and generative AI actually are, how prompts are written so that a language model does what you intend, and how a small AI-powered web application fits together using Python and Flask. A worked example estimates how much text a model can read at once, a practical limit every AI application runs into.
How software gets built
Professional software is produced through a software development life cycle, a sequence of activities that turns an idea into a working, maintained product. The exact names vary, but the stages are recognisable in every team: understanding what is needed, designing a solution, writing the code, testing it, releasing it, and maintaining it afterwards. Traditional teams pass through these stages once, in order; agile teams cycle through all of them every few weeks, delivering a little more each time.
| Stage | Main question | Typical roles |
|---|---|---|
| Requirements | What problem are we solving, and for whom? | Product manager, business analyst |
| Design | How will the system be structured and look? | Software architect, UX designer |
| Development | How do we build each part correctly? | Front-end, back-end and full-stack developers |
| Testing | Does it work, and does it keep working after changes? | Quality assurance engineers, developers |
| Deployment | How does it reach users safely? | DevOps and site reliability engineers |
| Maintenance | How do we fix, secure and improve it over time? | The whole team |
Developers rely on a common toolkit: a code editor or integrated development environment, a version control system such as Git to track every change and let many people work on the same code, package managers to install libraries, and build and testing tools that run automatically whenever code changes. Programming languages are chosen to suit the job. JavaScript dominates in web browsers, Python is the leading language for data and AI work thanks to its huge library ecosystem, and languages such as Java, C# and Go are common for large back-end systems. Whatever the language, the same building blocks appear: variables, conditions, loops, functions and data structures.
Testing happens at several levels. Unit tests check a single function in isolation, integration tests check that components work together, and end-to-end tests drive the whole application as a user would. Automated tests run every time code changes, so a mistake introduced on Tuesday is caught on Tuesday rather than discovered by a customer weeks later. For AI features, tests are joined by evaluation sets of example inputs with known good outputs.
Applications are organised by an architecture. A common pattern separates a presentation layer, the screens users see, from a business logic layer that applies the rules, and a data layer that stores information. Larger systems may be split into microservices, small independent services that each do one job and talk to each other through APIs, so that each can be updated and scaled separately. An AI feature usually becomes one more service in that picture, called by the rest of the application when it needs a prediction or a piece of generated text.
What AI, machine learning and generative AI mean
Artificial intelligence is the broad goal of making computers perform tasks that normally need human intelligence, such as understanding language, recognising images or making decisions. Early AI systems followed rules written by hand. Machine learning is the approach that now dominates: instead of writing rules, you give the computer many examples and let it learn the patterns itself. A spam filter trained on thousands of labelled emails learns which features suggest spam without anyone listing them.
Deep learning is machine learning with artificial neural networks of many layers, which can learn very complex patterns from raw data such as pixels, sound waves or text. It powers modern speech recognition, translation and image recognition. Generative AI is a family of deep learning models that create new content, text, images, audio or code, rather than only classifying existing data. Large language models, which predict text one piece at a time after training on enormous amounts of writing, are the best-known example.
AI is used in almost every industry: detecting fraudulent transactions in banking, forecasting demand in retail, reading medical scans, routing deliveries and answering customer questions. Its use also raises genuine concerns. Models can reproduce biases present in their training data, can produce confident but false statements, and can expose private information if they are given it carelessly. Responsible teams test for these problems, keep people involved in important decisions and are open with users about when AI is being used.
Prompt engineering
A language model's output depends heavily on its input, the prompt. Prompt engineering is the practice of writing prompts that produce reliable, useful results. A few techniques make a large difference. Give the model a role and context: who it is acting as and who the answer is for. State the task and the format precisely, such as "three bullet points of no more than 20 words each". Provide examples of good answers when the format matters, an approach called few-shot prompting. For problems that need reasoning, ask the model to work through the steps before giving its final answer. And set constraints: what to do if the information is missing, which sources to use, what to avoid.
You are a helpful assistant for a hardware shop.
Summarise the customer review below for the store manager.
Return exactly three bullet points: what they liked, what they
disliked, and one suggested action. If the review does not
mention a point, write "not mentioned".
Review: """The drill arrived quickly and works well, but the
battery lasts barely 20 minutes and the case broke on day two."""
Image generators respond to the same discipline. A prompt for a text-to-image model works best when it names the subject, the setting, the style, the lighting and the composition, rather than a single vague phrase.
Building an AI-powered web application
A small AI application often has three parts: a web page where the user types or uploads something, a back-end written in Python using a lightweight framework such as Flask, and a model, either called through a provider's API or run locally from an open-source library. Flask maps web addresses to Python functions: a route such as /summarise receives the user's text, sends it to the model with a carefully written prompt, and returns the result to the page. Packaging the code with its dependencies listed, and deploying it to a server or container platform, turns a script into a service others can use.
The same pattern produces many useful tools: captioning photos, a chatbot, a voice assistant that turns speech to text and back, a meeting summariser, a translation helper or a coach that gives feedback on job applications. Each is mostly ordinary software around a single model call, which is why software engineering skills matter so much in AI work. Every such application must also respect a practical limit: a model can only read a fixed amount of text at once, its context window, measured in tokens, which are word pieces.
Generative AI also changes how software itself is written. Coding assistants can suggest functions, explain unfamiliar code, write tests and point out security problems. They speed up routine work, but their suggestions can be wrong or insecure, so developers still review and test everything they accept, exactly as they would code written by a colleague.
Check your understanding
- List the six stages of the software development life cycle and one role involved in each.
- Explain the difference between machine learning and deep learning, with an example of each.
- Rewrite the vague prompt "Tell me about this product" so that it states a role, a task, a format and a constraint.
- A report has 15,000 words. Estimate its length in tokens, and how many chunks it needs if each chunk can hold 6,000 tokens.
- Describe what happens, step by step, when a user submits text to a Flask summarising app.
- Give two risks of using generative AI in an application and how a team could reduce each.
This course book is available to read online only at chrysolites.org.