SyntaxPilot
Courses/Vibe Coding/Lesson 34
Video coming soonThis lesson’s video is being made

Start with the notes below; the video appears here as soon as it is on YouTube.

Vibe Coding · Lesson 34 of 40

Data privacy basics for your app

personal datawhat to collect and not collectconsentprivacy policydeleting user dataIndia's DPDP Act in plain wordssecrets and logs

Vibe Coding: build real apps with AI · Episode 34. Every agent run below is real: Claude Code 2.1.322 (model claude-opus-5-5) in print mode (claude -p --permission-mode acceptEdits), on 12 November 2026, in /home/asha/projects/canteen. Every browser test (Playwright Chromium), curl, sqlite3 and strings check was run by us.

What was written by hand: the canteen app (episodes 31-33) was written for these videos. Neha, Arjun and Asha are fictional; 98765 43210 and 91234 56780 are made-up numbers. The "obvious logger" below is our own example, not the AI's code.

Not legal advice. This is a plain-words introduction for builders. For a real product, read the Act and Rules yourself or ask a lawyer.

Sources for the law (fetched 12 Nov 2026): the Digital Personal Data Protection Act, 2023, sections 2 and 6 (text as published at dpdpa.com); PIB press release of 14 Nov 2025 on the DPDP Rules, 2025; commencement summaries by The Privacy Labs (8 Oct 2026) and MirvoLegal (Sep 2026); the Cyril Amarchand Mangaldas DPDPA FAQ (Dec 2025) for the 72-hour report. Dates can change: check the official Gazette and meity.gov.in.

The problem: the school library register

The library register has your name, class, the book and the date: exactly what the library needs. It doesn't ask for your home address or your father's salary. When every book is back at year end, the pages are torn out.

The library register Your app's database
Name, class, book, date Collect less: only what the feature needs
Not your address or salary Don't collect: no box without a reason
Pages torn out at year end Delete on time: when the purpose is done

Aunty wants phone numbers (real)

$ claude -p "Aunty wants to send each student a WhatsApp message when their order is ready. Add a phone number box to the order page and save the number with the order. Also add request logging to a file, logs/requests.log, so we can debug problems at the counter."
Edit   src/db/schema.js       + orders.phone, upgrade() for the old db
Edit   src/routes/orders.js   accepts 98765 43210, +91-..., saves 10 digits
Edit   public/index.html      "WhatsApp number (optional)"
Write  test/phone.test.js, test/requestLog.test.js
Bash   npm test               # tests 16  pass 16   · commit
Reply: "The page remembers it on the phone, the same way it
   remembers name and class."
 "It doesn't record names, phone numbers, the staff PIN or request
   contents ... a log file gets copied around when people debug."
 "the school may want parents to agree before aunty starts
   messaging them."

Good instincts (a clean log, a hint about parents), and one dangerous line: it remembers it on the phone.

The AI mistake: the next student sees it all (real)

Neha (wrist in plaster, episode 33) orders from the library computer. Then the next student opens the page on the same computer:

Neha types: Neha Joshi · 9A · 98765 43210 -> Order #24 placed
next student sees: {"name":"Neha Joshi","class":"9A",
                    "phone":"98765 43210"}
localStorage: {"canteen.phone":"98765 43210",
               "canteen.student":"Neha Joshi","canteen.class":"9A"}

$ sqlite3 canteen.db "SELECT id, student, phone FROM orders ..."
24|Neha Joshi (9A)|9876543210        # kept... for how long? forever
  • localStorage (browser storage) keeps data on that browser for whoever uses it next. A "remember me" built for a personal phone breaks on a shared computer.
  • The number stays in the database forever, though aunty needs it for ten minutes.

Personal data in plain words

  • The DPDP Act, section 2(t): personal data is "any data about an individual who is identifiable by or in relation to such data". In plain words: anything you can tie back to a person.
  • Examples: name + class, phone number, face photo, location, order history.
  • Every copy is a separate risk: database, browser storage, log files, backups, screenshots, exports.
  • Our students are under 18: the Act calls them children (section 2(f)), with extra protection.
  • Privacy = people decide who knows what about them.

Logs and secrets (real)

A log is a file where the app writes a line for each event so you can debug later. Our example of the obvious logger writes everything:

