Skip to content

wasif1/ProjectCv

Repository files navigation

Spring Boot Application (Microservices)

Structure

spring-boot-microservices/
│
├── users/
│   ├── src/
│   ├── pom.xml (or build.gradle)
│   └── application.properties
│
├── experience/
│   ├── src/
│   ├── pom.xml (or build.gradle)
│   └── application.properties
│
├── projects/
│   ├── src/
│   ├── pom.xml (or build.gradle)
│   └── application.properties
│
├── reviews/
│   ├── src/
│   ├── pom.xml (or build.gradle)
│   └── application.properties
│
├── services/
│   ├── src/
│   ├── pom.xml (or build.gradle)
│   └── application.properties
│
├── skills/
│   ├── src/
│   ├── pom.xml (or build.gradle)
│   └── application.properties
│

Tools & Technology

Postgres Java Spring Gradle Postman IntelliJ IDEA

Getting Started

Spring Boot application featuring full CRUD operations with seamless PostgreSQL integration. Postman-tested and ready to go! 🚀

Prerequisites

List of software and tools which you need to get started

  • Java JDK 17

  • IntelliJ IDEA (Community Edition)

  • Gradle

  • Xcode Command Line Tools

    (for install) --> xcode-select --install
    (for verify) --> xcode-select -p 
  • Homebrew

    (for install) --> /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    (for verify) --> brew --version
    (if issue set PATH) -->  (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/waxif/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)"
  • PostgreSQL

    (for install) --> brew install postgresql
  • Start the PostgreSQL service:

    brew services start postgresql
  • Verify that PostgreSQL is running by checking its status:

    brew services list

Configure PostgreSQL

  • Switch to the default postgres user:

    psql postgres
  • Create a new databases for each module:

    CREATE DATABASE userdb;
    CREATE DATABASE projectsdb;
    CREATE DATABASE skillsdb;
    CREATE DATABASE reviewsdb;
    CREATE DATABASE experiencedb;
    CREATE DATABASE servicesdb;
  • Create a new user:

    CREATE USER your_username WITH PASSWORD 'your_password';
  • Grant all privileges on all the databases to the user:

    GRANT ALL PRIVILEGES ON DATABASE your_database_name TO your_username;
  • To check if the spring boot application process is running or not you can use this command :

    lsof -i :8080
  • To Kill the process you can use this command by passing process id which mention above screenshot as PID:

    kill -9 <PID>

    Now Goto Each module and run its main class to start the microservice:

    User module -> MainUser class
    Experience module -> MainExperience class
    Projects module -> MainProjects class
    Reviews module -> MainReviews class
    Services module -> MainServices class
    Skills module -> MainSkills class
  • Once all the services are running. Then you can check the following api URL in Postman.

    Users Api (PORT 8081)

     GET -> http://localhost:8081/api/users/{user_id}
     POST -> http://localhost:8081/api/users
     
     Param -> Body -> raw -> JSON 
     
     { //Required fields
      "name": "Name",
      "email": "[email protected]"
     }

    Experience Api (PORT 8080)

     GET -> http://localhost:8080/api/experience/users/{user_id}
     POST -> http://localhost:8080/api/experience/users/{user_id}
     
     Param -> Body -> raw -> JSON 
     
     { //Required fields
      "employer": "test1",
      "start_date": "12/11/2023",
      "end_date": "12/11/2023"
     }

    Projects Api (PORT 8082)

     GET -> http://localhost:8082/api/projects
     POST -> http://localhost:8082/api/projects/users/{user_id}
     
     Param -> Body -> raw -> JSON 
     
     { //Required fields
      "name": "test",
      "start_date": "12/11/2023",
      "end_date": "12/11/2023"
     }

    Reviews Api (PORT 8083)

     GET -> http://localhost:8083/api/reviews
     POST -> http://localhost:8083/api/reviews/users/{user_id}
     
     Param -> Body -> raw -> JSON 
     
     { //Required fields
      "name": "test",
      "start_date": "12/11/2023",
      "end_date": "12/11/2023"
     }

    Services Api (PORT 8084)

     GET -> http://localhost:8084/api/services
     POST -> http://localhost:8084/api/services/users/{user_id}
     
     Param -> Body -> raw -> JSON 
     
     { //Required fields
      "name": "test",
      "start_date": "12/11/2023",
      "end_date": "12/11/2023"
     }

    Skills Api (PORT 8085)

     GET -> http://localhost:8085/api/skills
     POST -> http://localhost:8085/api/skills/users/{user_id}
     
     Param -> Body -> raw -> JSON 
     
     { //Required fields
      "name": "test",
      "start_date": "12/11/2023",
      "end_date": "12/11/2023"
     }

NOTE: If you notice all microservices have different PORTS, so its very important to use the correct port to get the expected result.

  • You can get the POSTMAN file from
    ProjectCv -> postman -> postman_collection.json

Contact

Wasif Mujahid - @LinkedIn - [email protected]

Medium Articles

If you need more details, here are my few articles where i explained everything step by step.

(back to top)

About

Spring Boot Application for CRUD operations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published