Skip to content

Commit fa6af44

Browse files
committed
Flybooker
1 parent e08b7e9 commit fa6af44

30 files changed

+23993
-0
lines changed

README.md

+58
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,60 @@
11
# Flybooker
2+
23
✈️ MERN app with Keycloak
4+
5+
![flybooker.png](https://github.com/Piterson25/Flybooker/blob/main/screenshots/flybooker.png)
6+
7+
Flybooker is a web application built on the MERN (MongoDB, Express, React, Node.js) stack, secured with Keycloak. It allows users to book flights and manage flight listings. After logging in as a regular user, you can access the flight list, while admins have additional privileges such as deleting flights. The project includes a Docker Compose configuration for running Keycloak and MongoDB. Follow the instructions below to get started with Flybooker.
8+
9+
## 🛠️ Technologies Used
10+
11+
Flybooker is built using the following technologies:
12+
13+
- MongoDB
14+
- Express
15+
- React
16+
- Node.js
17+
- JavaScript
18+
- Keycloak
19+
20+
## 🚀 Getting Started
21+
22+
To start the Flybooker application, follow these steps:
23+
24+
1. Run the following command to start Keycloak and MongoDB using Docker Compose:
25+
26+
```sh
27+
docker-compose up
28+
```
29+
30+
2. After the containers are up and running, execute the [script.sh](https://github.com/Piterson25/Flybooker/blob/main/script.sh) script to start the frontend and backend:
31+
32+
```sh
33+
./script.sh
34+
```
35+
36+
This script installs the necessary dependencies and starts the frontend and backend servers.
37+
38+
3. Access the Flybooker application by opening your web browser and navigating to [http://localhost:3000](http://localhost:3000).
39+
40+
## 🔑 Login Credentials
41+
42+
Use the following credentials to log in:
43+
44+
Regular User:
45+
- Username: myuser
46+
- Password: myuser
47+
48+
Admin:
49+
- Username: myadmin
50+
- Password: myadmin
51+
52+
## 🎉 Features
53+
### Flight Listing
54+
Upon logging in as a regular user, you gain access to a flight listing section. Browse through a curated selection of example flights and view their details.
55+
56+
### Admin Section
57+
As an admin, you have additional privileges. In addition to accessing the user flight listing, you can also navigate to the admin section. Explore a broader range of flights and enjoy the ability to delete unwanted flights from the database.
58+
59+
## 📄 License
60+
Flybooker is licensed under the MIT License. See the [LICENSE](https://github.com/Piterson25/Flybooker/blob/main/LICENSE) file for more information.

backend/Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM node:14-alpine
2+
3+
WORKDIR /app
4+
5+
COPY package*.json ./
6+
7+
RUN npm install
8+
9+
COPY . .
10+
11+
CMD [ "npm", "start"]

backend/config.env

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
MONGO_URI=mongodb://localhost:27017/flybooker
2+
PORT=5000

backend/db/conn.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const { MongoClient } = require("mongodb");
2+
const Db = process.env.MONGO_URI;
3+
4+
console.log(Db);
5+
6+
const client = new MongoClient(Db, {
7+
useNewUrlParser: true,
8+
useUnifiedTopology: true,
9+
});
10+
11+
var _db;
12+
const initialData = require("./flights.json");
13+
14+
module.exports = {
15+
connectToServer: function (callback) {
16+
client.connect(function (err, db) {
17+
if (db) {
18+
_db = db.db("flybooker");
19+
console.log("Successfully connected to MongoDB");
20+
insertInitialData();
21+
}
22+
return callback(err);
23+
});
24+
},
25+
getDb: function () {
26+
return _db;
27+
},
28+
};
29+
30+
function insertInitialData() {
31+
const collection = _db.collection("flights");
32+
collection.deleteMany({}, (err) => {
33+
if (err) throw err;
34+
console.log("Deleted previous data");
35+
collection.insertMany(initialData, (err, res) => {
36+
if (err) throw err;
37+
console.log(`Insterted ${res.insertedCount} initial data to database`);
38+
});
39+
});
40+
}

backend/db/flights.json

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[
2+
{
3+
"airline": "Lufthansa",
4+
"origin": "New York",
5+
"destination": "Berlin",
6+
"departureDate": "2023-06-15T12:00:00Z",
7+
"arrivalDate": "2023-06-15T18:00:00Z",
8+
"image": "https://fly.pl/wp-content/uploads/2014/08/Berlin.jpg"
9+
},
10+
{
11+
"airline": "British Airways",
12+
"origin": "London",
13+
"destination": "Paris",
14+
"departureDate": "2023-06-16T10:00:00Z",
15+
"arrivalDate": "2023-06-16T12:00:00Z",
16+
"image": "https://dcontent.inviacdn.net/shared/img/web-830/2020/6/12/m0/966731.jpg"
17+
},
18+
{
19+
"airline": "Air France",
20+
"origin": "Paris",
21+
"destination": "New York",
22+
"departureDate": "2023-06-17T14:00:00Z",
23+
"arrivalDate": "2023-06-17T20:00:00Z",
24+
"image": "https://www.interameryka.com/wp-content/uploads/2015/11/Nowy-Jork-co-zobaczyc-jpg.webp"
25+
},
26+
{
27+
"airline": "Delta Airlines",
28+
"origin": "New York",
29+
"destination": "Los Angeles",
30+
"departureDate": "2023-06-18T08:00:00Z",
31+
"arrivalDate": "2023-06-18T12:00:00Z",
32+
"image": "https://bi.im-g.pl/im/9b/b4/1b/z29052827AMP,Przedmiescia-Los-Angeles.jpg"
33+
},
34+
{
35+
"airline": "United Airlines",
36+
"origin": "Los Angeles",
37+
"destination": "Chicago",
38+
"departureDate": "2023-06-19T09:00:00Z",
39+
"arrivalDate": "2023-06-19T15:00:00Z",
40+
"image": "https://floryda.eu/wp-content/uploads/2023/03/CHICAGO-NIERUCHOMOSCI.jpeg"
41+
},
42+
{
43+
"airline": "Emirates",
44+
"origin": "Dubai",
45+
"destination": "Sydney",
46+
"departureDate": "2023-06-20T16:00:00Z",
47+
"arrivalDate": "2023-06-21T06:00:00Z",
48+
"image": "https://cms.finnair.com/resource/blob/829444/3523a759b61b788b834fe56aa57fa255/sydney-main-data.jpg"
49+
}
50+
]

backend/keyclock.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"realm": "keycloak-react-auth",
3+
"auth-server-url": "http://localhost:8080/",
4+
"ssl-required": "external",
5+
"resource": "my-react-app-pkce",
6+
"public-client": true,
7+
"verify-token-audience": true,
8+
"use-resource-role-mappings": true,
9+
"confidential-port": 0
10+
}

0 commit comments

Comments
 (0)