The POS Backend API is designed to manage various functionalities within a Point of Sale system, covering user authentication, item management, stock updates, category management, and sales processing. This API follows the OpenAPI Specification (OAS 3.0) and provides detailed endpoints for different user roles.
This project was created as a learning experience to understand how to work with Spring Boot, JWT authentication, and Swagger documentation.
- GitHub Repository: Pos-Backend
- Swagger UI:
http://localhost:8080/swagger-ui/index.html
The security model for this API uses JWT authentication to control access based on user roles.
- Public Access: No authentication is needed for endpoints like
/auth/**
,/swagger-ui/**
, and/v3/**
. - Admin-only Access: Requires an ADMIN role for endpoints starting with
/admin/**
. - Manager and Admin Access: Requires either MANAGER or ADMIN roles for endpoints starting with
/manager/**
. - Cashier, Manager, and Admin Access: Accessible by CASHIER, MANAGER, or ADMIN roles for general requests.
Note: To create an admin user, temporarily permit all requests in
WebSecurityConfig.java
.
POST /auth/login
: Authenticates users and returns a JWT token.POST /admin/users
: Allows admins to create new users.GET /user
: Retrieves the authenticated user's information.GET /admin/allusers
: Lists all users.DELETE /admin/users/{username}
: Deletes a user based on username.
POST /manager/items
: Creates a new item.PUT /manager/items/{id}
: Updates an existing item.DELETE /manager/items/{id}
: Deletes an item by ID.GET /items
: Retrieves all items.GET /items/{id}
: Fetches an item by its ID.
PUT /manager/stocks
: Updates stock quantity for an item.GET /stocks/{id}
: Retrieves stock details by item ID.
POST /manager/categories
: Creates a new category.PUT /manager/categories/{id}
: Updates an existing category.DELETE /manager/categories/{id}
: Deletes a category.GET /categories
: Retrieves all categories.GET /categories/{id}
: Fetches a category by its ID.
POST /sale
: Creates a new sale and returns the created entity.GET /sale/{id}
: Retrieves sale details by sale ID.
- Spring Boot: Backend framework.
- JWT (JSON Web Token): For secure user authentication.
- Swagger: For API documentation and testing.
- Clone the repository from GitHub:
git clone https://github.com/SACHIBOT/Pos-Backend.git
- Navigate to the project directory:
cd Pos-Backend
- Build the project using Maven:
mvn clean install
- Run the application:
mvn spring-boot:run
- Access the Swagger UI at
http://localhost:8080/swagger-ui/index.html
to explore and test the endpoints.
This project is open-source and available under the MIT License.