// OUR example of the obvious logger (not the AI's code)
app.use((req, res, next) => {
  appendFileSync("naive.log", `${new Date().toISOString()} ${req.method}
    ${req.url} ${JSON.stringify(req.headers)} ${JSON.stringify(req.body)}\n`);
  next();
});
$ cat naive.log
... PATCH /api/menu/2 {"host":"localhost:4100", ... "x-staff-pin":"482913", ...}
... POST /api/orders {...} {"student":"Neha Joshi (9A)",
                           "phone":"98765 43210","whatsapp_ok":true, ...}

The staff PIN (a secret) and Neha's number are now in a file that people paste into AI chats and WhatsApp groups when something breaks. The AI's logger writes only method, path, status and time:

2026-11-12T20:04:54.153Z DELETE /api/orders/27/phone 200 2ms
$ grep -cE "98765|9876543210|482913" logs/requests.log
0

Before you add a box: four questions

  1. What is it for? The purpose in one sentence: "to message you when your order is ready".
  2. Do we need it? The notice-board screen could show "Order #24 is ready" with no phone at all. Collecting the least you can is data minimisation.
  3. How long? Until the order is collected (retention: how long you keep data).
  4. Who sees it? Canteen staff only.

Data you never collect can never leak.

Consent is a person's clear yes, to one specific purpose. The Act, section 6(1): consent must be "free, specific, informed, unconditional and unambiguous with a clear affirmative action", limited to the data needed for that purpose. Section 6(4): the person can withdraw it "at any time", with "the ease of doing so being comparable to the ease with which such consent was given".

Counts Doesn't count
An unticked box the student ticks: "Yes, send me a WhatsApp message when my order is ready" A box that comes already ticked
One purpose, said in plain words "By using this app you agree to everything"
"Don't message me: delete my number" one tap away "No number, no samosa" (not free)

For a child (under 18), the Act requires verifiable consent of a parent or lawful guardian.

The fix prompt (real)

claude -p "Privacy problems with the phone numbers. Our students are under 18.
1. I ordered as 'Neha Joshi, 9A, 98765 43210' on a library computer.
   The next student who opened the page saw Neha's name, class AND
   phone number already filled in (localStorage).
2. Phone numbers stay in canteen.db forever, but aunty only needs them
   until the order is collected.
3. The page doesn't say why we want the number or let a student
   change their mind.
Fix it: only remember details on a device if the student ticks 'Remember
me on this device' (unticked by default). Phone stays optional, with one
plain sentence saying what it's for, and an unticked checkbox to agree to
the WhatsApp message. Delete phone numbers at the end of each day (India
time). Let a student remove their number from today's order. Keep the
request log free of personal data."

Its answer (extracts), 20/20 tests passing:

  • "The phone number is never saved on the device." Name and class only with "Remember me" ticked; old saved details are cleared on first load.
  • "The server deletes earlier days' numbers when it starts, every 10 minutes, and before every API request."
  • "I also set the database to overwrite deleted data ... Copies or backups of the file made before today still contain them."
  • "Asking for the phone number means nobody can remove someone else's." (new DELETE /api/orders/:id/phone)
  • "if a web address ever contains something that looks like a phone number, it's logged as [path hidden]"

The new form shows: WhatsApp number (optional) · "Only used to message you when your order is ready, and deleted at the end of the day." · an unticked consent box · an unticked Remember me on this device with "Leave it unticked on a shared or library computer." That sentence at the moment of asking is a privacy notice.

Our checks: deleting for real (real)

# 1. the next student, same computer
next student sees: {"name":"","class":"","phone":""}   localStorage: {}

# 2. an old order from yesterday, then restart the server
25|Arjun 10A|9123456780|2026-11-11T05:00:00.000Z
$ strings canteen.db | grep -c 9123456780      ->  1
  ... restart ...
25|Arjun 10A||2026-11-11T05:00:00.000Z           # number gone
$ strings canteen.db | grep -c 9123456780      ->  0   (secure_delete)

# 3. "remove my number"
DELETE /api/orders/27/phone {"phone":"91234 56780"}
{"error":"No order today with that number and phone."}  404
DELETE /api/orders/27/phone {"phone":"98765 43210"}
{"id":27,"phone_removed":true}  200

Why check the raw bytes? Many databases (SQLite included) only mark deleted rows as free space; the old bytes stay in the file until overwritten. SQLite's PRAGMA secure_delete = ON overwrites them. Backups made earlier still contain the data: plan how long backups are kept, too.

