{"id":19672735,"url":"https://github.com/halilozel1903/kotlinleapyear","last_synced_at":"2026-06-14T15:33:51.475Z","repository":{"id":188047370,"uuid":"616152263","full_name":"halilozel1903/KotlinLeapYear","owner":"halilozel1903","description":"Code in Kotlin Programming Language that determines whether a given year is a leap year or not.  ⚠️ 💥 ✅","archived":false,"fork":false,"pushed_at":"2025-11-11T07:28:27.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-21T15:03:47.830Z","etag":null,"topics":["kotlin","kotlin-android","kotlin-basic","kotlin-beginner","kotlin-calculator","kotlin-code","kotlin-codelab","kotlin-example","kotlin-examples","kotlin-language","kotlin-leap-year","kotlin-learning","kotlin-programming-language","kotlin-tutorial","leapyear","leapyear-calculator"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/halilozel1903.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-03-19T18:55:57.000Z","updated_at":"2025-11-11T07:26:22.000Z","dependencies_parsed_at":"2024-03-10T12:53:32.673Z","dependency_job_id":null,"html_url":"https://github.com/halilozel1903/KotlinLeapYear","commit_stats":null,"previous_names":["halilozel1903/kotlinleapyear"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/halilozel1903/KotlinLeapYear","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FKotlinLeapYear","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FKotlinLeapYear/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FKotlinLeapYear/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FKotlinLeapYear/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halilozel1903","download_url":"https://codeload.github.com/halilozel1903/KotlinLeapYear/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FKotlinLeapYear/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34326236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-14T02:00:07.365Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kotlin","kotlin-android","kotlin-basic","kotlin-beginner","kotlin-calculator","kotlin-code","kotlin-codelab","kotlin-example","kotlin-examples","kotlin-language","kotlin-leap-year","kotlin-learning","kotlin-programming-language","kotlin-tutorial","leapyear","leapyear-calculator"],"created_at":"2024-11-11T17:13:10.319Z","updated_at":"2026-06-14T15:33:51.458Z","avatar_url":"https://github.com/halilozel1903.png","language":"Kotlin","funding_links":["https://www.buymeacoffee.com/halilozel1903"],"categories":[],"sub_categories":[],"readme":"# Kotlin Leap Year 📆 💀 👀\n\n![Kotlin Leap Year](https://whizpool.com/wp-content/uploads/2022/10/kotlin1.jpg)\n\nA **Leap Year** is a year that is evenly divisible by 4, except for years that are divisible by 100 but not by 400. This means that the year 2000 was a leap year, but 1900 was not.\n\nThis project demonstrates **Clean Architecture** principles in Kotlin, showcasing how to structure a simple application with proper separation of concerns.\n\n## 🏗️ Clean Architecture\n\nThis project follows Clean Architecture principles with clear separation of layers:\n\n### Architecture Layers\n\n```\n┌─────────────────────────────────────────────┐\n│         Presentation Layer                  │\n│  ┌──────────┐  ┌───────────┐  ┌─────────┐ │\n│  │   View   │  │ ViewModel │  │ UIState │ │\n│  └──────────┘  └───────────┘  └─────────┘ │\n└─────────────────────────────────────────────┘\n                    ↓\n┌─────────────────────────────────────────────┐\n│            Domain Layer                     │\n│  ┌──────────┐  ┌──────────┐  ┌──────────┐ │\n│  │ Use Case │  │ Entity   │  │Repository│ │\n│  │          │  │ (Model)  │  │Interface │ │\n│  └──────────┘  └──────────┘  └──────────┘ │\n└─────────────────────────────────────────────┘\n                    ↓\n┌─────────────────────────────────────────────┐\n│             Data Layer                      │\n│  ┌──────────────┐  ┌──────────────────────┐│\n│  │ Repository   │  │    Data Source       ││\n│  │Implementation│  │                      ││\n│  └──────────────┘  └──────────────────────┘│\n└─────────────────────────────────────────────┘\n```\n\n### Layer Responsibilities\n\n#### 📱 Presentation Layer (`presentation/`)\n- **View**: Renders UI and handles user interactions (console-based)\n- **ViewModel**: Manages presentation logic and transforms domain data to UI state\n- **UIState**: Represents possible UI states (Success, Error)\n\n#### 💼 Domain Layer (`domain/`)\n- **Use Cases**: Contains business logic (e.g., `IsLeapYearUseCase`)\n- **Entities/Models**: Core business models with validation (`Year`)\n- **Repository Interfaces**: Abstractions for data access\n\n#### 💾 Data Layer (`data/`)\n- **Repository Implementation**: Concrete implementation of domain repositories\n- **Data Sources**: Handle data retrieval (console input, API, database, etc.)\n\n#### 🔧 Dependency Injection (`di/`)\n- **DependencyContainer**: Manages object creation and dependency injection\n\n### Key Principles\n\n1. **Dependency Rule**: Dependencies point inward. Inner layers know nothing about outer layers.\n2. **Single Responsibility**: Each class has one reason to change.\n3. **Dependency Inversion**: High-level modules don't depend on low-level modules; both depend on abstractions.\n4. **Interface Segregation**: Use focused interfaces (`YearDataSource`, `YearRepository`).\n\n## 🚀 Usage\n\n### Running the Application\n\n```bash\n# Compile the project\nkotlinc -d out $(find src/main/kotlin -name \"*.kt\" -type f)\n\n# Run the application\nkotlin -classpath out com.example.leapyear.MainKt\n```\n\n### Example Interaction\n\n```kotlin\nEnter favorite year: 2024\n2024 is a leap year.\n```\n\n```kotlin\nEnter favorite year: 2023\n2023 is not a leap year.\n```\n\n### Input Validation\n\nThe application validates input and provides meaningful error messages:\n\n```kotlin\nEnter favorite year: abc\nError: Invalid input\n```\n\n```kotlin\nEnter favorite year: -5\nError: Year must be a positive number\n```\n\n## 📝 Code Example\n\nThe core leap year logic is encapsulated in the domain entity:\n\n```kotlin\nfun isLeapYear(year: Int?): Boolean {\n    return if (year != null) {\n        (year % 4 == 0) \u0026\u0026 (year % 100 != 0 || year % 400 == 0)\n    } else {\n        false\n    }\n}\n\nfun main() {\n    print(\"Enter favorite year: \")\n    val year = readlnOrNull()?.toInt()\n    if (isLeapYear(year)) {\n        println(\"$year is a leap year.\")\n    } else {\n        println(\"$year is not a leap year.\")\n    }\n}\n```\n\nIn this program, the `isLeapYear()` function takes a year as input and returns true if it is a leap year, and false otherwise. The function checks if the year is divisible by 4, and if it is, it checks if it is not divisible by 100 or if it is divisible by 400.\n\n## 🧪 Testing\n\nThe architecture makes testing easier by allowing each layer to be tested independently:\n\n- **Unit Tests**: Test use cases and domain logic in isolation\n- **Integration Tests**: Test repository implementations with mock data sources\n- **UI Tests**: Test view models with mock repositories\n\n## Donation 💸\n\nYou can support by buying a coffee. ☕️\n\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/halilozel1903)\n\n\n## License ℹ️\n```\nMIT License\n\nCopyright (c) 2024 Halil OZEL\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalilozel1903%2Fkotlinleapyear","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalilozel1903%2Fkotlinleapyear","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalilozel1903%2Fkotlinleapyear/lists"}