This backend server is built using Flask, MongoDB, and mongoengine, following the MVC (Model-View-Controller) pattern.
- Clone the repository from GitHub:
git clone <repository_url>
- Install dependencies using pip:
pip install -r requirements.txt
- Create a
.env
file in the root directory with the following environment variables:
FLASK_APP=app.py
FLASK_ENV=development
SECRET_KEY=<your_secret_key>
MONGODB_URI=<your_mongodb_uri>
To run the server, execute the following command:
flask run
By default, the server will run on http://localhost:5000
.
/api/v1/login
:- POST: to login an existing customer.
/api/v1/signup
:- POST: create a new account for a customer.
/api/v1/logout
:- POST: removes session and logs out all types of user.
/api/v1/login/admin
:- POST: to login an existing admin.
/api/v1/login
:- POST: create a new account for an admin.
/api/v1/flights/search
:- GET: Search for flights by date, to or from.
/api/v1/flights/
:- GET: Get all the flights status(Admin operation).
/api/v1/flights/
: :- POST: Add a flight (Admin operation).
/api/v1/flights/<flightId>
:- GET: Get the status of a particular flight (Admin operation).
/api/v1/flights/<flightId>
:- DELETE: Delete a flight (Admin operation).
/api/v1/book
:- GET: Get all the bookings made by the customer.
/api/v1/book/<flightId>
:- POST: Book a flight.
The application uses the following models:
- User Model: Represents users of the system.
- Flight Model: Represents flight information.
- Booking Model: Represents a booking made by a customer.
app.py
: Main Flask application file.controllers/
: Contains controller logic.models/
: Contains data models.routes/
: Contains all the routes for the endpoints
- Flask: Micro web framework for Python.
- mongoengine: Object-Document Mapper (ODM) for working with MongoDB in Python.
- PyMongo: Python driver for MongoDB.