Future Gate is a platform designed to efficiently manage student data, providing a seamless way to store and retrieve information such as student names, seat numbers, and governorates. The backend is built using Laravel (PHP), exposing API endpoints to fetch student data. The frontend is developed with React (web) and Flutter (mobile), enabling users to interact with the data effortlessly.
This project is a collaborative effort:
- Backend: Managed by Abdelrhman Elnagar.
- Frontend: Developed by teammates using React and Flutter.
- Technologies Used
- API Endpoints
- For Frontend Teammates (React and Flutter)
- Troubleshooting
- Contributing
- License
- Backend: Laravel (PHP framework, version 11.x)
- Database: MySQL (local database:
future_gate_db)- Database was created with Mysql version: (Insert Mysql Version Here)
- Frontend:
- React (web application)
- Flutter (mobile application)
- Tools:
- Ngrok (for exposing the local backend)
- Composer (PHP dependency manager)
- WampServer/XAMPP (local server for PHP)
The backend provides the following API endpoints to retrieve student data:
-
GET /api/studentsRetrieves a list of all students.
Example response:
[ { "id": 1, "الاسم": "أحمد محمد", "رقم_الجلوس": "12345", "المحافظة": "القاهرة" }, { "id": 2, "الاسم": "سارة علي", "رقم_الجلوس": "12346", "المحافظة": "الجيزة" } ] -
GET /api/students/{id}Retrieves a specific student by ID.
Example:
/api/students/1Example response:
{ "id": 1, "الاسم": "أحمد محمد", "رقم_الجلوس": "12345", "المحافظة": "القاهرة" }
You have two options to retrieve student data:
- Access the backend remotely via API calls (no setup required).
- Install PHP and run the backend on your own PC.
You can fetch data from Abdelrhman’s local backend without installing PHP or Laravel. The backend is made accessible over the internet using Ngrok.
-
API Base URL
The current public URL is:
https://abc123.ngrok.io.Note: This URL is temporary and changes each time the Ngrok server restarts. To obtain the most up-to-date URL, please contact Abdelrhman.
-
Making Requests from Your Code
Use the Ngrok URL to make HTTP requests to the API endpoints.
-
React: Use
axiosorfetch.Example with
fetch:async function fetchStudents() { const response = await fetch('[https://abc123.ngrok.io/api/students](https://abc123.ngrok.io/api/students)'); const data = await response.json(); console.log(data); } fetchStudents();
-
Flutter: Use the
httppackage.Add to
pubspec.yaml:dependencies: http: ^1.2.1
Then, make a request:
import 'package:http/http.dart' as http; Future<void> fetchStudents() async { final response = await http.get(Uri.parse('[https://abc123.ngrok.io/api/students](https://abc123.ngrok.io/api/students)')); if (response.statusCode == 200) { print(response.body); // JSON data } else { print('Failed to load data'); } }
-
-
Testing Without Code
-
Postman: Create a
GETrequest with the URL (e.g.,https://abc123.ngrok.io/api/students) and hit "Send". -
cURL:
curl -X GET [https://abc123.ngrok.io/api/students](https://abc123.ngrok.io/api/students)
-
If you prefer to run the backend on your own PC, you’ll need to install PHP, a web server, and the project dependencies. This allows you to work offline and test the backend independently.
-
Prerequisites
- PHP: Download and install PHP (version 8.1 or higher) from php.net.
- Composer: Install Composer from getcomposer.org.
- Web Server: Install a local server:
- WampServer (Windows): Download from wampserver.com.
- XAMPP (Windows/Mac/Linux): Download from apachefriends.org.
- MySQL: Included with WampServer/XAMPP, or install separately from mysql.com.
- Git: Install Git from git-scm.com.
-
Clone the Repository
git clone [https://github.com/Abdelrhman-Elnagar/future-gate.git](https://github.com/Abdelrhman-Elnagar/future-gate.git) cd future-gate -
Install Dependencies
composer install
-
Set Up Environment
cp .env.example .env
Open the
.envfile and configure the database settings:DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=future_gate_db DB_USERNAME=root DB_PASSWORD=
(Adjust
DB_USERNAMEandDB_PASSWORDbased on your MySQL setup.) Note: Do not commit sensitive information, like database passwords, to version control. -
Set Up the Database
Abdelrhman will provide a copy of the database (
future_gate_db.sql). Import it into MySQL:- Open phpMyAdmin (usually at
http://localhost/phpmyadmin). - Create a new database named
future_gate_db. - Go to the "Import" tab, upload the
future_gate_db.sqlfile, and click "Go".
Alternatively, use the MySQL command line:
mysql -u root -p future_gate_db < future_gate_db.sql - Open phpMyAdmin (usually at
-
Generate an Application Key
php artisan key:generate
-
Run the Backend
php artisan serve
The backend will run at
http://localhost:8000. Use this as your API base URL. -
Retrieve Data
Use the same API endpoints as in Option 1, but with your local URL (e.g.,
http://localhost:8000/api/students).
- Option 1:
- If you can’t connect, the Ngrok URL might have changed, or Abdelrhman’s server might be down. Contact him to confirm.
- If the data isn’t what you expect (e.g., missing fields like "الاسم"), let Abdelrhman know to check the backend.
- Option 2:
- PHP Errors: Ensure PHP is in your system’s
PATH. Test withphp -v. - Database Issues: Double-check your
.envfile and MySQL credentials. Ensure MySQL is running. - Composer Issues: Run
composer updateif dependencies fail to install.
- PHP Errors: Ensure PHP is in your system’s
For any issues, reach out to Abdelrhman.
Contributions are welcome! If you have suggestions or improvements:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature). - Commit your changes (
git commit -m 'Add your feature'). - Push to the branch (
git push origin feature/your-feature). - Open a pull request.
Please follow the Contributor Covenant guidelines for respectful collaboration.
This project is licensed under the MIT License. See the LICENSE file for details.
- Ngrok URL: Replace
https://abc123.ngrok.iowith the actual Ngrok URL when you runngrok http 8000. Update the README whenever the URL changes. - Database File: Ensure you share the
future_gate_db.sqlfile with your teammates securely (e.g., via Google Drive) for Option 2. - Laravel Version: The project uses Laravel version 11.x.
- License: I’ve assumed an MIT License, which is common for open-source projects. If you prefer a different license, update the License section accordingly using a resource like choosealicense.com.