# Nebula ERP Purchase

## Overview

The Nebula ERP Purchase project is a module within an ERP system focused on managing purchase processes, including purchase orders, goods received notes (GRN), purchase returns, and supplier management. This project features JWT-based authentication, modular architecture, and comprehensive documentation via Swagger.

## Features

- **Purchase Management**: Handles purchase orders, goods received notes, and purchase returns.
- **Supplier Management**: Manages suppliers and their details.
- **JWT Authentication**: Secured APIs using JWT for authentication and access control.
- **Modular Structure**: Organized into controllers, services, models, repositories, and utilities for better code maintainability.
- **Maven-based Build**: Easily build and manage dependencies.
- **Swagger Documentation**: Built-in API documentation.

## Technologies

- **Java**: Primary programming language for the application.
- **Spring Boot**: Framework for building the application.
- **Maven**: Dependency and project management.
- **JWT**: For secure authentication.
- **PostgreSQL**: Database for handling persistent data.
- **Swagger**: Provides interactive API documentation.

## Prerequisites

Before running this project, ensure you have the following installed:

- [JAVA](https://www.java.com/en/) (version 11 or later)
- [Maven](https://maven.apache.org/)
- [PostgreSQL](https://sbp.enterprisedb.com/getfile.jsp?fileid=1259129)

## Installation

Follow these steps to set up the project locally:

1. **Clone the repository:**

   ```bash
   git clone <repository-url>
   cd nebula-erp-purchase

2. **Set up PostgreSQL Database:**

   Set up your PostgreSQL database with the required schemas and tables, as referenced in application.properties.

3. **Configure environment properties:**

   Update src/main/resources/application.properties with your database credentials and other environment-specific settings.

4. **Build the application:**

   ```bash
   mvn clean install 

## Running the Application

To start the application, run:

`mvn spring-boot:run`

The server will run on http://localhost:8085 by default. You can adjust the port in application.properties.

## API Documentation

API documentation is available through Swagger. After starting the application, access it at:

   ```bash
   http://localhost:8085/swagger-ui.html
   ```
   

## Project Structure

- **src/main/java/com/nebula/erp/purchase/config**: Configuration files for OpenAPI and web settings.
- **src/main/java/com/nebula/erp/purchase/controller**: Controllers for managing each feature (GRN, Purchase, Supplier, etc.).
- **src/main/java/com/nebula/erp/purchase/model**: Entity models for database tables related to purchase management.
- **src/main/java/com/nebula/erp/purchase/repository**: Repository interfaces for database interactions.
- **src/main/java/com/nebula/erp/purchase/service**: Business logic for each module.
- **src/main/java/com/nebula/erp/purchase/utility**: Utilities for handling responses and JWT processing.

## Key Endpoints

- **Purchase Orders**: /api/purchase/...
- **Goods Received Notes (GRN)**: /api/grn/...
- **Purchase Returns**: /api/purchase-returns/...
- **Suppliers**: /api/suppliers/...

## Security

The application uses JWT tokens for secure access. Update JwtUtils.java for token configurations, and ensure your JWT secret and expiration settings are specified in application.properties.

## Additional Configurations

- **Swagger**: Configurations in OpenAPIConfiguration.java control the settings for API documentation.
- **Environment Variables**: Update .properties files as necessary for development, testing, and production environments.