Secrets and logs

A secret gives power to whoever learns it: PINs, passwords, API keys, tokens.

# .env  (in .gitignore: never committed, never pasted)
STAFF_PIN=482913

# .gitignore
node_modules/
canteen.db
.env
logs/
  • Never log: passwords, PINs, tokens, API keys, full request bodies, headers (they carry secrets), personal data.
  • Before pasting a log into an AI chat or a group: grep -nE "[0-9]{10}|PIN|token|key|password" logs/requests.log.
  • canteen.db is in .gitignore: real data never goes to GitHub.

India's DPDP Act in plain words

Term Meaning
DPDP Act, 2023 India's Digital Personal Data Protection Act
Data Principal "the individual to whom the personal data relates" (the student)
Data Fiduciary Whoever "determines the purpose and means of processing" (whoever runs the canteen app)
Child Under 18: verifiable consent of a parent or guardian
Processing Any automated operation on digital personal data (collecting, storing, using, sharing, deleting)
Personal data breach Unauthorised processing or accidental disclosure, loss or sharing that harms confidentiality, integrity or availability

Dates:

  • The DPDP Rules, 2025 were notified on 14 November 2025 with an 18-month phased timeline (PIB).
  • Consent manager registration (Rule 4) starts November 2026.
  • Most duties (Rules 3 and 5-16: notice, consent, security safeguards, breach reporting, erasure, children's data, data principal rights) and the penalty provisions apply from May 2027 (13/14 May depending on how the date is counted).
  • MeitY proposed (Jan 2026) shortening the period to 12 months; our sources (Sep-Oct 2026) found no amendment notified. Check the Gazette.

Duties and rights, in plain words:

  • A clear, standalone notice saying what you collect and why.
  • People can access, correct and erase their data; requests must be answered within 90 days (PIB).
  • After a breach: tell affected people without delay, and send a detailed report to the Data Protection Board within 72 hours (Rules, as summarised in the Cyril Amarchand Mangaldas FAQ).
  • Erase data when the purpose is served or consent is withdrawn (unless a law requires keeping it).
  • Penalties: up to ₹250 crore for failing to keep reasonable security safeguards (PIB); other violations up to ₹200 crore or ₹50 crore.

A one-page privacy notice (our draft)

## Privacy: what we keep and why          (canteen pre-order)

What we collect   your name and class (to hand over your order),
                  your WhatsApp number ONLY if you tick the box
Why               to make and hand over your order; to message you
                  once when it's ready
How long          numbers are deleted at the end of the day; orders
                  (name, class, items) are kept for aunty's accounts
Who sees it       canteen staff only. Never sold, never shared
Your choices      untick the box, or "Don't message me: delete my
                  number" any time today
Questions         Asha, coding club (room 14) · asha@example.com

A privacy policy is the full written version of this promise. If you can't write a line honestly ("we keep numbers forever"), change the app, not the sentence.

Checklist before you ship

  • [ ] Every personal field has a purpose in one sentence, or it goes.
  • [ ] Consent: an unticked box, one purpose, as easy to undo as to give.
  • [ ] Under 18? A parent's or guardian's consent (DPDP).
  • [ ] Delete on a schedule; check the file, not just the table; remember backups.
  • [ ] Test on a shared computer: what does the next person see?
  • [ ] Logs: no secrets, headers, bodies or personal data.
  • [ ] A plain-words privacy notice and a contact for requests.

Common mistakes (real)

Mistake What we saw Why Fix
Remember me by default (the AI's) next student sees "phone":"98765 43210" Shared computer Opt-in, never the phone
Numbers kept forever 24\|Neha Joshi (9A)\|9876543210 No end date Delete at end of day
Logging headers + body (our example) "x-staff-pin":"482913" Logs travel Method, path, status, time
Deleting only the row strings canteen.db \| grep → 1 Old bytes stay secure_delete + check
No reason given a phone box, no sentence Not informed consent Notice + unticked box

Mini project: a privacy pass on your app

  1. List every personal field your app stores (database, localStorage, logs) and write its purpose in one sentence. Delete one you don't need.
  2. Add a schedule that deletes data when its purpose is done, and check with strings (or your database's tools) that it's really gone.
  3. Open your app in a fresh browser profile after using it: does anything of yours show?
  4. Search your logs for phone numbers, emails, tokens and keys.
  5. Write a one-page PRIVACY.md like the draft above and link it from the page.

Practice questions

  1. Is "Ravi, 10B" personal data?
Answer

Yes: a name with a class identifies a student in a school.

  1. Your sign-up form has "Date of birth" but you only need to know if someone is 13+. What do you do?
Answer

Ask only what you need (e.g. a yes/no age check, or year of birth if required), not the full date: data minimisation.

  1. You deleted a user's row. Name three places their data might still be.
Answer

Backups, log files, browser storage on their device, exports/screenshots, and old bytes inside the database file.

  1. Why should request headers never be logged?
Answer

They carry secrets: cookies, tokens, API keys, PINs (x-staff-pin).

  1. A checkbox reads "I agree to receive WhatsApp updates" and is ticked by default. Valid consent?
Answer

No: it needs a clear affirmative action by the person, so the box must start unticked.

Quiz

Which consent counts? A) A box that comes already ticked · B) "By using this app you agree to everything" · C) An unticked box: "Yes, message me when my order is ready" · D) No phone number, no order

