Case study for nuvve
- Java 11+
- Maven 3+
- Git
- PostgreSQL 12+
First we need to clone the project
git clone git@github.com:datruq/epik.git
When it finished clonning and have it in your local machine, just open it with your preferred IDE and import all the dependencies with Maven
- Create a new data base on your local postgreSQL. In this case I named it "epik"
- Excecute the user.sql and ev.sql queries to create both tables. Those are inside the "sql" folder
- Open a command line window or terminal.
- Navigate to the root directory of the project, where the pom.xml resides.
- Compile the project:
mvn clean install -pl user_ev. - Change into the target directory: user_ev/target/ Or you can use the one already generated inside the "jars" folder
- You should see the file name: user_ev-0.0.1-SNAPSHOT.jar.
- Execute the JAR:
java -user_ev-0.0.1-SNAPSHOT.jar. - The application should be available at http://localhost:8080/.
- Open a command line window or terminal.
- Navigate to the root directory of the project, where the pom.xml resides.
- Compile the project:
mvn clean install package -pl user_ev. - Build the docker image with the command
docker build -t nuvve . - Run a docker container with the previus image
docker run -p 8090:8080 nuvve
With this Epik app we can get:
- User CRUD
- EV CRUD
- Basic stats from Users and EVs
Get all users.
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://localhost:8080/user/
Get user by id.
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://localhost:8080/user/{userId}
Get all Evs.
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://localhost:8080/ev/
Get Ev by id.
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://localhost:8080/ev/{evId}
Alternatively to curl, you can use Postman to target the REST API.
Get all users
[GET] http://localhost:8080/users/
Create user
[POST] http://localhost:8080/users/
Update user
[PUT] http://localhost:8080/users/
Delete user
[DELETE] http://localhost:8080/users/{userId}
Get all Evs
[GET] http://localhost:8080/ev/
Get Evs by Id
[GET] http://localhost:8080/ev/{evId}
Find out which are the best-selling models!
[GET] http://localhost:8080/ev/findMostPopularEv/
- Spring - The web framework used
- Maven - Dependency Management
- Junit Java unit testing framework
- Mockito Java Mocking framework
- PostgreSQL Data Base management system
- David Trujillo - Initial work - datruq