Spring Boot, PostgreSQL and AI

Spring Boot + PostgreSQL + AI

REST APIs, JPA, and a chat agent — 29 parts

Follow the chapters in order, or open any topic you need. Each part includes runnable Java examples and production-minded notes. Topics run from project setup and configuration to CRUD, validation, global exception handling, pagination, testing, AI integration, persisting chat history, Docker, and deploy basics.

Go to the main Java section for the broader core-to-advanced learning guide.

What is Spring Boot and why teams use it
Read More →

What is Spring Boot and why teams use it

A friendly introduction to Spring Boot: what problem it solves, how it fits on top of Spring Framework, and why it is the default choice for new Java services.

Learn more
JAR vs WAR in Java and Spring Boot
Read More →

JAR vs WAR in Java and Spring Boot

When you build a Java app you get a JAR or a WAR. This post explains the difference, what Spring Boot prefers, and what that means for you day to day.

Learn more
Maven vs Gradle for Spring Boot
Read More →

Maven vs Gradle for Spring Boot

How Maven and Gradle both build Spring Boot projects, the mental model of each, and a practical pick for this series.

Learn more
Spring Boot project setup with Spring Initializr
Read More →

Spring Boot project setup with Spring Initializr

Step by step: create a Spring Boot project on start.spring.io (or the IDE), choose the right options for REST and PostgreSQL, and run it the first time.

Learn more
Spring Boot project structure explained
Read More →

Spring Boot project structure explained

A practical package layout for a layered REST service: what goes where, and how Spring finds your beans.

Learn more
application.yml vs application.properties in Spring Boot
Read More →

application.yml vs application.properties in Spring Boot

How Spring reads externalized configuration, when to use YAML or properties, and a typical starter application.yml for this series.

Learn more
Spring Boot configuration best practices
Read More →

Spring Boot configuration best practices

Sensible rules for config files, secrets, feature flags, and 12-factor style for Spring Boot services on the way to production.

Learn more
PostgreSQL setup for Spring Boot (local and Docker)
Read More →

PostgreSQL setup for Spring Boot (local and Docker)

Install or run PostgreSQL, create a database and user, and verify connectivity before Spring Data JPA talks to it.

Learn more
Required Spring Boot starters for REST + JPA + PostgreSQL
Read More →

Required Spring Boot starters for REST + JPA + PostgreSQL

Which starters to add in a REST API with PostgreSQL, Lombok, Validation, and DevTools, and what each one brings to the classpath.

Learn more
Entity layer in Spring Data JPA
Read More →

Entity layer in Spring Data JPA

Model database tables with JPA entities, ids, column mapping, and relationships—foundation for a REST service backed by PostgreSQL.

Learn more
Repository layer with Spring Data JPA
Read More →

Repository layer with Spring Data JPA

Use JpaRepository for CRUD and derived queries, and when to drop down to @Query or custom implementations.

Learn more
Service layer: use cases and transactions in Spring
Read More →

Service layer: use cases and transactions in Spring

Build a service class with @Service, constructor injection, and @Transactional for coherent business operations around your repositories.

Learn more
Controller layer: @RestController and HTTP mapping in Spring Boot
Read More →

Controller layer: @RestController and HTTP mapping in Spring Boot

Expose JSON REST endpoints with @RestController, @RequestMapping, proper HTTP status codes, and no business rules in the controller class.

Learn more
DTOs for request and response in a Spring REST API
Read More →

DTOs for request and response in a Spring REST API

Separates JSON contracts from JPA entities using records or classes, so your API can evolve without leaking database details.

Learn more
CRUD REST API with PostgreSQL and Spring Boot
Read More →

CRUD REST API with PostgreSQL and Spring Boot

Implement create, read, update, and delete for a resource, wire JPA, and return appropriate HTTP status codes and bodies.

Learn more
Validation in Spring REST with Jakarta Bean Validation
Read More →

Validation in Spring REST with Jakarta Bean Validation

Use @NotBlank, @Size, @Min on request DTOs, @Valid on the controller, and return clear 400 responses when the client payload is wrong.

Learn more
Global exception handling with @ControllerAdvice in Spring
Read More →

Global exception handling with @ControllerAdvice in Spring

Map exceptions to HTTP status, body, and problem details so your API is predictable and easy to test.

Learn more
Pagination and sorting in Spring Data REST lists
Read More →

Pagination and sorting in Spring Data REST lists

Use Pageable, Page, and sort parameters so list endpoints stay fast and predictable as tables grow.

Learn more
Testing your Spring REST API with Postman (or a similar client)
Read More →

Testing your Spring REST API with Postman (or a similar client)

Send requests, save a collection, pass variables, and read responses so you can verify behavior before a frontend or mobile app exists.

Learn more
Build and run a Spring Boot application (Maven/Gradle, JAR, and local run)
Read More →

Build and run a Spring Boot application (Maven/Gradle, JAR, and local run)

Compile, package a runnable JAR, run it, and use dev-friendly commands so you are not lost on day one of a new project.

Learn more
Environment variables and Spring profiles for real deployments
Read More →

Environment variables and Spring profiles for real deployments

Keep secrets and environment-specific values out of source, use application-{profile}, and override with env vars the platform provides.

Learn more
What is an “AI agent” in a Spring Boot backend (plain English)
Read More →

What is an “AI agent” in a Spring Boot backend (plain English)

Agent means the system can take a goal, call tools, and use a model in a loop—here we start with a single request–response chat as the foundation.

Learn more
Create a chat-style REST API in Spring Boot
Read More →

Create a chat-style REST API in Spring Boot

Add request and response DTOs, a ChatController, and a service interface so you can plug the model implementation in the next post.

Learn more
Connect Spring Boot to a remote language model (OpenAI-compatible API)
Read More →

Connect Spring Boot to a remote language model (OpenAI-compatible API)

Implement ChatService with RestClient, read base URL and API key from configuration, and parse JSON in a way you can test without calling the real API every time.

Learn more
Store AI chat history in PostgreSQL (sessions and messages)
Read More →

Store AI chat history in PostgreSQL (sessions and messages)

Add ChatSession and ChatMessage entities, persist user and assistant turns, and build the messages list you send to the model from the database.

Learn more
Putting it together: final project architecture (REST + JPA + LLM)
Read More →

Putting it together: final project architecture (REST + JPA + LLM)

A concise map of packages, data flow, and boundaries so a new teammate can find where things live and what depends on what.

Learn more
Dockerize Spring Boot and PostgreSQL for a reproducible local stack
Read More →

Dockerize Spring Boot and PostgreSQL for a reproducible local stack

A multi-stage Dockerfile for a lean runtime image, plus docker-compose wiring the app to Postgres with healthchecks and the right environment variables.

Learn more
Deployment basics: from JAR to a running service people can trust
Read More →

Deployment basics: from JAR to a running service people can trust

Environment separation, health checks, zero-secrets in images, and what you verify before and after a release—so production is not a mystery for beginners.

Learn more
Full Spring Boot + PostgreSQL CRUD app .
Read More →

Full Spring Boot + PostgreSQL CRUD app .

Maven project, YAML config, and Java source for Item CRUD (create, read, list, update, delete) on PostgreSQL. Run with Docker for Postgres and mvnw spring-boot:run.

Learn more