Answer

C: a clear action by the person, for one specific purpose, given freely. A and B aren't a clear action; D isn't free.

Interview questions

  1. What is data minimisation? Collecting only the personal data needed for a stated purpose.
  2. How do you handle a "delete my data" request? Find every copy (DB, logs, caches, backups, third parties), delete or anonymise, confirm, and record that it was done.
  3. What should never be in logs? Secrets, credentials, tokens, full bodies/headers, personal data; log IDs and status instead.
  4. What does India's DPDP Act require for children's data? Verifiable consent of a parent or lawful guardian (child = under 18).
  5. Privacy vs security? Security protects data from attackers; privacy decides what you collect, why, for how long and who sees it.

Glossary

Term Meaning (with an example from this episode)
Personal data Data about a person who can be identified from it (Neha's name, class, number).
Privacy People deciding who knows what about them.
Purpose Why you collect something, in one sentence ("message you when ready").
Data minimisation Collect the least you need (an order number instead of a phone).
Retention How long you keep data (until the end of the day).
Consent A person's clear, free yes to one purpose (an unticked box they tick).
Withdraw consent Saying no later, as easily as you said yes.
Privacy notice / policy Telling people what you collect, why, how long, who sees it.
localStorage Browser storage that stays on that browser, even for the next user.
Shared computer A device many people use (the library computer).
Log / request log A file with a line per event (DELETE /api/orders/27/phone 200 2ms).
Header Extra information sent with a request; can carry secrets (x-staff-pin).
Request body The data sent with a request ({"phone": ...}).
Secret Anything that gives power if known (PIN, password, API key, token).
.env / .gitignore A file for secrets / the list of files Git must not commit.
secure_delete SQLite setting that overwrites deleted data in the file.
strings A command that prints readable text found in any file.
Backup A copy of data kept in case of loss; it remembers deleted data.
DPDP Act, 2023 India's Digital Personal Data Protection Act.
DPDP Rules, 2025 The rules under the Act, notified 14 Nov 2025, phased over 18 months.
Data Principal The person the data is about (the student).
Data Fiduciary Whoever decides why and how data is processed (whoever runs the app).
Child (DPDP) Anyone under 18.
Consent manager A registered service people can use to give and manage consent.
Data Protection Board The body that enforces the Act and receives breach reports.
Personal data breach Data seen, lost or shared without permission.

Summary

  • Personal data is anything you can tie back to a person; every copy (DB, browser, logs, backups) is a risk, and students are children under the law.
  • The AI kept its log clean but "remembered" a student's phone number for the next person on a shared computer, and kept numbers forever.
  • Ask four questions before adding a box; get consent with an unticked box; make saying no as easy as saying yes.
  • With the evidence, the AI fixed it; we verified: nothing left for the next student, yesterday's number gone from the table and the file bytes, and only the right phone removes a number. Backups still remember.
  • Keep secrets in .env, never in logs; grep logs before sharing.
  • DPDP: Rules notified 14 Nov 2025; most duties from May 2027; children need a parent's consent; penalties up to ₹250 crore.

Next episode: Deploying for free: Vercel, Netlify and Firebase.