{
  "app": {
    "name": "Mokabla",
    "url": "https://www.mokabla.com",
    "description": "Real interview questions from companies in Egypt, organised by company. Access is sold per company for 30 days."
  },
  "page": {
    "kind": "question",
    "title": "Question · top-products-and-slow-endpoint-coding-challenge",
    "humanPath": "/en/c/rabbit/top-products-and-slow-endpoint-coding-challenge",
    "humanOnly": false
  },
  "identity": {
    "class": "declared",
    "agent": "ClaudeBot",
    "operator": "Anthropic",
    "verified": false,
    "reason": "The user agent is ClaudeBot (Anthropic), which identifies itself as an AI agent.",
    "signals": [
      "Known agent user agent"
    ],
    "claimable": false
  },
  "state": {
    "question": {
      "slug": "top-products-and-slow-endpoint-coding-challenge",
      "title": "Top Products and Slow Endpoint Coding Challenge",
      "difficulty": "medium",
      "tags": [
        "system-design",
        "sql",
        "backend",
        "take-home"
      ],
      "is_free": true,
      "locked": false,
      "frequency": 1,
      "last_reported_at": "2025-01-22T08:38:49.094595Z",
      "url": "https://www.mokabla.com/en/c/rabbit/top-products-and-slow-endpoint-coding-challenge",
      "agent": {
        "page": "https://www.mokabla.com/agent/en/c/rabbit/top-products-and-slow-endpoint-coding-challenge",
        "question": "https://www.mokabla.com/agent/_call/get_question?company=rabbit&question=top-products-and-slow-endpoint-coding-challenge"
      },
      "company": {
        "slug": "rabbit",
        "name_en": "Rabbit"
      },
      "body_md": "## What they ask\n\nBackend candidates receive a coding challenge sized at three to four hours, delivered as a repository from the company's own GitHub organisation: a NestJS project with Prisma, a seed script, and a `package.json` you are told to read carefully because some of the installed libraries are there to help you. You bring any SQL database (Postgres or MySQL). Two requirements:\n\n1. **Top 10 most ordered products in an area.** A new endpoint for the app's home screen that returns the ten products ordered most often in a given area or region. It will be hit millions of times, so design it for that.\n2. **Fix the slow products listing.** The existing `GET /products` is deliberately badly written: inefficient queries and poor practices. Review it, refactor it, and you may change the request and response contracts (DTOs, filters) if that makes it faster and more reliable.\n\nPlus tests that prove the top-10 endpoint is correct, documentation of your assumptions, and a note on what you would do with more time. Optional bonus: send a push notification (Pushover is suggested) when a new order is created. Submit as a public GitHub or GitLab link. The business framing in the brief: multiple stores across the region, thousands of orders a day.\n\nThe challenge is announced after the HR call. One senior candidate's \"coding challenge\" slot turned out to be a system design conversation instead, so confirm which one you are getting.\n\n## What they look for\n\n- The top-10 query done with an aggregate and an index (or a precomputed table) rather than loading orders into memory, and cached, since the data changes slowly and the traffic is huge; Redis through the cache manager already listed in `package.json` is the expected move.\n- The products endpoint fixed at the root: pagination, selecting only the needed columns, no N+1, filters pushed into the query, cursor or offset chosen and justified.\n- Tests on the ranking itself: ties, areas with fewer than ten products, cancelled orders.\n- An assumptions section that says what \"area\" means in your model and how stale the cached top-10 is allowed to be.",
      "follow_ups_md": "- The top-10 must reflect a new order within a minute. What changes?\n- How would you invalidate the cache per area without a thundering herd at 7 pm?\n- Where does the notification bonus belong: the service, an event handler, or a queue?"
    },
    "paid": false,
    "access": "Question bodies are paid content: a person buys 30 days of access per company (200 EGP or 200 points) in the human app. Agents get titles, tags and difficulty; bodies only for free questions."
  },
  "actions": [
    {
      "name": "get_question",
      "description": "One question with its body. Bodies are paid content unless the question is free.",
      "permission": "allow",
      "sideEffect": "read",
      "input": {
        "company": "string",
        "question": "string"
      },
      "href": "https://www.mokabla.com/agent/_call/get_question?company=rabbit&question=top-products-and-slow-endpoint-coding-challenge",
      "ready": true,
      "missing": [],
      "humanPath": "https://www.mokabla.com/en/pricing"
    },
    {
      "name": "list_questions",
      "description": "The questions reported at a company: titles, tags, difficulty, whether each is free or paid.",
      "permission": "allow",
      "sideEffect": "read",
      "input": {
        "company": "string",
        "page": "number?"
      },
      "href": "https://www.mokabla.com/agent/_call/list_questions?company=rabbit",
      "ready": true,
      "missing": []
    },
    {
      "name": "buy_access",
      "description": "Buy 30 days of access to a company.",
      "permission": "block",
      "reason": "This action is for people only",
      "ruleId": "R1",
      "sideEffect": "payment",
      "input": {
        "company": "string"
      },
      "href": "https://www.mokabla.com/agent/_call/buy_access?company=rabbit",
      "ready": true,
      "missing": [],
      "humanPath": "https://www.mokabla.com/en/pricing"
    },
    {
      "name": "post_comment",
      "description": "Comment on a question.",
      "permission": "block",
      "reason": "This action is for people only",
      "ruleId": "R1",
      "sideEffect": "write",
      "input": {
        "question": "string",
        "text": "string"
      },
      "href": "https://www.mokabla.com/agent/_call/post_comment?question=top-products-and-slow-endpoint-coding-challenge",
      "ready": false,
      "missing": [
        "text"
      ],
      "humanPath": "https://www.mokabla.com/en/companies"
    }
  ],
  "navigate": [
    {
      "label": "This question, as data (free questions only)",
      "href": "https://www.mokabla.com/agent/_call/get_question?company=rabbit&question=top-products-and-slow-endpoint-coding-challenge"
    },
    {
      "label": "All questions at this company",
      "href": "https://www.mokabla.com/agent/_call/list_questions?company=rabbit"
    },
    {
      "label": "The company page",
      "href": "https://www.mokabla.com/agent/en/c/rabbit"
    },
    {
      "label": "Top Products and Slow Endpoint Coding Challenge · page",
      "href": "https://www.mokabla.com/agent/en/c/rabbit/top-products-and-slow-endpoint-coding-challenge"
    }
  ],
  "notices": [
    {
      "severity": "info",
      "message": "This classification is final for the session: it came from a strong signal, not a guess. The human pages are not served to agents."
    },
    {
      "severity": "info",
      "message": "Unverified agents are read-only. Signed requests (Web Bot Auth) are the path to write access."
    }
  ],
  "meta": {
    "requestId": "ag_cdb1d5869d16",
    "policyVersion": "mokabla-2026-11-03",
    "generatedAt": "2026-11-03T17:42:22.189Z",
    "jsonUrl": "https://www.mokabla.com/agent/en/c/rabbit/top-products-and-slow-endpoint-coding-challenge?format=json",
    "manifestUrl": "https://www.mokabla.com/.well-known/agentgate.json",
    "humanUrl": "https://www.mokabla.com/en/c/rabbit/top-products-and-slow-endpoint-coding-challenge",
    "humanClaimUrl": "https://www.mokabla.com/agent/_claim/human?to=%2Fen%2Fc%2Frabbit%2Ftop-products-and-slow-endpoint-coding-challenge"
  }
}