Skip to content

πŸš— Second-Hand Car Platform + 🚌 Bus Booking API (Full-Stack Project) A complete MERN-stack style assignment with: β€’ A responsive car marketplace frontend (React + Firebase + Google Auth) β€’ A secure Express.js REST API for a full-featured bus booking system (JWT Auth, Dockerized, deployed on AWS EC2) Includes API doc, Postman collection, EC2

Notifications You must be signed in to change notification settings

Puneetharajkr/anthil-networks-car-buying-frontend-bus-booking-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚌 Anthil Networks - Bus Booking Backend API App

This is the backend API for the Anthil Networks Bus Booking System, built using Node.js, Express, and SQLite3.
It supports features like admin route & bus management, user bookings, and role-based authentication using JWT.


πŸš€ Live Deployments

βœ… Render Deployment URL
πŸ”— https://anthil-networks-bus-booking-backend.onrender.com

βœ… AWS EC2 Deployment URL
πŸ”— http://ec2-51-20-37-192.eu-north-1.compute.amazonaws.com:5000


πŸ“ Project Structure

anthil-networks-backend/ β”œβ”€β”€ controllers/ # Business logic for admin, auth, user β”œβ”€β”€ middlewares/ # Auth, validation β”œβ”€β”€ models/ # SQLite DB models β”œβ”€β”€ routes/ # Route definitions β”œβ”€β”€ utils/ # JWT helpers β”œβ”€β”€ API_Documentation/ # πŸ“„ API_Documentation.md (detailed) β”œβ”€β”€ postman/ # πŸ“¦ BusBookingCollection.json β”œβ”€β”€ Dockerfile # Docker configuration β”œβ”€β”€ .env # Environment variables β”œβ”€β”€ .env.example # Env template (no secrets) β”œβ”€β”€ package.json
β”œβ”€β”€ server.js # Entry point β”œβ”€β”€ README.md # Project readme

πŸ”§ Setup Instructions (Local)

Clone the repository

git clone https://github.com/Puneetharajkr/anthil-networks-bus-booking-backend.git
cd anthil-networks-backend

Install dependencies

npm install

Create .env file

cp .env.example .env Then fill in required values inside .env.

Start the server

npm start or node server.js or nodemon server.js Server runs on: http://localhost:5000

πŸ§ͺ API Testing

πŸ“‚ The following resources are available for testing the API:

πŸ”Ή API_Documentation/API_Documentation.md – Full list of all API endpoints with request body, success & error responses. πŸ”Ή postman/BusBookingCollection.json – Import this collection into Postman to test all endpoints directly.

🐳 Docker Setup (Local)

Make sure you have Docker Desktop installed.

Build Docker Image

docker build -t bus-booking-api .

Run Docker Container

docker run -d -p 5000:5000 --name bus-booking bus-booking-api

Access the app at: πŸ‘‰ http://localhost:5000

☁️ AWS EC2 Deployment

Steps followed:

Launched an Ubuntu 24.04 EC2 instance Installed Docker & configured it Uploaded project files to EC2 (via scp) Built & ran Docker container on EC2

πŸ”— Final deployed EC2 URL: http://ec2-51-20-37-192.eu-north-1.compute.amazonaws.com:5000

Note: Make sure port 5000 is open in the EC2 security group.

🧠 Admin & User Roles

πŸ›  Admin (Predefined credentials)

Can add/view/delete buses and routes

πŸ‘€ User

Can register/login, view buses, and book/cancel tickets

πŸ” Authentication

JWT tokens are generated on login

Use the token in Authorization: Bearer header for protected routes

βœ… Example Test Credentials

Admin

email: admin@example.com password: admin123

User

email: user@example.com password: user123

πŸ“¦ Tech Stack

Node.js + Express SQLite3 (local database) JWT for auth Docker (containerized deployment) AWS EC2 (cloud hosting) Postman (API testing)

----------------------------------------------------------------------------

πŸš—Anthil Networks Second Hand Car Buying Frontend App

πŸš— Car Buying App – Second-hand Car Marketplace This is a web-based application that enables users to browse, request, and book second-hand cars. Admins can manage listings and requests through an admin dashboard.

πŸš€ Live Deployments

βœ… Netlify Deployment URL
πŸ”— https://anthill-networks-cars-app.netlify.app/

🌟 Features πŸ‘€ User Login with Google

Browse available cars with search & filter

View car details

Submit purchase requests

View "My Requests" and booking status

Book the car once the request is approved

πŸ” Admin Login with Google (admin role detected via Firestore)

Access admin dashboard

View all purchase requests

Change request status (Pending β†’ Approved/Rejected/Contacted)

View & manage all bookings (change status to Completed/Cancelled)

πŸ›  Tech Stack Frontend: React.js (Hooks, Routing)

Auth: Firebase Authentication (Google Sign-In)

Database: Firebase Firestore

Storage: Firebase Storage (for car images)

Hosting (optional): Firebase Hosting / Vercel

πŸš€ Working Flow πŸ”Ή 1. Authentication User logs in using Google.

Firebase Auth tracks current user session.

Admin role is fetched from Firestore (roles collection β†’ role: "admin").

πŸ”Ή 2. Car Listings Cars are listed from Firestore cars collection.

Users can search by make, model, year, or price.

πŸ”Ή 3. Purchase Requests When a user is interested in a car, they click "Request to Purchase".

A record is saved in the purchaseRequests collection with user & car info.

πŸ”Ή 4. Admin Panel Admin views all user requests.

Admin can update the status:

Pending β†’ Approved, Rejected, or Contacted

Once request is approved, the user sees "Book Now" button.

πŸ”Ή 5. Booking Flow User clicks "Book Now" β†’ creates a record in bookings collection.

Admin can view all bookings and update status:

Booked β†’ Completed or Cancelled

πŸ“ Firebase Collections markdown Copy Edit

  • cars

    • {id, make, model, year, price, imageUrls[] }
  • purchaseRequests

    • {id, userId, carId, status, message }
  • bookings

    • {id, userId, carId, status, createdAt }
  • roles

    • {uid: string, role: "admin"} βš™οΈ Setup Instructions bash Copy Edit

1. Clone the repo

git clone cd car-buying-app

2. Install dependencies

npm install

3. Add Firebase Config

Create a file: src/firebase/config.js

and paste your Firebase project credentials

4. Run the app

npm start πŸ§ͺ Sample Admin Setup To make someone admin:

Go to Firestore

Create document in roles collection:

Document ID = user UID

Field = role: "admin"

πŸ“Έ Screenshots (Add screenshots of Home, Car Detail, Admin Dashboard, My Requests, etc.)

πŸ“Œ Final Note This project demonstrates full-stack implementation using Firebase and React, covering authentication, CRUD operations, conditional role-based access, and real-time updates.

🀝 Author

Built by Puneetharaj K R puneetharajkr123@gmail.com

About

πŸš— Second-Hand Car Platform + 🚌 Bus Booking API (Full-Stack Project) A complete MERN-stack style assignment with: β€’ A responsive car marketplace frontend (React + Firebase + Google Auth) β€’ A secure Express.js REST API for a full-featured bus booking system (JWT Auth, Dockerized, deployed on AWS EC2) Includes API doc, Postman collection, EC2

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published