{"id":23534970,"url":"https://github.com/egypt-metro/backend","last_synced_at":"2025-11-01T00:30:27.508Z","repository":{"id":266982655,"uuid":"898192827","full_name":"Egypt-Metro/backend","owner":"Egypt-Metro","description":"Egypt Metro Backend Django","archived":false,"fork":false,"pushed_at":"2025-02-14T06:46:18.000Z","size":21589,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T06:13:07.158Z","etag":null,"topics":["admin-dashboard","api","deployment","django","django-rest-framework","docker","hosting","jwt","metro","postgresql","postman","production","python","real-time-data","render","restful-api","swagger"],"latest_commit_sha":null,"homepage":"https://backend-54v5.onrender.com/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Egypt-Metro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-12-04T00:34:19.000Z","updated_at":"2025-02-14T06:46:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"93fc6f16-1657-4d11-95b8-eed8f9e1378d","html_url":"https://github.com/Egypt-Metro/backend","commit_stats":null,"previous_names":["egypt-metro/backend"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Egypt-Metro%2Fbackend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Egypt-Metro%2Fbackend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Egypt-Metro%2Fbackend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Egypt-Metro%2Fbackend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Egypt-Metro","download_url":"https://codeload.github.com/Egypt-Metro/backend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239242112,"owners_count":19605954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["admin-dashboard","api","deployment","django","django-rest-framework","docker","hosting","jwt","metro","postgresql","postman","production","python","real-time-data","render","restful-api","swagger"],"created_at":"2024-12-26T01:14:04.291Z","updated_at":"2025-11-01T00:30:27.451Z","avatar_url":"https://github.com/Egypt-Metro.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Egypt Metro Backend API (Django)\n\n![License](https://img.shields.io/badge/license-MIT-green)\n![Python](https://img.shields.io/badge/python-3.12-blue)\n![Django](https://img.shields.io/badge/django-5.1.3-brightgreen)\n\n## Overview\n\nThe **Egypt Metro Backend** is a robust API, business logic, and metro administration for managing and operating the Egypt Metro platform. Built with **Django**, it provides seamless user authentication, station \u0026 lines management, trip details, route planning, real-time train schedules, online tickets \u0026 subscription management, and AI-powered features such as crowd prediction, route optimization, and Chatbot Support. The system efficiently handles approximately **4 million passengers daily**, ensuring scalability and reliability. The backend integrates with Flutter (frontend) and AI models, delivering a scalable and efficient solution.\n\n---\n\n## Features\n\n### Passenger Features\n\n- `User Authentication`: Registration, login, profile management, and JWT support.\n- `Station Management`: Nearest station lookup, station list, and trip details.\n- `Route and Trip Planning`: Manage metro routes, count the number of stations, and calculate ticket prices.\n- `Train Schedules`: Provide real-time schedule data, including arrival times and GPS-tracked train locations.\n- `Real-Time Crowd Management`: Use AI to predict train crowd levels and recommend less crowded options.\n- `User Profiles`: Manage user accounts, including registration, login, subscription types, and payment options.\n- `Online Ticketing`: Buy and generate tickets online with QR codes for easy scanning at metro gates\n- `Online Subscription`: Subscribe to or renew metro plans online.\n- `Payment Options`: Users can pay via credit/debit cards, e-wallets, or other payment gateways.\n- `Chatbot Support`: 24/7 AI-powered chatbot to answer questions, guide users, and connect with customer service.\n- `Real-Time Updates`: Supports extensions for real-time data (e.g., train locations, crowd levels).\n\n### Admin Features\n\n- `Admin Dashboard`: Track revenue, sales, and station performance in real-time.\n- `Fault Reporting`: Allow admins to view, respond to, and track the status of user-reported issues.\n- `Revenue and Sales Tracking`: Monitor ticket sales and subscription renewals for each metro line and station.\n- `Train Monitoring`: Track train locations and details in real-time.\n\n---\n\n## Technologies Used\n\n- **Backend Framework**: Django\n- **API**: Django REST Framework\n- **Database**: PostgreSQL (hosted on Render)\n- **Authentication**: JWT (JSON Web Token), Django Allauth\n- **Documentation**: Swagger (DRF-YASG), ReDoc\n- **Profiling**: Silk (development only)\n- **Real-time Features**: WebSockets (optional, for live updates like train location or crowds)\n\n---\n\n## Installation\n\n### Prerequisites\n\n- **Python**: Version 3.9+\n- **Django**: Version 4.x+\n- **PostgreSQL** (recommended for production)\n- **Swagger \u0026 ReDoc**: For API documentation\n- **Docker**: For containerized deployment (optional)\n- **Poetry** or **Pip**: For managing dependencies\n- **Channels**: for real-time updates\n\n### Steps\n\n1. **Clone the Repository**\n\n   ```bash\n   git clone https://github.com/Egypt-Metro/backend.git\n   cd backend\n   ```\n\n2. **Set Up Virtual Environment**\n\n   ```bash\n   python -m venv venv\n   source venv/bin/activate  # On Windows: venv\\Scripts\\activate\n   ```\n\n3. **Install Dependencies**\n\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n4. **Configure Environment Variables**\n\n   Create a `.env` file in the root directory and add the following:\n\n   ```env\n   SECRET_KEY=\u003cyour-secret-key\u003e\n   DEBUG=True  # Set to False in production\n   DB_NAME=\u003cyour-db-name\u003e\n   DB_USER=\u003cyour-db-user\u003e\n   DB_PASSWORD=\u003cyour-db-password\u003e\n   DB_HOST=\u003cyour-db-host\u003e\n   DB_PORT=5432\n   ````\n\n5. **Apply Migrations**\n\n   ```bash\n   python manage.py migrate\n   ```\n\n6. **Create Superuser**\n\n   ```bash\n   python manage.py createsuperuser\n   ```\n\n7. **Run the Server**\n\n   ```bash\n   python manage.py runserver\n   ```\n\n8. **Access the API**:\n   - API Base URL: `http://127.0.0.1:8000`\n   - Admin Panel: `http://127.0.0.1:8000/admin/`\n\n---\n\n## API Endpoints\n\n### Authentication Endpoints\n\n| Method | Endpoint              | Description                 |\n|--------|-----------------------|-----------------------------|\n| POST   | `/api/users/register/` | Register a new user.         |\n| POST   | `/api/users/login/`    | Login to get JWT tokens.     |\n| POST   | `/api/users/token/refresh/` | Refresh access token.      |\n| GET    | `/api/users/profile/`  | Retrieve user profile.       |\n| PATCH  | `/api/users/profile/update/` | Update user profile.       |\n\n### Metro Stations Endpoints\n\n| Method | Endpoint                                         | Description                         |\n|--------|--------------------------------------------------|-------------------------------------|\n| GET    | `/api/stations/list/`                            | List all metro stations.            |\n| GET    | `/api/stations/trip/\u003cstart_station_id\u003e/\u003cend_station_id\u003e/` | Get trip details between two stations. |\n| GET    | `/api/stations/nearest/`                         | Get the nearest metro station.      |\n\n### Route and Trip Planning\n\n| Method | Endpoint                                 | Description                                                        |\n|--------|------------------------------------------|--------------------------------------------------------------------|\n| GET    | `/api/routes/`                           | Get available routes and their respective details (stations, trip duration, price). |\n| GET    | `/api/routes/{start_station}/{end_station}/` | Get a route between two stations, including trip details and fare. |\n\n### Train Schedules\n\n| Method | Endpoint                                 | Description                                                        |\n|--------|------------------------------------------|--------------------------------------------------------------------|\n| GET    | `/api/schedules/`                        | Get the current train schedules.                                   |\n| GET    | `/api/schedules/{train_id}/`             | Get schedule details for a specific train.                         |\n\n### User Management\n\n| Method | Endpoint                                 | Description                                                        |\n|--------|------------------------------------------|--------------------------------------------------------------------|\n| POST   | `/api/users/register/`                  | Register a new user.                                               |\n| POST   | `/api/users/login/`                     | Login a user.                                                      |\n| GET    | `/api/users/{user_id}/`                  | Get user profile information.                                      |\n\n### Ticketing\n\n| Method | Endpoint                                 | Description                                                        |\n|--------|------------------------------------------|--------------------------------------------------------------------|\n| POST   | `/api/tickets/`                          | Create a new ticket based on the route selected.                    |\n| GET    | `/api/tickets/{ticket_id}/`              | Get ticket details.                                                |\n\n### Miscellaneous Endpoints\n\n| Method | Endpoint      | Description                  |\n|--------|---------------|------------------------------|\n| GET    | `/health/`    | Health check for the API.    |\n\n---\n\n## API Documentation\n\nInteractive API documentation is available:\n\n- **Swagger UI**: [https://backend-54v5.onrender.com/swagger/](https://backend-54v5.onrender.com/swagger/)\n- **ReDoc**: [https://backend-54v5.onrender.com/redoc/](https://backend-54v5.onrender.com/redoc/)\n- **Swagger JSON**: [https://backend-54v5.onrender.com/swagger.json](https://backend-54v5.onrender.com/swagger.json)\n\n---\n\n## Deployment\n\nThe project is deployed using **Render**. To deploy:\n\n1. **Configure Environment Variables** on Render.\n2. Use the provided PostgreSQL database settings.\n3. Deploy the Django app with the necessary build and start commands.\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## Contact\n\nFor inquiries, please reach out to **Ahmed Nassar**:\n\n- Email: [a.moh.nassar00@gmail.com](mailto:a.moh.nassar00@gmail.com)\n- GitHub: [AhmedNassar7](https://github.com/AhmedNassar7)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegypt-metro%2Fbackend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegypt-metro%2Fbackend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegypt-metro%2Fbackend/lists"}