PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/System Design/Akuna Capital

Implement a two-user communications handler

Last updated: Mar 29, 2026

Quick Overview

This question evaluates skills in stateful resource management, API and abstraction design, custom exception handling, and input validation for enforcing a single-active connection between two users.

  • medium
  • Akuna Capital
  • System Design
  • Software Engineer

Implement a two-user communications handler

Company: Akuna Capital

Role: Software Engineer

Category: System Design

Difficulty: medium

Interview Round: Take-home Project

Design and implement a communications handler to manage a one-at-a-time conversation channel between exactly two distinct users. Specifications: ( 1) Define a custom exception type ConnectionException that accepts a single error-message string. ( 2) Define an abstract base CommsHandlerABC with three abstract methods: connect(user1: Caller, user2: Caller) -> str to establish a call or raise ConnectionException; hangup(user1: Caller, user2: Caller) -> str to end the call or raise ConnectionException; clear_all() -> None to force-clear any existing call. ( 3) Implement a concrete CommsHandler that tracks the current active call and enforces: only one active call at a time; a user cannot connect with themselves; while a call is active, any new connect attempt fails with an appropriate error; hangup succeeds only for the currently connected pair; clear_all resets state immediately. Caller has a unique name field (name: str). Process the following commands and produce the exact outputs shown. Sample Input: connect Alice Bob; connect Carol Dave; hangup Alice Bob; connect Carol Dave; hangup Carol Dave; connect Eve Eve; hangup Alice Bob. Expected Output: Success: Connection established between Alice and Bob; Error: Connection in use. Please try later; Success: Alice and Bob are disconnected; Success: Connection established between Carol and Dave; Success: Carol and Dave are disconnected; Error: Eve cannot connect with Eve; Error: Alice and Bob not found in the communication channel.

Quick Answer: This question evaluates skills in stateful resource management, API and abstraction design, custom exception handling, and input validation for enforcing a single-active connection between two users.

Related Interview Questions

  • Design communication handler and exceptions - Akuna Capital (medium)
  • Design an order-matching engine - Akuna Capital (hard)
  • Fix and harden an object pool - Akuna Capital (hard)
  • Design user communication functions - Akuna Capital (easy)
  • Design user communication manager APIs - Akuna Capital (medium)
Akuna Capital logo
Akuna Capital
Sep 6, 2025, 12:00 AM
Software Engineer
Take-home Project
System Design
7
0

One-at-a-time Two-User Communications Handler

Context

Design and implement a communications handler that supports exactly one active conversation at a time between two distinct users. Each user is represented by a Caller with a unique name.

Requirements

  1. Define a custom exception type:
    • ConnectionException that accepts a single error-message string.
  2. Define an abstract base class CommsHandlerABC with these abstract methods:
    • connect(user1: Caller, user2: Caller) -> str
      • Establish a call and return a success message, or raise ConnectionException.
    • hangup(user1: Caller, user2: Caller) -> str
      • End the call and return a success message, or raise ConnectionException.
    • clear_all() -> None
      • Force-clear any existing call and reset state.
  3. Implement a concrete CommsHandler that enforces:
    • Only one active call at any time.
    • A user cannot connect with themselves.
    • While a call is active, any new connect attempt fails with error: "Connection in use. Please try later".
    • hangup succeeds only for the currently connected pair (order-agnostic). Otherwise raise: "{A} and {B} not found in the communication channel." (note trailing period).
    • clear_all resets the state immediately.

I/O Behavior

  • Commands to support (semicolon-separated in a single line or as separate lines):
    • connect <user1> <user2>
    • hangup <user1> <user2>
    • clear_all
  • Output:
    • On success: prefix with "Success: " and include the handler's returned message.
    • On error: prefix with "Error: " and include the exception's message.

Sample

  • Sample Input:
    • connect Alice Bob; connect Carol Dave; hangup Alice Bob; connect Carol Dave; hangup Carol Dave; connect Eve Eve; hangup Alice Bob
  • Expected Output:
    • Success: Connection established between Alice and Bob; Error: Connection in use. Please try later; Success: Alice and Bob are disconnected; Success: Connection established between Carol and Dave; Success: Carol and Dave are disconnected; Error: Eve cannot connect with Eve; Error: Alice and Bob not found in the communication channel.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More System Design•More Akuna Capital•More Software Engineer•Akuna Capital Software Engineer•Akuna Capital System Design•Software Engineer System Design
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.