Skip to content

About

A Java backend project built with Spring Boot, Spring Data JPA, and MySQL, focused on REST API development, CRUD operations, and clean layered architecture.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation

CRUD Spring Boot

A Java backend project built with Spring Boot, Spring Data JPA, and MySQL, focused on REST API development, CRUD operations, and maintainable application architecture.

Java Spring Boot Spring Data JPA MySQL Maven

Overview

CRUD Spring Boot is a backend project designed to explore the foundations of building REST APIs with the Spring ecosystem.

The project starts with a Spring Boot application configured with Spring Web MVC, Spring Data JPA, MySQL connectivity, Maven, and testing dependencies. Its goal is to evolve into a structured backend application that demonstrates resource management, database persistence, validation, and reliable HTTP error handling.

The repository is currently a foundation for development. CRUD endpoints, business entities, validation, and other features should be considered implemented only when they are present in the source code.

Technology Stack

Technology Purpose
Java 17+ Backend programming language
Spring Boot 4 Application framework and configuration
Spring Web MVC HTTP request handling and REST API development
Spring Data JPA Persistence abstraction and repository support
Hibernate Object-relational mapping through JPA
MySQL Relational database
Maven Dependency management and build automation
Spring Boot testing dependencies Application testing

Architecture

The intended design follows a layered architecture that separates HTTP handling, business logic, and data access.

Client
  |
  | HTTP / JSON
  v
REST Controller
  |
  v
Service Layer
  |
  v
Repository Layer
  |
  v
JPA / Hibernate
  |
  v
MySQL Database

Layer responsibilities

  • Controller: Handles HTTP requests and defines API endpoints.
  • Service: Contains business rules and coordinates operations.
  • Repository: Provides database access through Spring Data JPA.
  • Entity: Represents persistent domain objects.
  • DTO: Defines request and response structures independently of database entities.
  • Exception handling: Provides consistent API error responses.

This is the target architecture; the corresponding layers must be implemented and verified in the codebase before being considered complete.

Getting Started

Prerequisites

  • JDK 17 or a compatible version required by the selected Spring Boot release.
  • MySQL Server.
  • Git.
  • Maven, or the Maven Wrapper included in the repository.

1. Clone the repository

git clone https://github.com/ELGHAD/CRUD_SpringBoot.git
cd CRUD_SpringBoot

2. Create a MySQL database

CREATE DATABASE crud_springboot_db;

3. Configure the database connection

Update src/main/resources/application.properties with your local database settings:

spring.datasource.url=jdbc:mysql://localhost:3306/crud_springboot_db
spring.datasource.username=${DB_USERNAME}
spring.datasource.password=${DB_PASSWORD}

spring.jpa.hibernate.ddl-auto=update

Set DB_USERNAME and DB_PASSWORD in your environment before launching the application. Adapt the configuration to the properties already present in the repository.

Security: Never commit real database credentials. Schema auto-update is convenient during development, but production environments should use a controlled database migration strategy.

4. Build the application

On Linux or macOS:

./mvnw clean package

On Windows:

.\mvnw.cmd clean package

5. Run the application

On Linux or macOS:

./mvnw spring-boot:run

On Windows:

.\mvnw.cmd spring-boot:run

The default Spring Boot port is 8080, unless changed in the application configuration.

The application will start according to the features and configuration currently implemented in the repository.

Planned CRUD API

The following table describes the intended API contract for a future generic resource. These endpoints are examples, not a claim that the routes already exist.

Method Example endpoint Intended operation
POST /api/v1/items Create a resource
GET /api/v1/items Retrieve resources
GET /api/v1/items/{id} Retrieve one resource
PUT /api/v1/items/{id} Update a resource
DELETE /api/v1/items/{id} Delete a resource

Once implemented, the API should use appropriate HTTP status codes, validate incoming data, and return consistent error responses.

Engineering Principles

The project aims to reinforce practical backend development principles:

  • Separation of concerns and layered architecture.
  • Clear REST API conventions.
  • Maintainable Java code and meaningful naming.
  • Reliable database access and transaction management.
  • Input validation and predictable error handling.
  • Automated testing and reproducible builds.
  • Secure configuration and responsible secret management.

Author

ELGHAD

About

A Java backend project built with Spring Boot, Spring Data JPA, and MySQL, focused on REST API development, CRUD operations, and clean layered architecture.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages