Skip to content

Latest commit

 

History

History
95 lines (60 loc) · 2.79 KB

README.md

File metadata and controls

95 lines (60 loc) · 2.79 KB

Employee CRUD (Create, Read, Update, Delete) operation using Kotlin with Ktor and Koin frameworks:


Employee CRUD Operations using Kotlin, Ktor, and Koin

This project demonstrates how to perform CRUD operations for managing employee data using Kotlin programming language with Ktor framework for building HTTP servers and Koin framework for dependency injection.

Project Structure

The project is structured as follows:

  • src/main/kotlin/com/api/rest/ktor/ : Contains the main Kotlin source code.
  • src/main/kotlin/com/api/rest/ktor/routes/ : Contains controller classes responsible for handling HTTP requests.
  • src/main/kotlin/com/api/rest/ktor/services/ : Contains service classes responsible for business logic.
  • src/main/kotlin/com/api/rest/ktor/models/ : Contains data classes representing the Employee entity.
  • src/main/kotlin/com/api/rest/ktor/di/ : Contains Koin modules for dependency injection configuration.
  • src/test/kotlin/ : Contains unit and integration tests for the application.

Prerequisites

Before running the application, ensure you have the following installed:

  • Kotlin
  • Ktor
  • Koin
  • JDK
  • Gradle

Running the Application

To run the application, follow these steps:

  1. Clone the repository:
git clone <repository_url>
  1. Navigate to the project directory:
cd employee-crud-kotlin-ktor-koin
  1. Build the project:
gradle build
  1. Run the application:
gradle run

By default, the application will start on port 8080.

Endpoints

The application exposes the following endpoints:

  • GET /employees: Fetches all employees.
  • GET /employees/{id}: Fetches details of a specific employee by ID.
  • POST /employees: Creates a new employee.
  • DELETE /employees/{id}: Deletes a specific employee by ID.

Configuration

You can configure the application settings such as database connection details, server port, etc., in the application.conf file located in the resources directory.

Dependencies

The project uses the following dependencies:

  • Ktor: Web framework for building asynchronous servers and clients.
  • Koin: Dependency injection framework for Kotlin.
  • netty: Lightweight in-memory server for running kotlin or SpringBoot application.

Testing

The application includes unit tests and integration tests to ensure the correctness of business logic and API endpoints. You can run the tests using the following command:

gradle test

Contributing

Contributions are welcome! Feel free to open issues or pull requests for any improvements or fixes.


Feel free to customize this README according to your project's specific requirements and features. This README provides a basic outline to get started with building an Employee CRUD application using Kotlin, Ktor, and Koin frameworks.