> ## Documentation Index
> Fetch the complete documentation index at: https://docs.searchcompany.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Architecture for the Remove Competitor endpoint

## Purpose

Removes a user-added competitor from the Explore tab. Auto-discovered competitors cannot be removed.

## Architecture

```mermaid theme={null}
flowchart TD
    Request["DELETE /api/explore/competitor/{competitor_id}"]
    
    subgraph validation [Validation]
        CheckExists["Check competitor exists"]
        CheckSource["Verify source='user_added'"]
    end
    
    subgraph db [Database]
        Competitors["competitors table"]
    end
    
    Request --> CheckExists
    CheckExists --> CheckSource
    CheckSource -->|"user_added"| Delete["Delete from DB"]
    CheckSource -->|"auto_discovered"| Error["Return error"]
    Delete --> Response
```

## Deletion Rules

| Source            | Can Delete? |
| ----------------- | ----------- |
| `user_added`      | Yes         |
| `auto_discovered` | No          |
| `own_business`    | No          |

## Response Format

Success:

```json theme={null}
{
  "status": "success",
  "message": "Removed Competitor Name"
}
```

Error:

```json theme={null}
{
  "status": "error",
  "error": "Cannot remove auto-discovered competitors"
}
```

## Code Location

```
src/app/apis/explore/remove_competitor/routes.py
```
