How mehmetgencv/ktor-bank works
Project Type and Purpose
• Project Type: A backend REST API built with Ktor.
• Purpose: Provides a simple banking service with operations for creating accounts, depositing, withdrawing, and transferring money.
• Key Technologies: Ktor (as the server framework), Kotlin, Exposed (ORM), and H2 (in-memory database).
File Structure to Define Architectural Layers
• Top-Level Organization: The project follows a layered design with clear separation by packages inside src/main/kotlin.
• Core Directories:
• config: Contains application configuration files (e.g., database, serialization, exception handling) that set up the Ktor environment.
• dto: Houses Data Transfer Objects, defining the structure of incoming/outgoing data.
• model: Contains domain models such as Account, Transaction, and TransactionType that define the business entities.
• repository: Implements CRUD operations for the database interactions via the Exposed library.
• service: Contains business logic (e.g., AccountService) that mediates between API calls and data persistence.
• routes: Defines the API endpoints and maps HTTP requests to the corresponding service operations.
• exceptions: Lists custom exceptions used for error handling (e.g., AccountNotFoundException).