Employee CRUD (Create, Read, Update, Delete) operation using Kotlin with Ktor and Koin frameworks:
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.
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.
Before running the application, ensure you have the following installed:
- Kotlin
- Ktor
- Koin
- JDK
- Gradle
To run the application, follow these steps:
- Clone the repository:
git clone <repository_url>
- Navigate to the project directory:
cd employee-crud-kotlin-ktor-koin
- Build the project:
gradle build
- Run the application:
gradle run
By default, the application will start on port 8080.
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.
You can configure the application settings such as database connection details, server port, etc., in the application.conf
file located in the resources
directory.
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.
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
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.