Skip to content

Hamza-H10/salon-hub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Microservices(Full Stack), SpringBoot, KeyClock, JWT, MySql, RabbitMQ, WebSocket, Docker, React, TailwindCSS, Redux, Material-UI,Formik, Razor Pay, Stripe.

Steps to run frontend

  • npm i
  • npm start

Backend Setup

  • run all microservices
  • run keycloak server(user need to install docker for this)

Install Docker

then run keycloak

command : docker run -p 8080:8080 -e KC_BOOTSTRAP_ADMIN_USERNAME=admin -e KC_BOOTSTRAP_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:26.1.0 start-dev

1. create client
2. change clientId, CLIENT_SECRET, CLIENT_ID, username, password in Keycloak user service
3. create admin => asign admin role (don't forgot off temporary option)
4. create client role=> CUSTOMER => SALON_OWNER
5. increase access token life span

Once keycloack setup is completed you can login, register on frontend and check all the functionality

πŸš€ Build Microservices πŸ› οΈ

πŸ‘€ User Service

πŸ” Auth Endpoints

  1. πŸ“ POST /auth/signup

    • πŸ“ Description: Registers a new user with the provided signup details.
    • πŸ“₯ Request Body:
      • πŸ†• SignupDto (contains user registration details).
    • πŸ“€ Response:
      • 🟒 Success message: "User created successfully."
      • πŸ“„ Authentication response object.
  2. πŸ”‘ POST /auth/login

    • πŸ“ Description: Logs in a user using their email and password.
    • πŸ“₯ Request Body:
      • πŸ“§ LoginDto (contains email and password).
    • πŸ“€ Response:
      • 🟒 Success message: "User logged in successfully."
      • πŸ“„ Authentication response object.
  3. πŸ”„ GET /auth/access-token/refresh-token/{refreshToken}

    • πŸ“ Description: Generates a new access token using a valid refresh token.
    • πŸ“₯ Parameters:
      • πŸ”‘ refreshToken (PathVariable).
    • πŸ“€ Response:
      • 🟒 Success message: "Refresh token received successfully."
      • πŸ“„ Authentication response object.

πŸ‘₯ User Endpoints

  1. πŸ‘€ GET /api/users/profile

    • πŸ“ Description: Retrieves the user profile based on the JWT token.
    • πŸ“₯ Request Header:
      • πŸ”‘ Authorization (JWT token).
    • πŸ“€ Response:
      • πŸ“„ UserDTO containing the user's profile information.
    • βœ… HTTP Status:
      • 🟒 200 OK on success.
  2. πŸ” GET /api/users/{userId}

    • πŸ“ Description: Retrieves user details based on their ID.
    • πŸ“₯ Path Parameter:
      • πŸ†” userId (ID of the user to retrieve).
    • πŸ“€ Response:
      • πŸ“„ UserDTO containing the user's details.
    • βœ… HTTP Status:
      • 🟒 200 OK on success.
      • ❌ Throws a UserException if the user is not found.

πŸ’‡ Salon Service

Base URL: /api/salons


1️⃣ Create Salon

πŸ”Ή POST /api/salons

  • πŸ“ Description: Creates a new salon for the authenticated user.
  • πŸ”‘ Authorization:
    • Header: "Authorization" β†’ JWT token
  • πŸ“₯ Request Body:
    • SalonDTO β†’ Details of the salon to be created.
  • πŸ“€ Response:
    • Status: 201 Created
    • Body: SalonDTO β†’ Details of the newly created salon.

2️⃣ Update Salon

πŸ”Ή PUT /api/salons/{salonId}

  • πŸ“ Description: Updates an existing salon based on the given salon ID.
  • πŸ”‘ Path Parameter:
    • salonId β†’ ID of the salon to update.
  • πŸ“₯ Request Body:
    • Salon β†’ Updated details of the salon.
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: SalonDTO β†’ Updated details of the salon.

3️⃣ Get All Salons

πŸ”Ή GET /api/salons

  • πŸ“ Description: Retrieves a list of all salons.
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: List<SalonDTO> β†’ A list of all salons with owner details.

4️⃣ Get Salon By ID

πŸ”Ή GET /api/salons/{salonId}

  • πŸ“ Description: Retrieves the details of a salon by its ID.
  • πŸ”‘ Path Parameter:
    • salonId β†’ ID of the salon.
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: SalonDTO β†’ Details of the specified salon.
  • ❌ Error Handling:
    • Throws an exception if the salon does not exist.

5️⃣ Search Salon By City

πŸ”Ή GET /api/salons/search

  • πŸ“ Description: Searches for salons in a specific city.
  • πŸ”‘ Query Parameter:
    • city β†’ City name to search salons.
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: List<SalonDTO> β†’ A list of salons matching the city criteria.

6️⃣ Get Salon By Owner

πŸ”Ή GET /api/salons/owner

  • πŸ“ Description: Retrieves the salon owned by the authenticated user.
  • πŸ”‘ Authorization:
    • Header: "Authorization" β†’ JWT token
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: Salon β†’ Details of the salon owned by the user.

🎯 Highlights

  • Each endpoint is carefully integrated with SalonService and UserFeignClient to ensure efficient data flow and mapping.
  • Custom exceptions like UserException handle user-related errors gracefully.
  • Simplified DTO mapping via SalonMapper.

πŸ“š Note

Make sure the Authorization header contains a valid JWT token for endpoints requiring user authentication. πŸ’‘


🌟 Category Microservice API Documentation

Base URL: /api/categories

Owner-Specific Base URL: /api/categories/salon-owner


1️⃣ Get All Categories

πŸ”Ή GET /api/categories

  • πŸ“ Description: Fetches all available categories.
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: List<Category> β†’ List of all categories.

2️⃣ Get Categories by Salon ID

πŸ”Ή GET /api/categories/salon/{id}

  • πŸ“ Description: Retrieves categories associated with a specific salon.
  • πŸ”‘ Path Parameter:
    • id β†’ ID of the salon.
  • πŸ”‘ Header Parameter:
    • "Authorization" β†’ JWT token of the user.
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: Set<Category> β†’ List of categories linked to the salon.
  • πŸ”— Feign Clients:
    • UserFeignClient β†’ Validates the user's JWT token.
    • SalonFeignClient β†’ Fetches salon details by ID.

3️⃣ Get Category by ID

πŸ”Ή GET /api/categories/{id}

  • πŸ“ Description: Retrieves a single category by its ID.
  • πŸ”‘ Path Parameter:
    • id β†’ ID of the category.
  • πŸ“€ Response:
    • Status:
      • 200 OK β†’ If the category is found.
      • 404 Not Found β†’ If the category does not exist.
    • Body: Category β†’ Details of the category.

4️⃣ Delete Category by ID

πŸ”Ή DELETE /api/categories/{id}

  • πŸ“ Description: Deletes a category by its ID.
  • πŸ”‘ Path Parameter:
    • id β†’ ID of the category.
  • πŸ“€ Response:
    • Status:
      • 204 No Content β†’ If deletion is successful.
      • 404 Not Found β†’ If the category does not exist.

5️⃣ Create Category (Salon Owner)

πŸ”Ή POST /api/categories/salon-owner

  • πŸ“ Description: Allows a salon owner to create a new category for their salon.
  • πŸ”‘ Header Parameter:
    • "Authorization" β†’ JWT token of the salon owner.
  • πŸ“₯ Request Body:
    • Category β†’ Details of the new category.
  • πŸ“€ Response:
    • Status: 201 Created
    • Body: Category β†’ Details of the newly created category.
  • πŸ”— Feign Clients:
    • SalonFeignClient β†’ Validates salon ownership via JWT token.

🎯 Highlights

  1. **Role-Specific Endpoints:**Separate APIs for all users and salon owners.
  2. Integrated Feign Clients:
    • UserFeignClient β†’ Authenticates user requests.
    • SalonFeignClient β†’ Ensures salon-owner-specific operations are secure.
  3. Comprehensive Error Handling:
    • 404 Not Found for non-existent resources.
    • Graceful handling of invalid requests.
  4. **Enhanced Security:**JWT-based authorization ensures secure access to salon-owner-specific features.

πŸ“š Note

Ensure that JWT tokens are passed in the "Authorization" header for both salon-owner-specific and category-fetching operations. This guarantees proper authentication and data access.


🌟 Service Offering Microservice

Base URL: /api/service-offering

Owner-Specific Base URL: /api/service-offering/salon-owner


1️⃣ Get Services by Salon ID

πŸ”Ή GET /api/service-offering/salon/{salonId}

  • πŸ“ Description: Retrieves all services offered by a specific salon, with an optional filter by category.
  • πŸ”‘ Path Parameter:
    • salonId β†’ ID of the salon.
  • πŸ”‘ Query Parameter (Optional):
    • categoryId β†’ ID of the category to filter services.
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: Set<ServiceOffering> β†’ List of services offered by the salon.

2️⃣ Get Service by ID

πŸ”Ή GET /api/service-offering/{serviceId}

  • πŸ“ Description: Retrieves details of a specific service by its ID.
  • πŸ”‘ Path Parameter:
    • serviceId β†’ ID of the service.
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: ServiceOffering β†’ Details of the service.
  • ❌ Error Handling:
    • Throws an exception if the service does not exist.

3️⃣ Get Services by Multiple IDs

πŸ”Ή GET /api/service-offering/list/{ids}

  • πŸ“ Description: Retrieves details of multiple services by their IDs.
  • πŸ”‘ Path Parameter:
    • ids β†’ A set of service IDs (comma-separated).
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: Set<ServiceOffering> β†’ List of services matching the provided IDs.

4️⃣ Create Service (Salon Owner)

πŸ”Ή POST /api/service-offering/salon-owner

  • πŸ“ Description: Allows a salon owner to create a new service under their salon.
  • πŸ”‘ Authorization:
    • Header: "Authorization" β†’ JWT token.
  • πŸ“₯ Request Body:
    • ServiceDTO β†’ Details of the service to be created.
  • πŸ“€ Response:
    • Status: 201 Created
    • Body: ServiceOffering β†’ Details of the newly created service.
  • πŸ”— Feign Clients:
    • SalonFeignClient β†’ Retrieves salon details by the owner's JWT.
    • CategoryFeignClient β†’ Fetches the category details.

5️⃣ Update Service (Salon Owner)

πŸ”Ή PUT /api/service-offering/salon-owner/{serviceId}

  • πŸ“ Description: Allows a salon owner to update an existing service.
  • πŸ”‘ Path Parameter:
    • serviceId β†’ ID of the service to update.
  • πŸ“₯ Request Body:
    • ServiceOffering β†’ Updated service details.
  • πŸ“€ Response:
    • Status:
      • 200 OK β†’ On successful update.
      • 404 Not Found β†’ If the service does not exist.

🎯 Highlights

  1. **Service Segmentation:**Separate endpoints for all users and salon owners.
  2. Integrated Feign Clients:
    • SalonFeignClient β†’ Ensures salon owner is authenticated.
    • CategoryFeignClient β†’ Validates category data.
  3. **Error Handling:**Custom exceptions and status codes provide clear responses for invalid requests.
  4. **Flexibility:**Query parameter support enables dynamic filtering for services.

πŸ“š Note

Ensure proper JWT tokens are provided in the Authorization header for all salon-owner-specific operations.


🌟 Booking Microservice API Documentation

Base URL: /api/bookings


1️⃣ Create a Booking

πŸ”Ή POST /api/bookings

  • πŸ“ Description: Creates a new booking for a salon and generates a payment link.
  • πŸ”‘ Header Parameters:
    • Authorization β†’ JWT token of the user.
  • πŸ”‘ Query Parameters:
    • salonId β†’ ID of the salon.
    • paymentMethod β†’ Payment method (e.g., CARD, CASH).
  • πŸ“₯ Request Body:
    • BookingRequest β†’ Details of the booking (e.g., serviceIds, startTime, endTime).
  • πŸ“€ Response:
    • Status: 201 Created
    • Body: PaymentLinkResponse β†’ Payment link and details.
  • πŸ”— Feign Clients:
    • UserFeignClient β†’ Validates the user using JWT.
    • SalonFeignClient β†’ Verifies the salon ID.
    • ServiceOfferingFeignClient β†’ Retrieves services by their IDs.
    • PaymentFeignClient β†’ Generates the payment link.

2️⃣ Get All Bookings for a Customer

πŸ”Ή GET /api/bookings/customer

  • πŸ“ Description: Retrieves all bookings associated with a customer.
  • πŸ”‘ Header Parameters:
    • Authorization β†’ JWT token of the customer.
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: Set<BookingDTO> β†’ List of customer bookings.
  • πŸ”— Feign Clients:
    • UserFeignClient β†’ Validates the user.

3️⃣ Get All Bookings for a Salon

πŸ”Ή GET /api/bookings/salon

  • πŸ“ Description: Retrieves all bookings for a salon owned by the authenticated user.
  • πŸ”‘ Header Parameters:
    • Authorization β†’ JWT token of the salon owner.
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: Set<BookingDTO> β†’ List of salon bookings.
  • πŸ”— Feign Clients:
    • UserFeignClient β†’ Validates the user.
    • SalonFeignClient β†’ Retrieves salon information by owner.

4️⃣ Get a Salon Report

πŸ”Ή GET /api/bookings/report

  • πŸ“ Description: Retrieves a report of all bookings for the salon owned by the authenticated user.
  • πŸ”‘ Header Parameters:
    • Authorization β†’ JWT token of the salon owner.
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: SalonReport β†’ Report details for the salon.

5️⃣ Get Bookings by Date

πŸ”Ή GET /api/bookings/slots/salon/{salonId}/date/{date}

  • πŸ“ Description: Retrieves booked slots for a salon on a specific date.
  • πŸ”‘ Path Parameters:
    • salonId β†’ ID of the salon.
    • date β†’ Date for which slots are requested (format: YYYY-MM-DD).
  • πŸ”‘ Header Parameters:
    • Authorization β†’ JWT token of the user.
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: List<BookedSlotsDTO> β†’ List of booked slots.

6️⃣ Get a Booking by ID

πŸ”Ή GET /api/bookings/{bookingId}

  • πŸ“ Description: Retrieves details of a booking by its ID.
  • πŸ”‘ Path Parameter:
    • bookingId β†’ ID of the booking.
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: BookingDTO β†’ Details of the booking.

7️⃣ Update Booking Status

πŸ”Ή PUT /api/bookings/{bookingId}/status

  • πŸ“ Description: Updates the status of a booking (e.g., CONFIRMED, CANCELLED).
  • πŸ”‘ Path Parameter:
    • bookingId β†’ ID of the booking.
  • πŸ”‘ Query Parameter:
    • status β†’ New status for the booking.
  • πŸ“€ Response:
    • Status: 200 OK
    • Body: BookingDTO β†’ Updated booking details.

🎯 Highlights

  1. Role-Specific Endpoints:
    • Separate APIs for customers and salon owners.
  2. Integrated Feign Clients:
    • UserFeignClient β†’ Validates user requests.
    • SalonFeignClient β†’ Ensures secure access to salon-related data.
    • ServiceOfferingFeignClient β†’ Retrieves service details.
  3. Error Handling:
    • 404 Not Found β†’ If the resource does not exist.
    • 400 Bad Request β†’ For invalid input or state.
  4. Enhanced Security:
    • JWT-based authorization for all sensitive operations.
  5. Flexible Bookings Management:
    • Support for creating, updating, and querying bookings efficiently.

🌟 Payment Microservice API Documentation

Base URL: /api/payments

The Payment Controller handles APIs related to payment processing, including creating payment links, retrieving payment orders, and proceeding with payments.


Create Payment Link

POST /create

Creates a payment link for the specified booking using the given payment method.

Headers

  • Authorization: Bearer token of the user (String) (Required)

Request Body

  • BookingDTO: The details of the booking for which payment is being initiated.

Query Parameters

  • paymentMethod: The payment method to use (e.g., CREDIT_CARD, DEBIT_CARD, UPI, etc.)

Responses

  • 200 OK: Returns the payment link details.

    {
      "id": "string",
      "link": "string",
      "status": "string"
    }
    
  • 400 Bad Request: If required parameters are missing or invalid.

  • 500 Internal Server Error: If an error occurs while creating the payment link.


Get Payment Order by ID

GET /{paymentOrderId}

Fetches a payment order by its unique ID.

Path Parameters

  • paymentOrderId: The ID of the payment order (Long) (Required)

Responses

  • 200 OK: Returns the payment order details.

    {
      "id": "Long",
      "amount": "Double",
      "status": "String",
      "createdAt": "String",
      "updatedAt": "String"
    }
    
  • 404 Not Found: If the payment order with the specified ID does not exist.


Proceed Payment

PATCH /proceed

Processes a payment for the specified payment order.

Query Parameters

  • paymentId: The unique ID of the payment made by the user (String) (Required)
  • paymentLinkId: The unique ID of the payment link (String) (Required)

Responses

  • 200 OK: Returns true if the payment was processed successfully.

    true
    
  • 400 Bad Request: If the payment ID or link ID is invalid.

  • 500 Internal Server Error: If an error occurs while processing the payment.


Exceptions and Error Handling

UserException

  • Thrown when there is an issue with user authentication or user-related data.

RazorpayException

  • Thrown for issues related to Razorpay integration, such as link creation failures.

General Error Responses

  • 400 Bad Request: For invalid input or missing data.
  • 500 Internal Server Error: For any unexpected server-side errors.

Dependencies and Notes

  • The controller relies on the following services:
    • PaymentService: To handle payment-related logic.
    • UserFeignClient: To fetch user details from a remote service.
  • Supported payment methods include Razorpay integrations.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages