{
    "openapi": "3.0.0",
    "info": {
        "title": "School Management System API",
        "description": "REST API for the AI-powered School Management System. This API provides endpoints for managing students, teachers, grades, fees, exams, assignments, and marks.",
        "contact": {
            "name": "Dadansoft Support",
            "email": "support@dadansoft.com"
        },
        "version": "1.0.0"
    },
    "servers": [
        {
            "url": "/api",
            "description": "Main API Server"
        }
    ],
    "paths": {
        "/api/health": {
            "get": {
                "tags": [
                    "Authentication"
                ],
                "summary": "Health check endpoint",
                "description": "Check if the API is running",
                "operationId": "healthCheck",
                "responses": {
                    "200": {
                        "description": "API is running",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "ok"
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "School Management System API is running"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/login": {
            "post": {
                "tags": [
                    "Authentication"
                ],
                "summary": "User login",
                "description": "Authenticate user and receive access token",
                "operationId": "login",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "email",
                                    "password"
                                ],
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "example": "admin@school.com"
                                    },
                                    "password": {
                                        "type": "string",
                                        "format": "password",
                                        "example": "password123"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Login successful",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "token": {
                                            "type": "string",
                                            "example": "1|abc123..."
                                        },
                                        "user": {
                                            "type": "object"
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "تم تسجيل الدخول بنجاح"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Invalid credentials"
                    }
                }
            }
        },
        "/api/students": {
            "get": {
                "tags": [
                    "Students"
                ],
                "summary": "List all students",
                "description": "Get a paginated list of all students",
                "operationId": "listStudents",
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "description": "Page number",
                        "schema": {
                            "type": "integer",
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "description": "Items per page",
                        "schema": {
                            "type": "integer",
                            "default": 15
                        }
                    },
                    {
                        "name": "grade_id",
                        "in": "query",
                        "description": "Filter by grade",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    },
                    "401": {
                        "description": "Unauthenticated"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            },
            "post": {
                "tags": [
                    "Students"
                ],
                "summary": "Create a student",
                "description": "Create a new student record",
                "operationId": "createStudent",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "full_name",
                                    "grade_id"
                                ],
                                "properties": {
                                    "full_name": {
                                        "type": "string",
                                        "example": "أحمد محمد"
                                    },
                                    "email": {
                                        "type": "string",
                                        "format": "email"
                                    },
                                    "phone": {
                                        "type": "string"
                                    },
                                    "grade_id": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "gender": {
                                        "type": "string",
                                        "enum": [
                                            "male",
                                            "female"
                                        ]
                                    },
                                    "date_of_birth": {
                                        "type": "string",
                                        "format": "date"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Student created"
                    },
                    "422": {
                        "description": "Validation error"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/students/{id}": {
            "get": {
                "tags": [
                    "Students"
                ],
                "summary": "Get a student",
                "description": "Get details of a specific student",
                "operationId": "getStudent",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    },
                    "404": {
                        "description": "Student not found"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            },
            "put": {
                "tags": [
                    "Students"
                ],
                "summary": "Update a student",
                "description": "Update an existing student",
                "operationId": "updateStudent",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Student updated"
                    },
                    "404": {
                        "description": "Student not found"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            },
            "delete": {
                "tags": [
                    "Students"
                ],
                "summary": "Delete a student",
                "description": "Remove a student record",
                "operationId": "deleteStudent",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Student deleted"
                    },
                    "404": {
                        "description": "Student not found"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/fees": {
            "get": {
                "tags": [
                    "Fees"
                ],
                "summary": "List all fees",
                "operationId": "80fdece2e50824ed1b8860b80e0b71e8",
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            },
            "post": {
                "tags": [
                    "Fees"
                ],
                "summary": "Create a fee",
                "operationId": "aaa9b642a1dbd69c014e6e0e4d456d5a",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "title",
                                    "amount",
                                    "grade_id"
                                ],
                                "properties": {
                                    "title": {
                                        "type": "string",
                                        "example": "رسوم الفصل الأول"
                                    },
                                    "amount": {
                                        "type": "number",
                                        "example": 5000
                                    },
                                    "grade_id": {
                                        "type": "integer"
                                    },
                                    "due_date": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "description": {
                                        "type": "string"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Fee created"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/fees/students-summary": {
            "get": {
                "tags": [
                    "Fees"
                ],
                "summary": "Get student financial summary",
                "description": "Get financial status for all students",
                "operationId": "793ce8e017593547c475b66d9f8a60bf",
                "parameters": [
                    {
                        "name": "grade_id",
                        "in": "query",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/exams": {
            "get": {
                "tags": [
                    "Exams"
                ],
                "summary": "List all exams",
                "operationId": "2288b5213e73b42e81148d425620c8a5",
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            },
            "post": {
                "tags": [
                    "Exams"
                ],
                "summary": "Schedule an exam",
                "operationId": "1494baffd861f38ff753e238dafc7e36",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "title",
                                    "subject_id",
                                    "grade_id",
                                    "exam_date",
                                    "max_marks"
                                ],
                                "properties": {
                                    "title": {
                                        "type": "string",
                                        "example": "امتحان نهاية الفصل"
                                    },
                                    "subject_id": {
                                        "type": "integer"
                                    },
                                    "grade_id": {
                                        "type": "integer"
                                    },
                                    "exam_date": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "start_time": {
                                        "type": "string",
                                        "format": "time"
                                    },
                                    "end_time": {
                                        "type": "string",
                                        "format": "time"
                                    },
                                    "max_marks": {
                                        "type": "integer",
                                        "example": 100
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Exam scheduled"
                    },
                    "422": {
                        "description": "Schedule conflict"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/exams/upcoming": {
            "get": {
                "tags": [
                    "Exams"
                ],
                "summary": "Get upcoming exams",
                "operationId": "1dd785fa0328e678a40ce124a33f2480",
                "parameters": [
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "default": 10
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/exams/today": {
            "get": {
                "tags": [
                    "Exams"
                ],
                "summary": "Get today's exams",
                "operationId": "603467baa39606cb1840b87882f8978d",
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/grades": {
            "get": {
                "tags": [
                    "Grades"
                ],
                "summary": "List all grades",
                "operationId": "edc34c33a3105b1530f3af4c05a09b97",
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/subjects": {
            "get": {
                "tags": [
                    "Subjects"
                ],
                "summary": "List all subjects",
                "operationId": "07023e51b399f5b666b109066a73d89c",
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/teachers": {
            "get": {
                "tags": [
                    "Teachers"
                ],
                "summary": "List all teachers",
                "operationId": "d1f695da1d50369a1394773f50d2c557",
                "responses": {
                    "200": {
                        "description": "Successful operation"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/stats/dashboard": {
            "get": {
                "tags": [
                    "Authentication"
                ],
                "summary": "Get dashboard statistics",
                "description": "Get counts and summary statistics for the dashboard",
                "operationId": "85898add0f0cc8c0a75e73ee0f2bd6ca",
                "responses": {
                    "200": {
                        "description": "Successful operation",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "students_count": {
                                            "type": "integer"
                                        },
                                        "teachers_count": {
                                            "type": "integer"
                                        },
                                        "grades_count": {
                                            "type": "integer"
                                        },
                                        "subjects_count": {
                                            "type": "integer"
                                        },
                                        "upcoming_exams": {
                                            "type": "array",
                                            "items": {
                                                "type": "object"
                                            }
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "description": "Enter your Bearer token",
                "bearerFormat": "JWT",
                "scheme": "bearer"
            },
            "0": []
        }
    },
    "tags": [
        {
            "name": "Students",
            "description": "Student management endpoints"
        },
        {
            "name": "Teachers",
            "description": "Teacher management endpoints"
        },
        {
            "name": "Grades",
            "description": "Grade/Class management endpoints"
        },
        {
            "name": "Subjects",
            "description": "Subject management endpoints"
        },
        {
            "name": "Fees",
            "description": "Fee management endpoints"
        },
        {
            "name": "Exams",
            "description": "Exam scheduling endpoints"
        },
        {
            "name": "Authentication",
            "description": "User authentication endpoints"
        }
    ]
}