System design interviews can be quite open-ended and require a wide range of knowledge.
- It's not possible to add custom fonts to Google Docs at this time. That's because Docs uses special web-based fonts (since it's a cloud-based app). If you have Adobe Bengali stored locally on your device, Word and InDesign might be trying to replace the web font with the local one and running into conflicts.
- 119+ FREE PROJECT Templates - Download Now Adobe PDF, Microsoft Word (DOC), Microsoft Excel (XLS), Adobe Photoshop (PSD), Google Docs, Adobe InDesign (INDD & IDML), Apple (MAC) Pages, Google Sheets (Spreadsheets), Microsoft Publisher, Apple (MAC) Numbers, Adobe Illustrator (AI).
To prepare well for such kind of interviews, it’s important to cover different areas instead of focusing on a single topic. We’ve spent a lot of time selecting system design questions to analyze, our main criteria are:
- The question is popular and classic
- We care about the diversity of questions we select
- The analysis can be helpful to other interview questions
382+ FREE CONSTRUCTION Templates - Download Now Adobe PDF, Microsoft Word (DOC), Microsoft Excel (XLS), Adobe Photoshop (PSD), HTML5, WordPress, Google Docs, Microsoft PowerPoint (PPT), Adobe InDesign (INDD & IDML), Apple (MAC) Pages, Google Sheets (SPREADSHEETS), Microsoft Publisher, Apple (MAC) Numbers, Adobe Illustrator (AI), Apple (MAC) Keynote, Google Slides. The ‘Docs Flow’ system. Emsoftware’s Docs Flow system is a plugin for Indesign that allows the designer to import Google Doc or Google Sheet items from their Google Drive folder, including items shared with content editors, directly into Indesign. When content editors alter linked items in Google Drive, the designer gets an instant.
This week, we’d like to discuss how to design Google Docs. You will find it quite different from the analysis of our previous questions.
Question – How to design Google Docs
I’ll assume everyone knows what Google Docs is and won’t waste time introducing this product.
The question looks quite general at first glance and it indeed is. Google Docs is a huge system with tons of features. If you spend few minutes thinking about his problem, you may realize that Google Docs is much more complex than it seems to be.
As an interviewer, I don’t like to limit the scope of discussion to a specific feature of this product. Instead, I lean toward making the question broad and general so that I can know how candidates will address a vague problem step by step.
Divide into components
We’ve emphasized many times in our previous posts that it’s recommended to provide high-level solutions when the question is big. And one way to abstract your solution is dividing a big system into smaller components.
Apparently, Google Docs is a huge system that has a bunch of features, including doc storage, share docs, formatting, editing and so on. In fact, I can barely address such a big problem without separating it to different sub-problems.
If you haven’t thought about this problem, please spend 5-10min to have your own answer before checking our analysis. Also, it’s worth to note that it’s absolutely okay if your solution is different from ours since the question is open-ended.
We can divide the whole system into the following major components:
- File storage. Since Google Docs is part of Google Drive, I include the storage feature as well. The system allows users to group files (docs) into folders and support features like edit/create/remove etc.. It works like an OS.
- Online editing and formatting. There’s no doubt that one of the core features of Google Docs is online editing. It supports almost everything of Microsoft Office and maybe more.
- Collaboration. It’s truly amazing that Google Docs allows multiple people to edit a single doc simultaneously. This is a technical challenge for sure.
- Access Control. You can share docs with your friends and give different permissions (owner, read-only, allow comment etc.).
A bunch of less important features are ignored here, like add-ons, spell-checking, publish to the web and so on.
Storage and Formatting
I put these two topics together since with storage and formatting implemented, a very basic and naive version of Google Docs is created. Even if there’s no access control and collaboration, a single user can still use it to edit docs.
Also, storage and formatting can be regarded as backend and front-end to some extent.
IMHO, the storage system of Google Docs (or Google Drive) is very close to an operating system. It has notions like folders, files, owners etc..
Therefore, to build such system, the basic building block is a file object, which contains content, parent, owner and some other meta data like creation date. Parent denotes the folder relation and the root directory has empty parent. I won’t discuss how to scale the system as building a distributed system can be extremely complicated. There are tons of things to be considered like consistency, replication.
For the front-end formatting, an interesting question is how you would store documents with corresponding formats. If you know Markdown, it’s definitely one of the best solutions. Although Google Docs can be more complicated, the basic idea of Markdown still applies.
Concurrency
One of the coolest features of Google Docs is that multiple people can edit a single doc simultaneously. How would you design this feature?
This is not an easy problem, to be honest. You can’t just let each person work on his own and then merge everyone’s copy or the last one to edit wins. If you have tried the collaborative editing feature, you can actually see what the other person is doing and you get instant feedback.
If you have used Git for version control, some of the ideas here can be similar. First, let’s consider the simplest case – only 2 people are editing the same doc. Assuming the doc is “abc”.
Basically, the server can keep 2 copies of the same doc to each person and tracks the full revision history as well. When A edits the doc by adding “x” in the beginning, this change will be sent to the server together with the last revision seen by A. Suppose at this time, B deletes the last character “c” and this change is sent to the server as well.
Since the server knows the change is made on which revision, it will adjust the change accordingly. More specifically, B’s change is deleting the 3rd character “c”, which will be transformed to deleting the 4th character as A adds “x” in the beginning.
This is called operational transformation. It’s okay if you never heard of this. The basic idea is to transform each person’s mutation based on its revision and revisions from other collaborators.
Access Control
Google Docs allows you to invite collaborators to each doc with different level of permissions.
A naive solution shouldn’t be hard. For each file, you can keep a list of collaborators with corresponding permissions like read-only, owner etc.. When one wants to do specific actions, the system checks his permission.
Usually, I’d like to ask what are challenges to scale such access control system.
As is known to all, when scaling system to millions of users, there can be a lot of issues. Few things I’d like to mention here are:
- Speed. When the owner updates the permission of a folder (e.g. remove a specific viewer), this update should be propagated to all its children. speed can be a concern.
- Consistency. When there are multiple replications, it’s non-trivial to keep every replica consistent especially when multiple people update the permission at the same time.
- Propagation. There can be a lot of propagation cases. Besides updating the permission of a folder should reflect on all its children, if you give read permission of a doc D to someone, he may have read permission to all the parents of doc D as well. If someone deleted doc D, we may revoke his read permission of D’s parents (maybe not, this is more of a product decision).
Summary
Again, none of us at Gainlo has ever worked on Google Docs. This post is not teaching you how to build Google Docs from scratch.
Google Docs Indesign
Instead, I’d like to use this post to give you more ideas of how system design interviews are conducted and how you can address a vague problem.
Designing a complex system like Google Docs can be intimidating. But once you divide the system into smaller components, it becomes much simpler.
If you find this post helpful, I would really appreciate if you can share it with your friends. Also you can check more system design interview questions and analysis here.
The post is written by Gainlo - a platform that allows you to have mock interviews with employees from Google, Amazon etc..
I'd like to learn more
Related posts:
It’s with a great sigh of relief that, after nearly half a year of substantial internal re-engineering and intense development, we today release DocsFlow 2.0, the much anticipated follow-up to our acclaimed Google Docs connector plug-in. DocsFlow 2.0 offers many customer-driven improvements and new features. The new Pro level gives you full export to Google Docs, and full updating, where you can push-merge your changes from InDesign back into your linked Google Docs document, along with spreadsheet support.
You can purchase both Pro and non-Pro licenses or download the plug-in from the “DocsFlow for InDesign” sidebar, which appears here, on the product page, on the user guide page, and on any related news items.
As a thank-you to our early adopters, all of the licenses we’ve issued prior to this release have been Pro licenses. By updating to this release, those of you who have already purchased a license will instantly gain all of this version’s Pro capabilities (mainly story export and two-way updating).
Convert Indesign To Google Docs
You can learn all about DocsFlow at a high level from its product home page. And you’ll find all the details about using DocsFlow effectively in our online user guide.
Known issues
- Due to Google Docs bugs when uploading pictures, on export or update to Google Docs DocsFlow will omit any pictures from the uploaded story. However, they will remain in the InDesign document and will be properly maintained in place, but will just be missing in the Google Docs document.
- If you have a previous version of DocsFlow installed, we highly recommend that you first use our Uninstaller tool (see the Extension Manager problems sidebar on our product installation page for download links) to completely remove the old plug-in before attempting to install the upgrade. Otherwise, we’ve noticed in our testing that Extension Manager can become confused by such upgrades, or may just refuse to install them.
Changes
- Splits the product into Pro and no-Pro levels. A Pro-level license is now required to import Google spreadsheets and to use any of 2.0′s new export machinery. See notes above for licensing details.
Adds File > DocsFlow > Export to Google Docs… and a variant, File > DocsFlow > Export to Google Docs and Visit…, which adds a visit to the newly created Google Docs document after its export, which sends the selected (and currently not otherwise linked) story to the active Google Docs account and then creates a link to it. A new Export to Google Docs dialog displays the account’s existing documents and folders, allows the selection of a destination folder, and accepts a name for the exported document.
This export facility creates a true “poor man’s workflow” where stories can be created and “assigned out” from InDesign to Google Docs, with links that make them ready to receive updates in both directions.
- Adds a DocsFlow submenu to the Links panel menu that contains the renamed Visit Original Document (was previously Edit Original without Auto Update), which will take you to the original Google Docs document without forcibly updating the link when you return to InDesign.
- Adds a set of Update Original Document entries to the Links panel menu’s DocsFlow submenu which will export and merge any changes in the InDesign story to the linked Google Docs document. We think this is done in a particularly clever fashion, such that on export to an existing story, DocsFlow performs a three-way merge (just like when updating in the other direction). DocsFlow thus attempts to leave the formatting of the Google Docs document intact, updating only the content, unless your import options are such that Google Docs formatting is obeyed.
- Adds a full, “tree”-style view of your Google Docs files to the Place with DocsFlow dialog (and to the new export dialogs). The normal InDesign expand-all and collapse-all shortcuts work there for quick navigation (Ctrl/Cmd-click the triangle icon).
- Allows the placement of multiple documents from the Place with DocsFlow dialog and via drag-and-drop. Each selected or dropped document is loaded into InDesign’s place gun, which can then be used to place each linked document in sequence.
- Adds a DocsFlow link icon to the frames of all Google Docs-linked stories. The icon will show for newly imported, updated, and exported stories but not, unfortunately, for existing DocsFlow stories.
- Adds support for the placement of OpenOffice/LibreOffice ODF documents and spreadsheets that are stored in Google Drive.
- Adds DocsFlow-related entries to a story’s various context menus.
- Adds conflict markers, displayed as InDesign Notes, to show where DocsFlow resolved a merge conflict that may require additional attention. InDesign’s Notes panel (Window > Editorial > Notes) can then be used to select, view, and remove conflict markers that were inserted during an update.
- Works around an InDesign bug where updating a story containing custom-anchored frames would cause InDesign to shut down.
- Improves the reliability of browser-based (OAuth) connections. Browser-based connections are preferred and allow DocsFlow to provide a faster, more stable Google Docs experience.
Improves the resolution of merge conflicts by letting the source text always “win” for content order and the target text always “win” for formatting. For example, when updating an InDesign story from Google Docs, if the same piece of text has been moved in both, then DocsFlow will let the Google Docs text, as the merge’s source, determine the location of the resulting piece of text in the merged InDesign story. Similarly, if both have style changes to the same piece of text, then DocsFlow will let the InDesign story, as the merge’s target, determine how the resulting piece of text is styled. As noted above, a conflict marker (in the form of an InDesign Note) will be inserted at the location of any such conflict.
Likewise, when updating a Google Docs document from an InDesign story using Update Original, DocsFlow will let the InDesign text, the merge’s source, dictate conflicting text’s merged position, while the Google Docs text, the merge’s target, will determine how conflicting styles are resolved.
- Improves character style-level conflict handling.
- Imports Google Docs’s Normal text paragraph style as InDesign’s [Basic Paragraph] by default.
- Adds support for “line height” along with an Import Option to disable it.
- Adds settings for ignoring underline, strike-through, superscript, and subscript character attributes to the Import Options dialog.
- Removes the option to suppress change mark generation when updating a story.
- Improves the handling of quote, hyphen, and non-breaking space characters during merges.
- Fixes a problem where the login dialog would default to a direct-style connection even if the previous connection was via browser.
- Fixes the mysterious reappearance of replaced styles after updating an InDesign story.
- Fixes a problem where page breaks added to a linked Google Docs document could be ignored when updating the InDesign story.
- Fixes a problem where some deletions weren’t being displayed in the Story Editor.
- Fixes a problem where deleted hyperlinks could cause a merge to hang.