solidcodersolidcoder
Explore Courses
solidcodersolidcoder

Practical courses for software engineering interviews — no gatekeeping, no fluff.

Company-wise Questions

  • Flipkart Machine Coding Questions
  • Swiggy Machine Coding Questions
  • Meesho Machine Coding Questions
  • Razorpay Machine Coding Questions

Machine Coding Tutorial

  • Machine Coding Tutorial

Explore

  • Courses
  • About
  • Privacy Policy
  • Terms

© 2026 solidcoder · Practical courses for software engineering interviews.

Built for the AI era — learn by doing.

Home/Machine Coding/Razorpay Machine Coding Questions/Document Service — Razorpay Machine Coding Round
Chapters — Razorpay Machine Coding Questions▾

Document Service — Razorpay Machine Coding Round

Machine Coding·SDE-1·5 min read·Sep 11, 2026

Razorpay machine coding round — design a document service with ownership and per-user access control, scoped to an acting user.

Document Service — Razorpay Machine Coding Round — Razorpay Machine Coding Questions
Razorpay machine coding round — design a document service with ownership and per-user access control, scoped to an acting user.
Asked inRazorpay

Design and implement a simple document service where users can create documents and read them back. A document is just a name paired with string content — the interesting part of this problem is the access-control model layered on top of it.

What the round tests

This one tests whether you can build a correct permission model from scratch — private-by-default documents, owner-granted read/edit access, and an owner-only delete rule — while keeping every operation scoped to "on behalf of" a specific user rather than trusting a global, unscoped action.

Objective

The primary objective is to design and implement a user-scoped document service that supports creating private documents, granting read/edit access, and enforcing owner-only deletion — with correct permission checks on every operation.

Data Model

Each document is conceptually a name paired with its content, owned by the creating user.

Document => <name: string, content: string>
Every action is user-scoped

There's no anonymous or unscoped action — create, read, edit, and delete must all be performed on behalf of a specific user. A username is just a plain string; there's no separate user-registration step implied by the source problem.

Functional Requirements

Two tiers of scope

Requirements are split into two tiers so you know what to prioritize under time pressure: build first, and worth proposing if time allows.

Part 1 — Basic Requirements

Core functionality you must build and get working first.

Core operations
Operation
Behavior
create(user, name, content)
Creates a new document with the given name and content, owned by user. The document is private by default — visible only to its owner until access is explicitly granted.
read(user, name)
Returns the document's content if user is the owner or has been granted read or edit access; otherwise the read is denied.
edit(user, name, newContent)
Updates the document's content if user is the owner or has been granted edit access specifically (read-only access is not sufficient).
grant(owner, name, targetUser, accessLevel)
Lets the document's owner grant another user either read or edit access to the document.
delete(user, name)
Deletes the document — but only if user is the document's owner. No granted access level permits deletion.
Access rules to get exactly right

Documents are private at creation — no one but the owner can read or edit a brand-new document. Access is additive and owner-controlled: only the owner can call grant, and only the owner can delete, regardless of what access level anyone else holds. Edit access implies read access, but read access does not imply edit access.

Part 2 — Suggested Extensions

Access control follow-ups
Feature
Why it's worth adding
revoke(owner, name, targetUser)
Symmetric to grant — the source only lets the owner add access, never remove it.
Thread safety
Concurrent grant/edit/delete calls on the same document shouldn't corrupt its content or its access list.
transferOwnership(owner, name, newOwner)
Lets a document's ownership move to someone else, which then changes who can grant/revoke/delete going forward.
listAccessibleDocuments(user)
Lets a user see every document they own or have been granted access to, instead of needing to already know document names.
Access expiry
Grant access for a limited time window (e.g. read access for 24 hours) rather than permanently.

Part 3 — Future Extensions

Document lifecycle follow-ups
Feature
Why it's worth adding
Version history
Keep prior versions on every edit, and let an authorized user view or roll back to an earlier version.
Audit log
Track who performed which action (create/read/edit/grant/delete) and when, for accountability.
makePublic(owner, name) / makePrivate(owner, name)
Let an owner flip a document to be readable by any user, bypassing per-user grants entirely.
Scale & operations follow-ups
Feature
Why it's worth adding
Search by name or content
Let a user search across documents they can access, not just fetch by exact name.
Folders / namespacing
Group documents so name collisions across unrelated owners don't need to be handled as a special case.

Example Usage: Full Walkthrough

1. Create a document — private by default

> create("alice", "roadmap", "Q3 goals: ship search v2")
✅ Document 'roadmap' created, owned by alice.

> read("bob", "roadmap")
❌ Access denied. bob has no access to 'roadmap'.

2. Owner grants read access

> grant("alice", "roadmap", "bob", "read")
✅ bob granted READ access to 'roadmap'.

> read("bob", "roadmap")
"Q3 goals: ship search v2"

3. Read-only access does not allow editing

> edit("bob", "roadmap", "Q3 goals: ship search v2 and v3")
❌ bob has READ access only — cannot edit 'roadmap'.

4. Owner grants edit access to someone else

> grant("alice", "roadmap", "carla", "edit")
✅ carla granted EDIT access to 'roadmap'.

> edit("carla", "roadmap", "Q3 goals: ship search v2 and v3")
✅ 'roadmap' updated by carla.

5. Only the owner can delete — even an editor cannot

> delete("carla", "roadmap")
❌ carla is not the owner — cannot delete 'roadmap'.

> delete("alice", "roadmap")
✅ 'roadmap' deleted by alice.
Result

Bob is denied read access until explicitly granted, then correctly blocked from editing since read access doesn't imply edit access. Carla, despite holding edit access, is still blocked from deleting — only alice, the owner, can. This traces the full access hierarchy: private by default, then read, then edit, then owner-only delete.

Up next2/2
Part 1 · SDE-1
←
← Prev Chapter
In-Memory SQL
5 min
Next Chapter →
Search Engine
5 min · continue reading
→

Enroll in machine coding mastery series

₹30,000₹3,00090% OFF
Enroll Now →

Use code SOLID50 · 3 years · 40+ lessons

On this page
  • Objective
  • Data Model
  • Functional Requirements
    • Part 1 — Basic Requirements
    • Part 2 — Suggested Extensions
    • Part 3 — Future Extensions
  • Example Usage: Full Walkthrough