A role-controlled application for selling products and generating PDF receipts.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
This project tackles the challenges of managing product sales and generating professional receipts. Our role-based application, built on the robust Spring Boot framework, streamlines these processes for enhanced efficiency and accuracy.
Key Features:
- Role-based Access Control: Securely manage user permissions (product management, orders, receipts).
- Product Management: Effortlessly add, update, and track product details and pricing.
- Order Processing: Simplify order placement, monitor status, and generate invoices.
- Automated PDF Receipts: Generate professional PDF receipts with comprehensive order and product information.
- JDK 17 or higher
- Maven 3.6.3 or higher
- PostgreSQL 15 or higher
- Docker (optional)
-
Clone the repository:
git clone https://github.com/baranyalcinn/TYT-Project.git
-
Navigate to the project directory:
cd master -
Create Database
CREATE DATABASE your_database_name;
-
Update Database Configuration Open the
application-dev.ymlorapplication-test.ymlfile in thesrc/main/resourcesdirectory and update the database connection details:spring: datasource: url: jdbc:postgresql://localhost:5432/your_database_name username: your_database_user password: your_database_password -
Run the application:
mvn spring-boot:run
This project includes a Postman collection to help you quickly explore and test the API.
Getting Started with the Postman Collection:
-
Download the Collection: You can download the
toyota.postman_collection.jsonfile here. -
Import into Postman:
- Open your Postman application.
- Click on Import.
- Select the
toyota.postman_collection.jsonfile you downloaded.
-
Start Testing! The collection contains pre-configured requests for the API endpoints. You can now send requests and explore the API's functionality.
dev: For local development and testing withapplication-dev.ymlfile.test: For deployment and testing on a server or other machines withapplication-test.ymlfile (default for Docker).
This file (readyForProject.sql) contains the SQL statements to create and populate tables for your project. Follow these steps to import the tables into your PostgreSQL database:
1. Using the psql Tool (Command Line):
-
Open your terminal and connect to your PostgreSQL server:
psql -h localhost -p 5432 -U your_username -d your_database_name
(Replace
localhost,5432,your_username, andyour_database_namewith your actual credentials if needed) -
Run the following command to import the SQL file:
psql -h localhost -p 5432 -U your_username -d your_database_name < readyForProject.sql
2. Using the pgAdmin Tool (Graphical):
- Open pgAdmin and connect to your PostgreSQL server.
- Right-click on your target database.
- Select the "Query Tool" option.
- Open the
readyForProject.sqlfile in a text editor, copy its contents, and paste them into the Query Tool. - Click the "Execute" button (looks like a lightning bolt).
Important Notes:
- Make sure your PostgreSQL server is running and you can connect to the database where you want to import the tables.
- Backup your existing database: This process will overwrite any existing tables with the same names. If you have valuable data in those tables, back them up before importing.
- The
readyForProject.sqlfile might contain sensitive data. Store this file securely.
The docker-compose.yml file makes it easy to run the application using Docker containers. The volumes section within this file manages how files are shared between the containers and your host computer. Here's a breakdown of the volume definitions used in this project:
1. Application Logs (x-log-volume)
This volume maps the application logs from your host machine to the /app/logs directory inside the container.
- On your host machine:
- Create a directory named
TYT-Projectin a location you prefer (e.g.,Documents). - Inside the
TYT-Projectdirectory, create a subdirectory namedlogs.
- Create a directory named
- Updating
docker-compose.yml:- Modify the
x-log-volumedefinition to point to this new logs directory:x-log-volume: &log-volume /path/to/your/TYT-Project/logs:/app/logs
- Replace
/path/to/your/TYT-Project/logswith the actual path to your logs directory.
- Modify the
2. Generated Slips (x-slips-volume)
This volume maps the generated slips from your host machine to the /usr/share/app/slips directory inside the container.
- On your host machine:
- Inside the
TYT-Projectdirectory, create another subdirectory namedslips.
- Inside the
- Updating
docker-compose.yml:- Update the
x-slips-volumedefinition:x-slips-volume: &slips-volume /path/to/your/TYT-Project/slips:/usr/share/app/slips
- Replace
/path/to/your/TYT-Project/slipswith the actual path to your slips directory.
- Update the
Key Advantages of Using Volumes:
- Persistence: Even if your Docker containers are stopped or removed, your log files and generated slips will remain safe in the designated folders on your host machine.
- Easy Access: You can directly access and manage these files using your preferred tools on your host system.
- Organization: Keeping these files separate from the container's file system promotes better organization of your project.
By following these steps, you'll create dedicated directories on your host machine for both the logs and the generated slips. This makes it much simpler to manage these files, even when you're running your application with Docker.
-
Build the Docker image:
mvn compile jib:dockerBuild
-
Run the Docker-Compose:
docker-compose up --build -d
Make sure to expose the port you specified in your application properties.
- Implement additional features.
- Enhance API documentation.
- Improve test coverage.
- Integrate with other services.
See the open issues for a full list of proposed features (and known issues).
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature.
- Make your changes and commit them.
- Push your changes to your fork.
- Submit a pull request.
- Baran Yalçın - @Linkedin - brnylcn19@gmail.com
Project Link: https://github.com/baranyalcinn/TYT-Project/tree/master