The Building Blocks of an AI Application
An AI application is software that uses an AI model as one part of a larger system. The model writes the answers, but other parts do everything around it: the frontend people use, the backend that holds the rules and keys, a database that remembers, sometimes retrieval over documents, and security and monitoring that keep it safe and working. Most of the work of building an AI product is in these parts, not in the model.
This chapter builds one complete example: an AI Learning Assistant that explains topics at three levels of difficulty and quizzes the learner.
The Building Blocks
| Block | Description |
|---|---|
| Frontend | It is used for what people see and touch: a web page or mobile app |
| Backend | It is used to hold the rules, check requests, keep the API key and call the model |
| Model API | It is used to generate the answers (see "Calling a Model API") |
| Database | It is used to remember users, questions, answers, ratings and costs |
| Retrieval (if needed) | It is used to answer from your own documents (see "What Is RAG") |
| Security | It is used to check who someone is (authentication) and what they may do (authorization) |
| Monitoring | It is used to watch errors, response time, cost and ratings in real use |
Following One Request
- A student types "photosynthesis" and chooses beginner in the frontend.
- The frontend sends the request to the backend, never straight to the model.
- The backend checks the student is signed in and the request is valid.
- It calls the model API, using a key that only the server knows.
- It saves the question, answer, tokens and time in the database.
- The answer goes back to the frontend and is displayed.
The Seven-Step Method
| Step | Question it answers |
|---|---|
| 1. Define the problem | What is hard for whom, and why does it matter? |
| 2. Define the solution | What will the AI do about it, and what won't it do? |
| 3. Identify users | Who exactly will use it? |
| 4. Define features | What must the first version do, and what can wait? |
| 5. Choose the architecture | Which building blocks, connected how? |
| 6. Evaluate | Is it accurate, fast, affordable and useful? |
| 7. Improve | What do feedback and measurements say to change next? |
Common Mistakes
Calling the model from the browser. It exposes your key and your prompts; always go through a backend.
Skipping the database. Without stored questions, answers and ratings, you can't measure or improve anything.
Treating security as a later step. Decide who may use the app, and what each person may see, from the start.
Interview Corner
What are the main building blocks of an AI application?
A frontend, a backend, a model API, a database, optionally retrieval, plus security (authentication and authorization) and monitoring. The model is one block; the system around it makes it a product.
Why should the backend, not the frontend, call the model?
To keep the API key, prompts and business rules private and enforceable, and to validate, log and limit every request in one place.
Practice
Exercise: map an AI app you use. Pick an AI feature in an app you know, such as a writing assistant or a support chat. Sketch its likely building blocks: what does the frontend do, what must the backend check, and what would it store?
Check your understanding:
- What does the backend do that the frontend mustn't?
- What is the difference between authentication and authorization?
- Why does the app need a database?
Key Takeaways
Quick reference
| Block | Holds |
|---|---|
| Frontend | The screen |
| Backend | Rules, key, model calls |
| Database | History and ratings |
| Monitoring | Errors, speed, cost |
Was this tutorial helpful?