To run this application, follow the below steps
-
clone the frontend git repository from https://github.com/saikumarpb/todo-react
-
clone the backend git repository from https://github.com/saikumarpb/spring-boot-todo-backend
-
Instructions to setup frontend repository are mentioned in the Readme.md file in the frontend repository. Follow the instructions and complete the frontend setup successfully.
-
The configuration file for this application is located at
src\main\resources\application.properties
-
This application uses
postgres
as database. if you have an existing postgres service available update database configuration such as database url, port, databse name, username, password in DATABASE PROPERTIES section of theapplication.properties
file and proceed from step 7. -
if existing
postgres
service is not available, (assuming docker/docker desktop is available in your machine) open terminal project folder and executedocker-compose up -d
command. -
once the postgres service is up and running. next step is to create a database with a name. in this project the database name is
test
. if running postgres on docker execute the container either through docker desktop or from terminal (assuming terminal is linux or git bash) withdocker exec -it postgres bash
>su postgres
>psql
>CREATE DATABASE test;
-
After creating a databse and configuring it properly in application.properties. (Assuming code editor is
intellij
)- this project uses java 11 . use a java 11 sdk from File > Project structure > Project > Project SDK > select a version 11 SDK.
- choose a proper jvm under File > Settings > Build, Execution and Deployment > Build Tools > Gradle > Gradle JVM to be version 11.
-
Load/Reload the gradle project and complete the build.
-
Once the build, indexing is completed. now setup the run configuration Run/Debug Configuration menu > Edit Configurations > Add new configuration > Gradle > select spring-boot-todo-backend > Run > select bootRun > Click on Ok.
-
Now setup is completed. run the application. Tomcat should start on port specified in application.properties file (Port: 8000). backend is available at http://localhost:8000
-
Add the backend url in frontend application to connect to backend and run the frontend application.
- Get Todolist API
Request : curl --location --request GET 'http://localhost:8000/todolist/'` Response : { "pending": [ { "id": 1, "text": "test task desciption" } ], "completed": [ { "id": 2, "text": "completed task desciption" } ] }
- Post Task API (create/update a task/todo)
curl --location --request POST 'http://localhost:8000/todolist/post' \ --header 'Content-Type: application/json' \ --data-raw '{ "id": 1, "text": "test task desciption", "isPending": true }'`
- Delete task API
curl --location --request DELETE 'http://localhost:8000/todolist/delete/1'
- Todo is a very basic and simple CRUD application with add,edit,delete functionality.
- DB contains a single table
todo
Table "public.todo" Column | Type | Collation | Nullable | Default ------------+------------------------+-----------+----------+--------- id | bigint | | not null | is_pending | boolean | | not null | text | character varying(255) | | | Indexes: "todo_pkey" PRIMARY KEY, btree (id)