Finish and deploy a small app that calls a model API from a server, keeping the key on the server.
An app that only runs on your own laptop is no use to anyone else. To finish the module, you complete the app described in your spec and put it on the internet, with the API key kept as a secret. You also add limits that protect your budget and watch two real people try it.
Priya built a feedback summariser for her team leads. It ran perfectly on her laptop for a week, but her team leads could not use it because it existed only on her laptop.
Your app has to meet five conditions. It does the job in your spec and is deployed. It calls a model API from a server. The API key is set as a secret on the hosting service and never appears in the code or the browser. The app has basic limits that stop a single user from running up the bill. Two people other than you have used it, and you have written down where they got stuck and what you changed.
You need the spec from lesson 6.2, the committed code from lesson 6.3 and the bug log from lesson 6.4. Allow about 90 minutes, or longer if this is your first deployment.
Start by listing the features in your spec that are still to build. Build them one at a time, using this module's habits: run the app after each feature, and commit after each one.
When the spec is finished, stop. Leave the later-features list from lesson 6.1, "Pick a project small enough to finish", alone for now. Every extra feature delays the moment real people use the app, and their reactions will reorder that list anyway.
Choose a hosting service that supports your stack. Many offer free tiers suitable for a small app, and your coding assistant can tell you which ones fit the framework you used. Most hosting services connect to your code repository and deploy automatically every time you push a commit.
Before you push, check one last time that the env file is not in the repository. Then push the code to a private repository on a code hosting service, and connect that repository to the hosting service.
Every hosting service has a settings page for environment variables or secrets. Add the API key there. The variable name must match exactly the name your code reads, for example MODEL_API_KEY. The code is the same on your laptop and on the server. Only the value it is given changes, as lesson 1.2 described.
Once the app has deployed, open it and test it. Then open the browser's developer tools, look through the page sources and the network tab, and confirm the key appears nowhere. Lesson 8.4 covers this check in more depth, but do it now as well.
A public link can be shared further than you intended, so the app needs two limits. Both must go on the server, where users cannot get around them.
The first is a maximum input length. Set it from what normal use looks like, with room to spare, and reject longer requests with a clear message. Priya's server rejects any request over 50 feedback items or 20,000 characters in total, and shows a clear message saying so.
The second is a cap on requests per user. If your app has no user accounts, you can limit by IP address, for example a few requests per minute plus a set number per day. Many hosting services and frameworks have rate limiting built in or available as a small add-on, and your assistant can tell you what fits your stack. When a user hits the limit, show a message saying when they can try again.
Keep the monthly spending limit you set on the provider account in lesson 1.1. The limits in your code stop ordinary overuse, and the provider's spending limit is the last line of defence if everything else fails.
Choose two testers who match the user described in your spec. Send them the link and one sentence about what the app does, and explain nothing more. Watch them use it, in person or by screen share, and say nothing unless they are completely stuck. Write down every moment they hesitate, misread something or do something you did not expect.
Priya's first tester pasted a whole email thread, greetings and signatures included, and got result rows for "Hi team" and "Best regards". Her second tester did not notice that the results table had appeared below the fold and pressed submit three times.
From your notes, pick the three biggest problems and fix them. Priya added a line under the text box saying "One piece of feedback per line". She made the page scroll to the results, and she disabled the button while a request is running.
a link to a working app on the internet the code in a git repository, with the key stored only as a secret on the hosting service input-length and per-user limits on the server, both tested by trying to exceed them a short note listing three things your testers struggled with and what you changed for each
That note is the start of version two.
Deploy your app and send the link to two testers. Write down three things they struggled with and what you changed for each.
Junxiong-WFG Organisation is an authorised representative of AIA Financial Advisers Private Limited (Reg. No. 201715016G).