{"id":23490036,"url":"https://github.com/satishsurani/school-management-backend","last_synced_at":"2026-02-02T10:44:45.551Z","repository":{"id":267636622,"uuid":"901816548","full_name":"satishsurani/School-Management-Backend","owner":"satishsurani","description":"This School Management API is a backend application built with Node.js, Express.js, and MySQL","archived":false,"fork":false,"pushed_at":"2024-12-11T14:25:19.000Z","size":1027,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T17:46:27.415Z","etag":null,"topics":["backend","express-js","mysql","node-js"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/satishsurani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-11T11:18:25.000Z","updated_at":"2025-04-12T13:37:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"45a31fd2-89a6-4f5b-aa8a-0c5254b505bb","html_url":"https://github.com/satishsurani/School-Management-Backend","commit_stats":null,"previous_names":["satishsurani/school-management"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/satishsurani/School-Management-Backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satishsurani%2FSchool-Management-Backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satishsurani%2FSchool-Management-Backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satishsurani%2FSchool-Management-Backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satishsurani%2FSchool-Management-Backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/satishsurani","download_url":"https://codeload.github.com/satishsurani/School-Management-Backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satishsurani%2FSchool-Management-Backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29010602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T10:37:29.253Z","status":"ssl_error","status_checked_at":"2026-02-02T10:37:28.644Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","express-js","mysql","node-js"],"created_at":"2024-12-25T00:13:45.378Z","updated_at":"2026-02-02T10:44:45.545Z","avatar_url":"https://github.com/satishsurani.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# School Management System APIs\n\nThis project provides a set of Node.js APIs for managing school data. The APIs allow users to add new schools and retrieve a list of schools sorted by proximity to a specified location.\n\n## Objective\n\nDevelop APIs using Node.js, Express.js, and MySQL to manage school data effectively.\n\n---\n\n## Database Setup\n\n### Schools Table\n\nCreate a table in MySQL with the following structure:\n\n| Column    | Data Type | Constraints                 |\n| --------- | --------- | --------------------------- |\n| id        | INT       | Primary Key, Auto Increment |\n| name      | VARCHAR   | Not NULL                    |\n| address   | VARCHAR   | Not NULL                    |\n| latitude  | FLOAT     | Not NULL                    |\n| longitude | FLOAT     | Not NULL                    |\n\n### Example SQL Query\n\n```sql\nCREATE TABLE schools (\n    id INT AUTO_INCREMENT PRIMARY KEY,\n    name VARCHAR(255) NOT NULL,\n    address VARCHAR(255) NOT NULL,\n    latitude FLOAT NOT NULL,\n    longitude FLOAT NOT NULL\n);\n```\n\n---\n\n## API Development\n\n### Add School API\n\n- **Endpoint**: `/addSchool`\n- **Method**: POST\n- **Payload**:\n  ```json\n  {\n      \"name\": \"School Name\",\n      \"address\": \"School Address\",\n      \"latitude\": 12.345678,\n      \"longitude\": 98.765432\n  }\n  ```\n- **Functionality**:\n  - Validates the input data.\n  - Adds a new school record to the `schools` table.\n- **Validation Rules**:\n  - `name`: Non-empty string.\n  - `address`: Non-empty string.\n  - `latitude`: Valid float value.\n  - `longitude`: Valid float value.\n\n### List Schools API\n\n- **Endpoint**: `/listSchools`\n- **Method**: GET\n- **Parameters**:\n  - `latitude`: User's latitude.\n  - `longitude`: User's longitude.\n- **Functionality**:\n  - Fetches all schools from the database.\n  - Sorts them by proximity to the user's specified location using the Haversine formula for geographical distance.\n  - Returns the sorted list.\n\n---\n\n## Sorting Mechanism\n\nThe proximity is calculated using the Haversine formula:\n\n### Formula\n\n```\nd = 2 * r * asin(sqrt(\n    sin^2((lat2 - lat1) / 2) +\n    cos(lat1) * cos(lat2) * sin^2((lon2 - lon1) / 2)\n))\n```\n\nWhere:\n\n- `d` is the distance.\n- `r` is the Earth's radius (approximately 6371 km).\n- `lat1`, `lon1` are the user's coordinates.\n- `lat2`, `lon2` are the school's coordinates.\n\n---\n\n## Example Usage\n\n### Adding a School\n\n**Request**:\n\n```bash\nPOST /addSchool\nContent-Type: application/json\n\n{\n    \"name\": \"Green Valley High School\",\n    \"address\": \"123 Main St, Springfield\",\n    \"latitude\": 34.052235,\n    \"longitude\": -118.243683\n}\n```\n\n**Response**:\n\n```json\n{\n    \"success\": true,\n    \"message\": \"School added successfully.\"\n}\n```\n\n### Listing Schools\n\n**Request**:\n\n```bash\nGET /listSchools?latitude=34.052235\u0026longitude=-118.243683\n```\n\n**Response**:\n\n```json\n[\n    {\n        \"id\": 1,\n        \"name\": \"Green Valley High School\",\n        \"address\": \"123 Main St, Springfield\",\n        \"latitude\": 34.052235,\n        \"longitude\": -118.243683,\n        \"distance\": 0.0\n    },\n    {\n        \"id\": 2,\n        \"name\": \"Sunnydale Elementary\",\n        \"address\": \"456 Oak St, Springfield\",\n        \"latitude\": 34.045123,\n        \"longitude\": -118.250456,\n        \"distance\": 1.23\n    }\n]\n```\n\n---\n\n## Project Setup\n\n1. Clone the repository.\n2. Install dependencies:\n   ```bash\n   npm install\n   ```\n3. Run the server:\n   ```bash\n   npx nodemon index.js\n   ```\n\n---\n\n## Future Enhancements\n\n- Implement user authentication for secure API access.\n- Add pagination to the `listSchools` API for handling large datasets.\n- Include detailed error handling and logging.\n\n---\n\n## Contact\n\nFor questions or issues, please contact [satishsurani60@gmail.com](mailto\\:satishsurani60@gmail.com).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatishsurani%2Fschool-management-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsatishsurani%2Fschool-management-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatishsurani%2Fschool-management-backend/lists"}