Lesson 8: Where does application data live?
The everyday picture
Think of a shop. Notes on the shopkeeper's hand are gone when they wash (memory). The customer's own loyalty card stays in their wallet (browser storage). The ledger in the safe is the official record (database). The stockroom holds the boxes and goods (file storage). The bank handles the money (external services).
What it really is
| Where | What goes there | How long it lasts | Who can see it |
|---|---|---|---|
| Browser storage (cookies, localStorage) | login session, preferences, a cart in progress | until the user clears it; only on that device | that user's browser |
| App memory | data being worked on right now | gone when the app restarts | the running program |
| Database | customers, orders, bookings, users | permanent, backed up | your app, through its rules |
| File/object storage | photos, PDFs, videos, uploads | permanent | your app, by link or permission |
| External services | payments (Razorpay, Stripe), emails, logins | in their systems | that provider |
Follow one photo upload: the user picks a photo in the browser → it travels over HTTPS to your server, which briefly holds it in memory → the photo is saved to file storage → a row in the database records "this photo belongs to this customer, stored here".
What it means for your idea
For every piece of information in your idea, ask three questions: Who needs to see it? How long must it last? How private is it? That tells you where it belongs. Two firm rules: - Never store passwords as they are; store a scrambled version (a "hash"). Lesson 10's AI should know this too. - Never store card details yourself; let the payment provider hold them. In India, personal data is also covered by the Digital Personal Data Protection Act, 2023, so collect only what you need.
Pick this when...
- Database: anything that must be permanent and shared across users.
- Browser storage: small, personal, non-sensitive things for one user.
- File storage: anything that is a file, not a record.
- External service: money, email delivery and anything regulated that experts do better.
Quick check
A customer's booking disappears when they switch from phone to laptop. Where was it probably stored? In browser storage on the phone, instead of in the database.
Goes deeper in Modules 51–62, 77, 79.