{
    "openapi": "3.0.0",
    "info": {
        "title": "Election MS API",
        "description": "API documentation for the Election Management System",
        "version": "1.0.0"
    },
    "paths": {
        "/api/candidates": {
            "get": {
                "tags": [
                    "Candidates"
                ],
                "summary": "Get all candidates",
                "operationId": "c05cd65a3a82fb13680e02a577ca9bd6",
                "responses": {
                    "200": {
                        "description": "List of candidates retrieved successfully"
                    }
                }
            },
            "post": {
                "tags": [
                    "Candidates"
                ],
                "summary": "Create a new candidate",
                "operationId": "e57aa026db5a266bc1a38bc5b7eedce0",
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "required": [
                                    "full_name",
                                    "party_id"
                                ],
                                "properties": {
                                    "full_name": {
                                        "type": "string",
                                        "example": "John Doe"
                                    },
                                    "party_id": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "bio": {
                                        "type": "string",
                                        "example": "Experienced political leader"
                                    },
                                    "photo": {
                                        "description": "Candidate photo (jpeg, png, jpg)",
                                        "type": "string",
                                        "format": "binary"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Candidate created successfully"
                    },
                    "422": {
                        "description": "Validation error"
                    }
                }
            }
        },
        "/api/candidates/{id}": {
            "get": {
                "tags": [
                    "Candidates"
                ],
                "summary": "Get a single candidate by ID",
                "operationId": "ee1893b31a639f1e4d96cbb6e2a855c1",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Candidate ID",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "example": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Candidate retrieved successfully"
                    },
                    "404": {
                        "description": "Candidate not found"
                    }
                }
            },
            "put": {
                "tags": [
                    "Candidates"
                ],
                "summary": "Update an existing candidate",
                "operationId": "bd6ff4a39e368a20fdcbedc8d74b21b0",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Candidate ID",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "example": 1
                        }
                    }
                ],
                "requestBody": {
                    "required": false,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "properties": {
                                    "full_name": {
                                        "type": "string",
                                        "example": "John D. Doe"
                                    },
                                    "party_id": {
                                        "type": "integer",
                                        "example": 2
                                    },
                                    "bio": {
                                        "type": "string",
                                        "example": "Updated candidate bio"
                                    },
                                    "photo": {
                                        "description": "New candidate photo",
                                        "type": "string",
                                        "format": "binary"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Candidate updated successfully"
                    },
                    "404": {
                        "description": "Candidate not found"
                    }
                }
            },
            "delete": {
                "tags": [
                    "Candidates"
                ],
                "summary": "Delete a candidate",
                "operationId": "93615c1f677171fecd7fff894cae45b5",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Candidate ID",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "example": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Candidate deleted successfully"
                    },
                    "404": {
                        "description": "Candidate not found"
                    }
                }
            }
        },
        "/api/countries": {
            "get": {
                "tags": [
                    "Countries"
                ],
                "summary": "Get all countries",
                "operationId": "bbb90b9e86a9cab92aaa448fe98954c9",
                "responses": {
                    "200": {
                        "description": "List of all countries",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": true
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "properties": {
                                                    "id": {
                                                        "type": "integer",
                                                        "example": 1
                                                    },
                                                    "name": {
                                                        "type": "string",
                                                        "example": "Nigeria"
                                                    },
                                                    "capital": {
                                                        "type": "string",
                                                        "example": "Abuja"
                                                    },
                                                    "created_at": {
                                                        "type": "string",
                                                        "example": "2025-10-27T12:00:00Z"
                                                    }
                                                },
                                                "type": "object"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "tags": [
                    "Countries"
                ],
                "summary": "Add a new country",
                "operationId": "575eed1b82f384d950b5b4541e3f2c50",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "name",
                                    "capital"
                                ],
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "example": "Nigeria"
                                    },
                                    "capital": {
                                        "type": "string",
                                        "example": "Abuja"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Country created successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": true
                                        },
                                        "data": {
                                            "properties": {
                                                "id": {
                                                    "type": "integer",
                                                    "example": 5
                                                },
                                                "name": {
                                                    "type": "string",
                                                    "example": "Ghana"
                                                },
                                                "capital": {
                                                    "type": "string",
                                                    "example": "Accra"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/countries/{id}": {
            "get": {
                "tags": [
                    "Countries"
                ],
                "summary": "Get a single country by ID",
                "operationId": "c172dfb1b3785a376f52b0f46f344f20",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "ID of the country",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "example": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Country found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": true
                                        },
                                        "data": {
                                            "properties": {
                                                "id": {
                                                    "type": "integer",
                                                    "example": 1
                                                },
                                                "name": {
                                                    "type": "string",
                                                    "example": "Nigeria"
                                                },
                                                "capital": {
                                                    "type": "string",
                                                    "example": "Abuja"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Country not found"
                    }
                }
            },
            "put": {
                "tags": [
                    "Countries"
                ],
                "summary": "Update a country",
                "operationId": "0c6426c4d0dfc8c5a372bad4825a38bc",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Country ID",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "example": 1
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "example": "Republic of Nigeria"
                                    },
                                    "capital": {
                                        "type": "string",
                                        "example": "Abuja"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Country updated successfully"
                    },
                    "404": {
                        "description": "Country not found"
                    }
                }
            },
            "delete": {
                "tags": [
                    "Countries"
                ],
                "summary": "Delete a country",
                "operationId": "47110a2e95266d7e013ca957c8e9dbb3",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Country ID",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "example": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Country deleted successfully"
                    },
                    "403": {
                        "description": "Unauthorized"
                    },
                    "404": {
                        "description": "Country not found"
                    }
                }
            }
        },
        "/api/countries/upload": {
            "post": {
                "tags": [
                    "Countries"
                ],
                "summary": "Upload countries in bulk via CSV (queued job)",
                "operationId": "c04358e45a25a61cf164fe888a5b5f04",
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "required": [
                                    "file"
                                ],
                                "properties": {
                                    "file": {
                                        "description": "CSV file to upload",
                                        "type": "string",
                                        "format": "binary"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Upload queued successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": true
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "Upload queued successfully. The system will process it in the background."
                                        },
                                        "path": {
                                            "type": "string",
                                            "example": "uploads/csv/countries.csv"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Invalid file upload"
                    }
                }
            }
        },
        "/api/elections": {
            "get": {
                "tags": [
                    "Elections"
                ],
                "summary": "List all elections",
                "operationId": "ca4ca296d5a15d40e45f1211964595b0",
                "responses": {
                    "200": {
                        "description": "List of elections"
                    }
                }
            },
            "post": {
                "tags": [
                    "Elections"
                ],
                "summary": "Create a new election with positions and candidates",
                "operationId": "1c31b3ecb371969da6861c2c087c9938",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "title",
                                    "level",
                                    "start_date",
                                    "end_date"
                                ],
                                "properties": {
                                    "title": {
                                        "type": "string",
                                        "example": "2027 General Election"
                                    },
                                    "level": {
                                        "description": "country | state | lga",
                                        "type": "string",
                                        "example": "country"
                                    },
                                    "country_id": {
                                        "type": "integer",
                                        "example": 125
                                    },
                                    "state_id": {
                                        "type": "integer",
                                        "example": null
                                    },
                                    "lga_id": {
                                        "type": "integer",
                                        "example": null
                                    },
                                    "is_general": {
                                        "type": "boolean",
                                        "example": true
                                    },
                                    "start_date": {
                                        "type": "string",
                                        "format": "date",
                                        "example": "2027-02-15"
                                    },
                                    "end_date": {
                                        "type": "string",
                                        "format": "date",
                                        "example": "2027-02-20"
                                    },
                                    "positions": {
                                        "type": "array",
                                        "items": {
                                            "properties": {
                                                "name": {
                                                    "type": "string",
                                                    "example": "President"
                                                },
                                                "voting_date": {
                                                    "type": "string",
                                                    "format": "date",
                                                    "example": "2027-02-16"
                                                },
                                                "candidates": {
                                                    "type": "array",
                                                    "items": {
                                                        "properties": {
                                                            "candidate_id": {
                                                                "type": "integer",
                                                                "example": 1
                                                            },
                                                            "party_id": {
                                                                "type": "integer",
                                                                "example": 1
                                                            },
                                                            "votes": {
                                                                "type": "integer",
                                                                "example": 0
                                                            }
                                                        },
                                                        "type": "object"
                                                    }
                                                }
                                            },
                                            "type": "object"
                                        }
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Election created successfully"
                    },
                    "422": {
                        "description": "Validation error"
                    }
                }
            }
        },
        "/api/elections/{id}": {
            "get": {
                "tags": [
                    "Elections"
                ],
                "summary": "Get a specific election with positions and candidates",
                "operationId": "731ee386dc98398ac7f9e2edb316da31",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Election details"
                    },
                    "404": {
                        "description": "Election not found"
                    }
                }
            },
            "delete": {
                "tags": [
                    "Elections"
                ],
                "summary": "Delete an election and all related data",
                "operationId": "6d170c34bba19b80e50456f4edaad19b",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Election deleted successfully"
                    },
                    "404": {
                        "description": "Election not found"
                    }
                }
            }
        },
        "/api/elections/{id}/details": {
            "get": {
                "tags": [
                    "Elections"
                ],
                "summary": "Get full details for an election including locations, parties, positions, and candidates",
                "operationId": "ffa0ea718f4243aba2e9a95cd07de731",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Election details with locations, parties, positions, and candidates"
                    },
                    "404": {
                        "description": "Election not found"
                    }
                }
            }
        },
        "/api/election-results": {
            "post": {
                "tags": [
                    "Election Results"
                ],
                "summary": "Submit polling unit results (restricted to authorized agents)",
                "operationId": "57c9cf5de0f992b5c9891626f0d13b60",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "election_id",
                                    "position_id",
                                    "polling_unit_id",
                                    "results"
                                ],
                                "properties": {
                                    "election_id": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "position_id": {
                                        "type": "integer",
                                        "example": 2
                                    },
                                    "polling_unit_id": {
                                        "type": "integer",
                                        "example": 45
                                    },
                                    "results": {
                                        "type": "array",
                                        "items": {
                                            "properties": {
                                                "party_id": {
                                                    "type": "integer",
                                                    "example": 3
                                                },
                                                "votes": {
                                                    "type": "integer",
                                                    "example": 120
                                                }
                                            },
                                            "type": "object"
                                        }
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Results submitted successfully"
                    },
                    "403": {
                        "description": "Unauthorized access"
                    },
                    "422": {
                        "description": "Validation error"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/election-results/summary/{election_id}": {
            "get": {
                "tags": [
                    "Election Results"
                ],
                "summary": "Get election summary (total votes per party)",
                "operationId": "e4b24b0f9b223d5c4815ae2421ca48aa",
                "parameters": [
                    {
                        "name": "election_id",
                        "in": "path",
                        "description": "Election ID",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Election summary retrieved successfully"
                    },
                    "404": {
                        "description": "Election not found"
                    }
                }
            }
        },
        "/api/election-results/ward/{ward_id}": {
            "get": {
                "tags": [
                    "Election Results"
                ],
                "summary": "Get results summary for a specific ward",
                "operationId": "cd2d798fb5370a461af59132d3513544",
                "parameters": [
                    {
                        "name": "ward_id",
                        "in": "path",
                        "description": "Ward ID",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Ward summary retrieved successfully"
                    },
                    "404": {
                        "description": "Ward not found"
                    }
                }
            }
        },
        "/api/election-results/{id}/verify": {
            "post": {
                "tags": [
                    "Election Results"
                ],
                "summary": "Approve or reject submitted polling unit result",
                "operationId": "d83ea7c721bc0ce1760aa57b66191ff3",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "Election result ID",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "status"
                                ],
                                "properties": {
                                    "status": {
                                        "type": "string",
                                        "enum": [
                                            "approved",
                                            "rejected"
                                        ],
                                        "example": "approved"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Result verified successfully"
                    },
                    "403": {
                        "description": "Unauthorized"
                    },
                    "404": {
                        "description": "Result not found"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/lgas": {
            "get": {
                "tags": [
                    "LGAs"
                ],
                "summary": "List all LGAs",
                "operationId": "ab8103fb9eb3dcd11e09813fe4de343c",
                "responses": {
                    "200": {
                        "description": "List of LGAs"
                    }
                }
            },
            "post": {
                "tags": [
                    "LGAs"
                ],
                "summary": "Create a new LGA",
                "operationId": "92579bc9879f15acb848647b0c67c56a",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "state_id",
                                    "name",
                                    "head_quarter"
                                ],
                                "properties": {
                                    "state_id": {
                                        "type": "integer"
                                    },
                                    "name": {
                                        "type": "string"
                                    },
                                    "head_quarter": {
                                        "type": "string"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "LGA created successfully"
                    },
                    "400": {
                        "description": "Validation error"
                    }
                }
            }
        },
        "/api/lgas/by-state/{state_id}": {
            "get": {
                "tags": [
                    "LGAs"
                ],
                "summary": "List all LGAs by State ID",
                "operationId": "a7c64c53870312c8c6c9149ea6b8fea5",
                "parameters": [
                    {
                        "name": "state_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "List of LGAs for the specified state"
                    },
                    "404": {
                        "description": "No LGAs found for this state"
                    }
                }
            }
        },
        "/api/lgas/{id}": {
            "get": {
                "tags": [
                    "LGAs"
                ],
                "summary": "Get details of a specific LGA",
                "operationId": "2d9eb2bed92a7a1fb2a60d7d0cd4aefb",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "LGA details"
                    },
                    "404": {
                        "description": "LGA not found"
                    }
                }
            },
            "put": {
                "tags": [
                    "LGAs"
                ],
                "summary": "Update an LGA",
                "operationId": "6c43ac6d9c4d4abbb6c804c404bf778e",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "properties": {
                                    "state_id": {
                                        "type": "integer"
                                    },
                                    "name": {
                                        "type": "string"
                                    },
                                    "head_quarter": {
                                        "type": "string"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "LGA updated successfully"
                    },
                    "404": {
                        "description": "LGA not found"
                    }
                }
            },
            "delete": {
                "tags": [
                    "LGAs"
                ],
                "summary": "Delete an LGA",
                "operationId": "e4306bc7dfab172cbd1c7ce570f06685",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "LGA deleted successfully"
                    },
                    "404": {
                        "description": "LGA not found"
                    }
                }
            }
        },
        "/api/lgas/upload-csv": {
            "post": {
                "tags": [
                    "LGAs"
                ],
                "summary": "Upload LGAs from CSV file",
                "description": "Upload a CSV file containing LGAs (columns: state_id, name, head_quarter).",
                "operationId": "e7d76aac66b222336e614e114a9f0258",
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "properties": {
                                    "file": {
                                        "type": "string",
                                        "format": "binary"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "File uploaded successfully"
                    },
                    "400": {
                        "description": "Validation error"
                    }
                }
            }
        },
        "/api/parties": {
            "get": {
                "tags": [
                    "Parties"
                ],
                "summary": "List all parties",
                "operationId": "4243ef8d982d9a99bf14fd4255bd0885",
                "responses": {
                    "200": {
                        "description": "List of political parties"
                    }
                }
            },
            "post": {
                "tags": [
                    "Parties"
                ],
                "summary": "Create a new political party",
                "operationId": "525c52849c76322feb4bb19f628d8927",
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "required": [
                                    "name",
                                    "abbreviation",
                                    "color"
                                ],
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "example": "People's Unity Party"
                                    },
                                    "abbreviation": {
                                        "type": "string",
                                        "example": "PUP"
                                    },
                                    "color": {
                                        "type": "string",
                                        "example": "#FF0000"
                                    },
                                    "logo": {
                                        "description": "Party logo image",
                                        "type": "string",
                                        "format": "binary"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Party created successfully"
                    },
                    "400": {
                        "description": "Validation error"
                    }
                }
            }
        },
        "/api/parties/{id}": {
            "get": {
                "tags": [
                    "Parties"
                ],
                "summary": "Get a specific political party",
                "operationId": "2d09ee4d9a8adb565e4c9f4e96d39e98",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Party details"
                    },
                    "404": {
                        "description": "Party not found"
                    }
                }
            },
            "post": {
                "tags": [
                    "Parties"
                ],
                "summary": "Update a political party (use _method=PUT for file uploads)",
                "description": "Update an existing party details or logo. Use multipart/form-data with _method=PUT.",
                "operationId": "2c44199372990ef7f785895470932790",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "properties": {
                                    "_method": {
                                        "type": "string",
                                        "example": "PUT"
                                    },
                                    "name": {
                                        "type": "string",
                                        "example": "People's Unity Party"
                                    },
                                    "abbreviation": {
                                        "type": "string",
                                        "example": "PUP"
                                    },
                                    "color": {
                                        "type": "string",
                                        "example": "#FF0000"
                                    },
                                    "logo": {
                                        "description": "Updated logo image",
                                        "type": "string",
                                        "format": "binary"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Party updated successfully"
                    },
                    "404": {
                        "description": "Party not found"
                    }
                }
            },
            "delete": {
                "tags": [
                    "Parties"
                ],
                "summary": "Delete a political party",
                "operationId": "1d0d07fdaa280456dc6b4e933157add4",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Party deleted successfully"
                    },
                    "404": {
                        "description": "Party not found"
                    }
                }
            }
        },
        "/api/polling-units": {
            "get": {
                "tags": [
                    "PollingUnits"
                ],
                "summary": "List all polling units",
                "operationId": "f60a562bf35c96af282afd50863b2eee",
                "responses": {
                    "200": {
                        "description": "List of polling units"
                    }
                }
            },
            "post": {
                "tags": [
                    "PollingUnits"
                ],
                "summary": "Create a new polling unit",
                "operationId": "e86a1b284b8bee077475e341fcd0ed70",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "ward_id",
                                    "name"
                                ],
                                "properties": {
                                    "ward_id": {
                                        "type": "integer"
                                    },
                                    "name": {
                                        "type": "string"
                                    },
                                    "delimitation": {
                                        "type": "string",
                                        "example": "29-01-01-001"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Polling unit created successfully"
                    },
                    "400": {
                        "description": "Validation error"
                    }
                }
            }
        },
        "/api/polling-units/{id}": {
            "get": {
                "tags": [
                    "PollingUnits"
                ],
                "summary": "Get a specific polling unit",
                "operationId": "bff14d521496bfff090ad551ec22af66",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Polling unit details"
                    },
                    "404": {
                        "description": "Polling unit not found"
                    }
                }
            },
            "put": {
                "tags": [
                    "PollingUnits"
                ],
                "summary": "Update a polling unit",
                "operationId": "75fe02523b9539b5bc046014ad7c4808",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "properties": {
                                    "ward_id": {
                                        "type": "integer"
                                    },
                                    "name": {
                                        "type": "string"
                                    },
                                    "delimitation": {
                                        "type": "string",
                                        "example": "29-01-01-001"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Polling unit updated successfully"
                    },
                    "404": {
                        "description": "Polling unit not found"
                    }
                }
            },
            "delete": {
                "tags": [
                    "PollingUnits"
                ],
                "summary": "Delete a polling unit",
                "operationId": "4c30ff5a38609d5f9d05527f0f5e52e1",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Polling unit deleted successfully"
                    },
                    "404": {
                        "description": "Polling unit not found"
                    }
                }
            }
        },
        "/api/polling-units/by-ward/{ward_id}": {
            "get": {
                "tags": [
                    "PollingUnits"
                ],
                "summary": "Get all polling units by Ward ID",
                "description": "Fetch all polling units that belong to a specific ward",
                "operationId": "d403810371f2b50a3cc2532b14c43682",
                "parameters": [
                    {
                        "name": "ward_id",
                        "in": "path",
                        "description": "The ID of the ward",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "List of polling units in the specified ward"
                    },
                    "404": {
                        "description": "No polling units found for this ward"
                    }
                }
            }
        },
        "/api/polling-units/upload-csv": {
            "post": {
                "tags": [
                    "PollingUnits"
                ],
                "summary": "Upload a CSV file to bulk create polling units",
                "operationId": "1e40fcd8ff4e92ef0ef3da7afa5b0294",
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "properties": {
                                    "file": {
                                        "description": "CSV file containing polling units (including delimitation column)",
                                        "type": "string",
                                        "format": "binary"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "CSV queued for processing"
                    },
                    "400": {
                        "description": "Validation error"
                    }
                }
            }
        },
        "/api/states": {
            "get": {
                "tags": [
                    "States"
                ],
                "summary": "List states",
                "operationId": "17bd4db48fba840a5f9f9ecf1543d4c5",
                "responses": {
                    "200": {
                        "description": "List of states",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": true
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "properties": {
                                                    "id": {
                                                        "type": "integer",
                                                        "example": 1
                                                    },
                                                    "country_id": {
                                                        "type": "integer",
                                                        "example": 1
                                                    },
                                                    "name": {
                                                        "type": "string",
                                                        "example": "Lagos"
                                                    },
                                                    "capital": {
                                                        "type": "string",
                                                        "example": "Ikeja"
                                                    }
                                                },
                                                "type": "object"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "tags": [
                    "States"
                ],
                "summary": "Create state",
                "operationId": "75eb161b2b554948cd6b6be777929de1",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "country_id",
                                    "name",
                                    "capital"
                                ],
                                "properties": {
                                    "country_id": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "name": {
                                        "type": "string",
                                        "example": "Lagos"
                                    },
                                    "capital": {
                                        "type": "string",
                                        "example": "Ikeja"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "State created successfully"
                    },
                    "400": {
                        "description": "Validation error"
                    }
                }
            }
        },
        "/api/states/by-country/{country_id}": {
            "get": {
                "tags": [
                    "States"
                ],
                "summary": "Get states by country ID",
                "operationId": "a682b065343ca8ef83f557e23f4179fa",
                "parameters": [
                    {
                        "name": "country_id",
                        "in": "path",
                        "description": "Country ID to fetch states for",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "List of states for the given country",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": true
                                        },
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "properties": {
                                                    "id": {
                                                        "type": "integer",
                                                        "example": 1
                                                    },
                                                    "country_id": {
                                                        "type": "integer",
                                                        "example": 1
                                                    },
                                                    "name": {
                                                        "type": "string",
                                                        "example": "Ogun"
                                                    },
                                                    "capital": {
                                                        "type": "string",
                                                        "example": "Abeokuta"
                                                    }
                                                },
                                                "type": "object"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "No states found for this country"
                    }
                }
            }
        },
        "/api/states/{id}": {
            "get": {
                "tags": [
                    "States"
                ],
                "summary": "Get state by id",
                "operationId": "c230b55677877b2ad51a4229fcbbae4c",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "State ID",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "State found"
                    },
                    "404": {
                        "description": "State not found"
                    }
                }
            },
            "put": {
                "tags": [
                    "States"
                ],
                "summary": "Update state",
                "operationId": "d74aee8901d04aeb0f7c2a74f5a6e545",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "State ID",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "properties": {
                                    "country_id": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "name": {
                                        "type": "string",
                                        "example": "Ogun"
                                    },
                                    "capital": {
                                        "type": "string",
                                        "example": "Abeokuta"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "State updated successfully"
                    },
                    "404": {
                        "description": "State not found"
                    },
                    "400": {
                        "description": "Validation error"
                    }
                }
            },
            "delete": {
                "tags": [
                    "States"
                ],
                "summary": "Delete state",
                "operationId": "96dbbca41c32a1dd00291d319c7fbd1e",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "State ID",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "State deleted successfully"
                    },
                    "404": {
                        "description": "State not found"
                    }
                }
            }
        },
        "/api/states/upload-csv": {
            "post": {
                "tags": [
                    "States"
                ],
                "summary": "Upload states CSV (queued)",
                "description": "Upload a CSV with columns: country_id,name,capital. File is processed in background.",
                "operationId": "87ad484c922c9354266d76bab61b1d47",
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "required": [
                                    "file"
                                ],
                                "properties": {
                                    "file": {
                                        "type": "string",
                                        "format": "binary"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "202": {
                        "description": "File accepted and queued for processing"
                    },
                    "400": {
                        "description": "Validation error"
                    }
                }
            }
        },
        "/api/wards": {
            "get": {
                "tags": [
                    "Wards"
                ],
                "summary": "List all wards",
                "operationId": "137e26407b4ea73d48e0f237d680ec69",
                "responses": {
                    "200": {
                        "description": "List of wards"
                    }
                }
            },
            "post": {
                "tags": [
                    "Wards"
                ],
                "summary": "Create a new ward",
                "operationId": "fb0bce233f5d654e01e558062610eb57",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "country_id",
                                    "state_id",
                                    "lga_id",
                                    "name"
                                ],
                                "properties": {
                                    "country_id": {
                                        "type": "integer"
                                    },
                                    "state_id": {
                                        "type": "integer"
                                    },
                                    "lga_id": {
                                        "type": "integer"
                                    },
                                    "name": {
                                        "type": "string"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Ward created successfully"
                    },
                    "400": {
                        "description": "Validation error"
                    }
                }
            }
        },
        "/api/wards/{id}": {
            "get": {
                "tags": [
                    "Wards"
                ],
                "summary": "Get a specific ward",
                "operationId": "1ac49ba971c0e78e0d3d2a6ee525fc3d",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Ward details"
                    },
                    "404": {
                        "description": "Ward not found"
                    }
                }
            },
            "put": {
                "tags": [
                    "Wards"
                ],
                "summary": "Update a ward",
                "operationId": "2f765f7caf9be4ad50107ed815118de3",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "properties": {
                                    "country_id": {
                                        "type": "integer"
                                    },
                                    "state_id": {
                                        "type": "integer"
                                    },
                                    "lga_id": {
                                        "type": "integer"
                                    },
                                    "name": {
                                        "type": "string"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Ward updated successfully"
                    },
                    "404": {
                        "description": "Ward not found"
                    }
                }
            },
            "delete": {
                "tags": [
                    "Wards"
                ],
                "summary": "Delete a ward",
                "operationId": "a94b4b4bfeb68cee2e48079d2689c502",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Ward deleted successfully"
                    },
                    "404": {
                        "description": "Ward not found"
                    }
                }
            }
        },
        "/api/wards/by-lga/{lga_id}": {
            "get": {
                "tags": [
                    "Wards"
                ],
                "summary": "Get all wards by LGA ID",
                "description": "Fetch all wards that belong to a specific LGA",
                "operationId": "bc7e14f07ebf855eb4a6ad633195e82d",
                "parameters": [
                    {
                        "name": "lga_id",
                        "in": "path",
                        "description": "The ID of the LGA",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "List of wards in the specified LGA"
                    },
                    "404": {
                        "description": "No wards found for this LGA"
                    }
                }
            }
        },
        "/api/wards/upload-csv": {
            "post": {
                "tags": [
                    "Wards"
                ],
                "summary": "Upload a CSV file to bulk create wards",
                "operationId": "0483d3cd659385b6b0e736d8ab69dd09",
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "properties": {
                                    "file": {
                                        "description": "CSV file containing wards with columns: country_id, state_id, lga_id, name",
                                        "type": "string",
                                        "format": "binary"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "CSV queued for processing"
                    },
                    "400": {
                        "description": "Validation error"
                    }
                }
            }
        },
        "/api/login": {
            "post": {
                "tags": [
                    "Authentication"
                ],
                "summary": "Authenticate user and generate JWT token",
                "description": "Logs a user in using email and password and returns a JWT token.",
                "operationId": "bc76a9d52929cab7a147ca7b5c527430",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "email",
                                    "password"
                                ],
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "example": "user@example.com"
                                    },
                                    "password": {
                                        "type": "string",
                                        "example": "password123"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Successfully logged in",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "access_token": {
                                            "type": "string"
                                        },
                                        "token_type": {
                                            "type": "string",
                                            "example": "bearer"
                                        },
                                        "expires_in": {
                                            "type": "integer",
                                            "example": 3600
                                        },
                                        "user": {
                                            "properties": {
                                                "id": {
                                                    "type": "integer"
                                                },
                                                "email": {
                                                    "type": "string"
                                                },
                                                "name": {
                                                    "type": "string"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Invalid credentials"
                    }
                }
            }
        },
        "/api/me": {
            "get": {
                "tags": [
                    "Authentication"
                ],
                "summary": "Get current authenticated user",
                "description": "Returns the authenticated user's information.",
                "operationId": "7f778258b4b440fe40572651685be997",
                "responses": {
                    "200": {
                        "description": "Authenticated user data",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "id": {
                                            "type": "integer"
                                        },
                                        "name": {
                                            "type": "string"
                                        },
                                        "email": {
                                            "type": "string"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/logout": {
            "post": {
                "tags": [
                    "Authentication"
                ],
                "summary": "Logout user",
                "description": "Logs out the authenticated user by invalidating the JWT token.",
                "operationId": "0ab4e3cf7bc4f7ec81b48f7928c7de7c",
                "responses": {
                    "200": {
                        "description": "Successfully logged out",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "example": "Successfully logged out"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/refresh": {
            "post": {
                "tags": [
                    "Authentication"
                ],
                "summary": "Refresh JWT token",
                "description": "Generates a new token for the authenticated user.",
                "operationId": "158b81fb931dd5ece59b921dafb287db",
                "responses": {
                    "200": {
                        "description": "Token refreshed successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "access_token": {
                                            "type": "string"
                                        },
                                        "token_type": {
                                            "type": "string",
                                            "example": "bearer"
                                        },
                                        "expires_in": {
                                            "type": "integer"
                                        },
                                        "user": {
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "bearerFormat": "JWT",
                "description": "Enter token in format **Bearer <token>**"
            }
        }
    },
    "tags": [
        {
            "name": "Candidates",
            "description": "API Endpoints for managing election candidates"
        },
        {
            "name": "Countries",
            "description": "API Endpoints for managing countries"
        },
        {
            "name": "Elections",
            "description": "Manage elections, positions, and assigned candidates"
        },
        {
            "name": "Election Results",
            "description": "Record, verify, and summarize polling unit results"
        },
        {
            "name": "LGAs",
            "description": "API Endpoints for managing Local Government Areas"
        },
        {
            "name": "Parties",
            "description": "API Endpoints for managing political parties"
        },
        {
            "name": "PollingUnits",
            "description": "API Endpoints for managing Polling Units"
        },
        {
            "name": "States",
            "description": "API Endpoints for managing states"
        },
        {
            "name": "Wards",
            "description": "API Endpoints for managing Wards"
        },
        {
            "name": "Authentication",
            "description": "Authentication"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        }
    ]
}