📝 Google Docs Document Management API

Secure, Scalable and Collaborative documents.

1 hour
medium
2 submissions

Project Overview

Secure, Scalable and Collaborative documents.

The Document Management Service is a critical microservice responsible for securely storing, retrieving, and managing documents in a distributed system. It acts as the source of truth for document data, ensuring that users can create, update, and delete documents while enforcing access control via authentication.

This service integrates with the IAM (Identity & Access Management) Service to verify user authentication and ensure only authorized users can perform document operations. Additionally, it works alongside the Real-Time Collaboration Service, which handles live document editing, while the Document Management Service persists the final versions.

With a stateless and scalable design, this service guarantees efficient document handling, secure access enforcement, and seamless integration with other microservices.

This service relies on the previous google docs microservice we saw:

Identity Access Management API I → Registers and authenticates users, validates authentication tokens.

Make sure to read the google docs microservices project architecture before starting this service.

Your submissions

No submissions yet, start by making your first submission

Detailed Project Description

The Document Management Service is responsible for handling the storage, retrieval, and modification of documents within a microservices-based system. It acts as the source of truth for all document-related operations, ensuring secure and structured access to documents while integrating seamlessly with the authentication and collaboration services.

This service is designed to be stateless and scalable, relying on JWT-based authentication to ensure that only authorized users can access or modify documents. It communicates with the IAM (Identity & Access Management) Service to validate user tokens before processing any requests. Additionally, it integrates with the Real-Time Collaboration Service to facilitate concurrent editing and ensure data consistency.

This service relies on the previous google docs microservice we saw:

Identity Access Management API I (http://localhost:3033) → Registers and authenticates users, validates authentication tokens.

When your submission is executed, it will have access to a correct implementation of these services running on their respective ports. Your task is to implement the Ride Request Service so that it properly interacts with these services to facilitate ride matching, fare calculation, and ride lifecycle management.

Make sure your api runs on the port 3034.

Core Responsibilities

  • Document Storage & Retrieval:
    Store documents efficiently while allowing users to retrieve their documents at any time.

  • User Access Control:
    Verify user identity using JWT authentication via the IAM Service before granting access to any document.

  • Document Updates & Versioning:
    Handle document modifications while ensuring updates are stored persistently.

  • Inter-service Communication:
    Works alongside other microservices such as:

    • IAM Service – Used for verifying authentication tokens.
    • Real-Time Collaboration Service – Manages live document editing.
  • Security & Data Integrity:
    Prevent unauthorized access to documents and ensure consistent data storage.

Authentication & Authorization

All requests to the Document Management Service must be authenticated using a valid JWT token, which the service will validate by calling the IAM Service before proceeding with any action.

Token Validation Process:

  1. The client includes a JWT token in the Authorization header when making a request.
  2. The Document Management Service extracts the token and makes an internal request to the IAM Service’s /auth/validate endpoint.
  3. If the IAM Service confirms that the token is valid, the request proceeds. Otherwise, an authentication error (401 Unauthorized) is returned.
  4. After validation, the service checks if the user has access to the requested document before executing the operation.

Integration with the Real-Time Collaboration Service

While this service manages document storage, the Real-Time Collaboration Service is responsible for handling concurrent editing. The document management service only stores the latest committed version of a document, while real-time updates happen in a separate layer.

  1. When a user updates a document, changes are sent to the Collaboration Service.
  2. The Collaboration Service applies synchronization logic (e.g., Operational Transformation or CRDTs).
  3. Once finalized, updates are sent back to the Document Management Service for persistent storage.

Technical Specifications

Make sure your api runs on the port 3034.

Endpoint Schemas

  1. Retrieve Documents

    • Method: GET
    • Path: /documents
    • Description: Retrieve a list of documents accessible to the user.
    • Input:
      • Headers:
        • Authorization: Bearer JWT token
      • Query Parameters (optional):
        • limit (number)
        • offset (number)
    • Output:
      • Status: 200 OK
      • Body:
        { "documents": [ { "documentId": "string", "title": "string", "lastModified": "string (ISO 8601 date)" } ] }
  2. Create a New Document

    • Method: POST
    • Path: /documents
    • Description: Create a new document.
    • Input:
      • Headers:
        • Authorization: Bearer JWT token
        • Content-Type: application/json
      • Body:
        { "title": "string", "content": "string" }
    • Output:
      • Status: 201 Created
      • Body:
        { "documentId": "string", "message": "Document created successfully" }
  3. Retrieve a Specific Document

    • Method: GET
    • Path: /documents/{documentId}
    • Description: Retrieve the content and metadata of a specific document by its unique ID.
    • Input:
      • Headers:
        • Authorization: Bearer JWT token
      • Path Parameters:
        • documentId (string)
    • Output:
      • Status: 200 OK
      • Body:
        { "documentId": "string", "title": "string", "content": "string", "lastModified": "string (ISO 8601 date)" }
  4. Update a Document

    • Method: PUT
    • Path: /documents/{documentId}
    • Description: Update the content or metadata of a document.
    • Input:
      • Headers:
        • Authorization: Bearer JWT token
        • Content-Type: application/json
      • Path Parameters:
        • documentId (string)
      • Body:
        { "title": "optional string", "content": "optional string" }
    • Output:
      • Status: 200 OK
      • Body:
        { "message": "Document updated successfully" }
  5. Delete a Document

    • Method: DELETE
    • Path: /documents/{documentId}
    • Description: Delete a specific document.
    • Input:
      • Headers:
        • Authorization: Bearer JWT token
      • Path Parameters:
        • documentId (string)
    • Output:
      • Status: 200 OK
      • Body:
        { "message": "Document deleted successfully" }

Make sure your api runs on the port 3034.

Summary

The Document Management Service plays a critical role in maintaining structured access to documents. It acts as a secure storage layer, validates authentication via the IAM Service, and interacts with the Real-Time Collaboration Service to synchronize document changes. By providing a well-defined API, this service ensures scalability, security, and seamless document handling within a microservices architecture.

Project Completion Criteria

  • The system should require a valid JWT token in the `Authorization` header for all requests.
  • The system should validate JWT tokens by calling the IAM Service’s `/auth/validate` endpoint before granting access to any resource.
  • The system should return a `401 Unauthorized` response for requests with missing, invalid, or expired JWT tokens.
  • The system should allow users to create new documents via the `POST /documents` endpoint by providing a title and content.
  • The system should reject document creation requests that are missing a title or content with a `400 Bad Request` response.
  • The system should allow users to retrieve a specific document by its ID via the `GET /documents/{documentId}` endpoint.
  • The system should allow users to update an existing document’s title or content via the `PUT /documents/{documentId}` endpoint.
  • The system should ensure that only authorized users can update a document by validating their JWT and checking document ownership.
  • The system should return a `404 Not Found` response if a user attempts to update a document that does not exist.
  • The system should allow users to delete a document via the `DELETE /documents/{documentId}` endpoint.
  • The system should ensure that deleted documents no longer appear in the list retrieved from the `GET /documents` endpoint.