My first spring boot project - Task Manager API
Day 1 - Configuring application and database properties
I configured the database console for the application and I'm using H2 for the database connection and for creating the sql tables cause its easier and more beginner friendly than PostgreSQL which I'll be using in my later projects but for now I'm sticking with H2. I then configured the JPA database to tell spring which kind of sql I'm using as different sql have different syntax. I used it by implementing this line of code : spring.jpa.database.platform=org.hibernate.dialect.H2Dialect which tells spring that I'm using H2 for database configuration. Next, I set up my project structure and added 5 core spring dependencies like Spring-Web, Spring Data, H2 Database, Lombok and Spring boot dev tools. Then I started to create the entity layer in which I first created a public Enum with 3 status values : PENDING (default value), IN_PROGESS and COMPLETED. Then I created a Task Entity class with 7 fields like id , title, description, status, dueDate, createdAt and updatedAt. Then I added the JPA Annotations to avoid less boilerplate code and make my code look cleaner and more understandable. I added annotatios like - @Entity (Marks the database table) , @Table(name = "tasks") - for customizing the table name, @Id + @GeneratedValue - Primary key with auto-increment, @Column - Column constraints , @Enumerated(EnumType.STRING) - for storing the Enum as text.
Day 2 - Moving on with the Repository Layer, Service layer and Contoller Layer and Testing the API
Firstly, I added Lombok annotations and hibernate annotations like @CreateTimeStamp, @UpdateTimeStamp. I saw how Lombok saved me a 100 lines of code . Then , I moved on with the Respository layer by creating TaskRespository.java file which contained a taskRepository interface that extends JPARepository. Then I created the Service Layer in a file name TaskService.java for handling the business logical functions like UpdateTask() and CreateTask(). Finally , I created the controller Layer and included REST endpoints annotations like @RestController and @RequestMapping. Then to test my final application , I deployed it using an AWS cloud server and it was tested successfully , I've added the link to the cloud server in the project description so anyone seeing this can directly test the API on the cloud server. I haven't added my API to a frontend which I know would have made it look more cooler for user interaction but anyways its a backend project, but I'll be adding the frontend too with the API in my later projects so that its easier for non-technical users to interact with my projects easily.