|
| 1 | +# Gemini Context: DataSource-Extensions |
| 2 | + |
| 3 | +This document provides context and instructions for working with the `DataSource-Extensions` project. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +`DataSource-Extensions` is a collection of libraries and extensions for the Caplin DataSource platform. It focuses on modernizing integrations using Reactive programming models and Spring Boot. |
| 8 | + |
| 9 | +**Key Technologies:** |
| 10 | +* **Languages:** Kotlin (primary), Java |
| 11 | +* **Build System:** Gradle (Kotlin DSL) |
| 12 | +* **Frameworks:** Spring Boot 3.x, Caplin DataSource, Project Reactor, Kotlin Coroutines (Flow) |
| 13 | +* **Testing:** Kotest, Turbine, MockK, JUnit 5 |
| 14 | + |
| 15 | +## Architecture & Modules |
| 16 | + |
| 17 | +The project is a multi-module Gradle project: |
| 18 | + |
| 19 | +* **`datasourcex-reactive-core` & `api`**: Core abstractions for reactive data sources. |
| 20 | +* **`datasourcex-kotlin`**: Support for Kotlin Flow and Coroutines. |
| 21 | +* **`datasourcex-java-flow`**: Support for Java Flow (Flow API). |
| 22 | +* **`datasourcex-reactivestreams`**: Support for Reactive Streams (Reactor Flux/Mono, RxJava). |
| 23 | +* **`spring-boot-starter-datasource`**: A Spring Boot starter for easy integration, utilizing `@MessageMapping` for real-time endpoints. |
| 24 | +* **`datasourcex-util`**: Utility classes. |
| 25 | +* **`examples`**: Example applications (Spring Java/Kotlin, Chat app). |
| 26 | + |
| 27 | +## Building and Running |
| 28 | + |
| 29 | +### Prerequisites |
| 30 | +* JDK 17+ |
| 31 | +* `CAPLIN_USERNAME` and `CAPLIN_PASSWORD` environment variables are required to resolve dependencies from the Caplin repository. |
| 32 | + |
| 33 | +### Gradle Commands |
| 34 | + |
| 35 | +* **Build:** |
| 36 | + ```bash |
| 37 | + ./gradlew build |
| 38 | + ``` |
| 39 | +* **Test:** |
| 40 | + ```bash |
| 41 | + ./gradlew test |
| 42 | + ``` |
| 43 | +* **Format Code (Apply):** |
| 44 | + ```bash |
| 45 | + ./gradlew spotlessApply |
| 46 | + ``` |
| 47 | +* **Check Code Formatting:** |
| 48 | + ```bash |
| 49 | + ./gradlew spotlessCheck |
| 50 | + ``` |
| 51 | +* **Run Example (Spring Boot):** |
| 52 | + ```bash |
| 53 | + ./gradlew :examples:spring-kotlin:bootRun |
| 54 | + ``` |
| 55 | + |
| 56 | +## Development Conventions |
| 57 | + |
| 58 | +* **Code Style:** The project uses `spotless` with `ktfmt` for code formatting. Always run `./gradlew spotlessApply` before committing. |
| 59 | +* **Testing:** |
| 60 | + * Use **Kotest** for assertions (`shouldBe`, etc.). |
| 61 | + * Use **Turbine** for testing Kotlin Flows. |
| 62 | + * Use **MockK** for mocking dependencies. |
| 63 | + * Tests are typically JUnit 5 based. |
| 64 | +* **Documentation:** KDoc is used for API documentation. The `docs` module and `spring/docs/GUIDE.md` contain usage guides. |
| 65 | + |
| 66 | +## Common Tasks |
| 67 | + |
| 68 | +### Adding a new Reactive Endpoint (Spring) |
| 69 | +1. Create a `@Controller`. |
| 70 | +2. Annotate a function with `@MessageMapping("/subject")`. |
| 71 | +3. Return a `Flow<T>` (Kotlin) or `Flux<T>` (Java). |
| 72 | + |
| 73 | +### Testing a Flow |
| 74 | +Use `turbine` to verify the emission of items: |
| 75 | +```kotlin |
| 76 | +myFlow.test { |
| 77 | + awaitItem() shouldBe expectedItem |
| 78 | + awaitComplete() |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +## Key Files & Directories |
| 83 | + |
| 84 | +* `spring/docs/GUIDE.md`: Comprehensive guide on using the Spring Boot starter. |
| 85 | +* `buildSrc/src/main/kotlin/common-library.gradle.kts`: Shared build logic for libraries. |
| 86 | +* `gradle/libs.versions.toml`: Version catalog for dependency management. |
0 commit comments