The voice on the phone from the legal team was tense: a data protection audit was two weeks out, and they wanted to know whether "the technical side is ready." The paperwork genuinely was ready — privacy notices written, the data inventory compiled, the VERBIS registration (Turkey's data controller registry) done. Then we connected to the server of an old side service and looked at the application logs: the middleware was writing the body of every incoming request to the log file, verbatim. Turkish national ID numbers, phone numbers, full street addresses — for months, in plain text, multiplied over and over by log rotation. The legal department had no idea those files even existed.
On paper, KVKK (Turkey's personal data protection law) compliance looks like the legal department's job; in reality, most of the violations that turn into fines are born at the code level. Identity data leaking into logs, membership records kept forever, phone numbers flowing into a third-party SDK... None of these are solved by a contract clause; they're solved by architecture. The framework below, as we apply it on our own projects, follows data through its three life stages: when it's collected, while it lives, and when it dies.
As data comes in the door: take less, describe it honestly, ask separately
The first principle is minimization, and I'll admit it's the one that runs most against developer instinct. We all add fields "in case we need them later" when designing a form — date of birth, a second phone number, occupation. KVKK's logic is the exact opposite: data you never collected can't leak, can't be misused, and never has to be deleted. On new projects we ask a single question for every form field: is it impossible to deliver the service without this data? If the answer is "actually, we could," the field comes out of both the form and the database schema. The safest data is data that was never collected.
The second principle is that the privacy notice has to be true. It must describe what the application actually does — not what a lawyer wrote three years ago. The most common point of failure: a developer adds an analytics SDK mid-sprint, tells no one, and the notice goes stale. What prevents that gap for us is the release checklist: "if a new SDK or data flow has been added, no release until the privacy notice is updated" is a written item, and it's enforced.
The third is that explicit consent has to be genuinely explicit. Marketing permission buried inside the membership terms is legally invalid; the checkbox must be separate and unchecked by default. The developer's part is evidence: record when the user consented and to which version of the text. Saying "we got consent" isn't enough; you have to be able to show it.

While data lives inside: logs, access, third parties
Let's go back to the log story from the opening, because that really is the most common leak point. A middleware that logs the full request body also logs the user's password and identity details — and everyone who can see the logs (developers, the logging service, a potential attacker) can see that data. Masking shouldn't be a feature bolted on later; it should be a day-one decision for the logging infrastructure: sensitive fields (password, ID number, card details) are defined centrally, and the logging layer redacts them before writing anything.
On the access side, the target sentence is this: being able to answer "Who looked at this customer's data in the last three months?" within minutes. That requires role-based authorization plus an access log — even the customer search screen in the admin panel should leave a record. Sound like overkill? That is exactly the first question asked when a data breach is suspected, and you can guess how "we don't know" goes over in an audit.
The third-party inventory is part of this stage too. For every SDK and external service in your project, have answers ready to three questions:
- What personal data does it receive?
- Where does it process the data — is there a transfer abroad? (For most cloud services, there is.)
- Have the contractual and mechanism sides of that transfer been settled together with legal?
Any statement you make without having built this inventory is wishful thinking.
Then there's the most overlooked corner of a developer's daily life: test and development environments. Copying the production database to staging because "we need realistic test data," and from there onto developers' laptops, is still a common habit in the industry — and every copy is an unprotected duplicate of personal data. The staging password is weak, a laptop gets lost, a copy stays on a former employee's disk. The fix is well known but tedious: if production data has to come down to a development environment, it comes down masked, and the ideal is generated fake data (faker libraries exist for exactly this). Quitting testing with real customer data is one of the cheapest items on the compliance list.

When data dies: deleting means really deleting
First, the retention period itself: we still hear "forever, disk is cheap" as the answer to "how long do you keep data?" far too often. In fact, every category of data should have a defined retention period, and that period should be reflected in code — a deletion schedule that someone has to remember manually means data that never gets deleted. We set this up as scheduled cleanup jobs: tasks that regularly scan for expired records, delete or anonymize them, and report what they did.
As for the quality of deletion: the most common sleight of hand here is the active=0 trick we all know. Soft delete is a legitimate software pattern, but it isn't deletion in the KVKK sense; the data is still sitting there. If you choose the anonymization route, the bar is high: the process must be irreversible. Hashing the user ID doesn't count as anonymization — anyone who knows how the hash was produced can rebuild the mapping.
And test the right to be forgotten end to end; it's a requirement you can write a unit test for. When a membership is deleted, don't just look at the users table: what happens in the backups, what remains in the log archive, does the search index (Elasticsearch, etc.) still return that record, and what about the list already sent to the email service? While testing the deletion flow on the platform, we found that users kept living in the search index for months — the database was spotless, but the index had been forgotten. Be realistic about backups, too: scrubbing every historical backup is often not technically reasonable; the accepted approach is to limit the lifetime of backups and write a procedure guaranteeing that deleted records are deleted again if a restore is ever performed.

Compliance done late is a fine; done early, it's architecture
The whole list boils down to one principle: make KVKK an architectural input from day one, not a documentation task remembered at the end of the project. Compliance considered at the design stage is almost free — you drop a column, add a mask, make a logging decision; none of it shakes up the sprint plan. Compliance remembered because of an audit letter arrives as fine risk plus a rewrite bill; the difference between the two is sometimes one zero, sometimes two.
If you're curious where your current system stands across these three stages, run a compliance review through a developer's eyes; that review makes visible the layer a legal audit can't see. Remember those log files from the opening — it wasn't the legal team that found them; it was someone who thought to connect to the server and look. I enjoy discussing these topics; the contact page is open.