Skip to content
Middle+0 views

Design a platform for handling complaints about product quality, including photos, returns, and disputes between sellers and buyers.

Practice

Asked at

AI answer

Architecture

I would divide the platform into client applications (buyer, seller, operators) and a backend API. For the first version, I’d use a modular monolith with clearly defined domain boundaries; as the load grows, the most heavily loaded parts can be split out into services.

Main modules:

  • Complaints: create a case, product, order, defect description, deadlines, and statuses.
  • Media: upload and store photos, validate format and size, and generate thumbnails.
  • Returns: check return eligibility, create a request, and integrate with payment and logistics systems.
  • Disputes: exchange arguments and evidence, reach a seller decision or escalate to an operator, and maintain an activity log.
  • Notifications: email, push, or SMS notifications about status changes and new messages.

Processing flow

  1. The buyer creates a complaint and attaches photos.
  2. The backend checks the order and return rules, saves the case, and issues a temporary file upload link.
  3. Files are stored in object storage; an asynchronous task checks the file type, size, and malicious content, then creates safe previews.
  4. The seller is notified and responds or offers a return/refund.
  5. If the parties cannot reach an agreement, the case is escalated to an operator. The decision is recorded along with its author, timestamp, and rationale.
  6. The return is processed through external systems using an idempotent request; integration failures are retried or sent to a manual processing queue.

Data and reliability

A relational database is suitable for orders, complaints, messages, statuses, and audit records: transactions and relationships are needed. Photos are better stored in object storage, with the key, size, type, and checksum kept in the database. Status-change events and requests to external systems are processed through a queue; a transactional outbox can be used to maintain consistency between the database and the queue. Return and complaint-creation operations must be idempotent.

Define an explicit state machine, for example: New → Awaiting seller → Awaiting buyer → Under review → Resolved/Closed. Transitions are validated on the server. Long-running processes need timeouts, reminders, and escalation.

Security and operations

  • Check access permissions at the case level: buyers can see their own complaints, sellers can see only those related to their orders, and operators can access cases within their assigned permissions.
  • Use TLS, storage encryption, time-limited links to photos, and antivirus scanning. Do not trust the MIME type provided by the client; limit the size and number of files.
  • Maintain an immutable audit trail of decisions and actions involving personal data; establish retention and deletion periods.
  • Metrics: seller response time, escalation rate, return duration, upload errors, and integration errors. Add centralized logs, tracing, and alerts.
  • Deploy through CI/CD with tests, database migrations, staging, and gradual releases; maintain backups and tested recovery procedures.

At the start, correct statuses, auditing, secure handling of photos, and reliable return integrations matter more than prematurely splitting the system into many microservices.