The Invoice System is a Java-based Spring Boot application designed to manage and generate invoices for products bought by users. It utilizes CockroachDB for database management, Redis for caching, and integrates GraphQL for querying data.
- Spring Boot
- CockroachDB
- Redis
- GraphQL
- Lombok
- OpenPDF
Click here to install CockroachDB.
Open powershell and run the following command -
C:\Users\Admin\Downloads> cockroach start-single-node --insecure `
>> --listen-addr=localhost:26257 `
>> --http-addr=localhost:8080
Install WSL, enable the necessary features, and restart the system.
Install Ubuntu distros for windows.
Launch Ubuntu and install the Redis server
Run the following command to run redis server:
redis-server
Run redis-cli and run the command ‘ping’. If you get the response ’pong’ then redis is running.
Click here to install RedisInsight in your windows system to view the data in Redis.
Url: http://localhost:8080/api/graphql
The GraphQL queries for the APIs in the application:
{
getAllInvoices
{
products{
id
name
price
quantity
totalPrice
transactionId
}
paymentStatus
amount
}
}
{
getInvoice(id: "3f31fda3-9e28-4798-8766-2b6e40634dcb")
{
products{
id
name
price
quantity
totalPrice
transactionId
}
paymentStatus
amount
}
}
mutation{
saveInvoice(prods: [{name:" ",price: 14.0,quantity:4,totalPrice: null,transactionId: id"}],payment: true)
{
id
products{
id
name
price
quantity
totalPrice
transactionId
}
createdDate
createdTime
paymentStatus
amount
}
}
mutation{
updateInvoice(prods: [{id:"id",name:" ",price: 14.0,quantity:4,totalPrice: 56.0,transactionId: "id"}],id: "id",payment: true)
{
id
products{
id
name
price
quantity
totalPrice
transactionId
}
createdDate
createdTime
paymentStatus
amount
}
}
mutation{
deleteInvoice(id: "d4ce58dc-bd3d-4205-b929-43b1835498e4")
}
The project includes Dockerfiles and a docker-compose.yml file for easy deployment using Docker. Follow the steps in the Docker Setup section above.
To download the images from the docker repository:
docker pull nevin1m/invoice-system -a
Lombok is a Java library that helps to reduce boilerplate code in your Spring Boot application. It provides a set of annotations that automatically generate common code during compilation, making your code more concise and readable. Start using Lombok annotations in your code to reduce verbosity and improve code readability.
-
@Getter and @Setter: Automatically generate getter and setter methods for your classes.
-
@NoArgsConstructor, @AllArgsConstructor, and @RequiredArgsConstructor: Generate constructors without the need for boilerplate code.
-
@EqualsAndHashCode: Automatically generate equals and hashCode methods based on the fields of your class.
-
@ToString: Automatically generate a meaningful toString method.
To integrate Lombok into your project, add the Lombok dependency to your build configuration.
The Invoice System leverages OpenPDF, an open-source PDF generation library for Java, to dynamically create and manage PDF documents. OpenPDF simplifies the process of generating professional-looking invoices.
-
Text Formatting: Precise control over text formatting ensures polished and professional PDF content.
-
Image Embedding: Supports embedding images into PDFs, facilitating the inclusion of logos and graphical elements.
-
Page Manipulation: Functionality for manipulating pages enhances organization and structure within generated documents.
OpenPDF seamlessly integrates with the Spring Boot application, enhancing user experience by delivering well-designed and visually appealing invoices.
application.properties: Configure database connections, GraphQL, and other application properties.
This project is licensed under the MPL License - see the LICENSE.md file for details.