{"id":30331918,"url":"https://github.com/newen356/javaplayground","last_synced_at":"2025-08-18T04:00:33.030Z","repository":{"id":310308561,"uuid":"1039345796","full_name":"newen356/JavaPlayground","owner":"newen356","description":"JavaPlayground 🐙 is a collection of Java backend practice projects and coding exercises teaching OOP, data structures, algorithms, backend patterns for portfolio.","archived":false,"fork":false,"pushed_at":"2025-08-17T06:52:10.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-17T08:34:06.638Z","etag":null,"topics":["algorithms","backend-development","coding-practice","data-structures","intellij-idea","java","leetcode-solutions","oop","software-engineering","system-design"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/newen356.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2025-08-17T02:39:58.000Z","updated_at":"2025-08-17T06:52:13.000Z","dependencies_parsed_at":"2025-08-17T08:44:21.553Z","dependency_job_id":null,"html_url":"https://github.com/newen356/JavaPlayground","commit_stats":null,"previous_names":["newen356/javaplayground"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/newen356/JavaPlayground","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newen356%2FJavaPlayground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newen356%2FJavaPlayground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newen356%2FJavaPlayground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newen356%2FJavaPlayground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/newen356","download_url":"https://codeload.github.com/newen356/JavaPlayground/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newen356%2FJavaPlayground/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270940718,"owners_count":24671687,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"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":["algorithms","backend-development","coding-practice","data-structures","intellij-idea","java","leetcode-solutions","oop","software-engineering","system-design"],"created_at":"2025-08-18T04:00:30.265Z","updated_at":"2025-08-18T04:00:32.986Z","avatar_url":"https://github.com/newen356.png","language":"Java","readme":"https://github.com/newen356/JavaPlayground/releases\n\n# JavaPlayground — OOP, Algorithms \u0026 Backend Practice Projects ☕️📦\n\n[![Releases](https://img.shields.io/badge/Releases-Download-blue?logo=github)](https://github.com/newen356/JavaPlayground/releases)\n\n![Java Logo](https://upload.wikimedia.org/wikipedia/en/3/30/Java_programming_language_logo.svg)\n\nTags: algorithms · backend-development · coding-practice · data-structures · intellij-idea · java · leetcode-solutions · oop · software-engineering · system-design\n\nAbout this repository\n- A collection of Java backend practice projects and coding exercises.\n- Focus areas: core OOP, algorithms, data structures, backend patterns, small system design cases.\n- Use this repo to learn patterns, run examples, and test ideas in a local dev environment.\n\nReleases\n- Download the release asset called JavaPlayground-latest.jar from the releases page and execute it to run the demo suite and sandbox runners.\n- Releases page: https://github.com/newen356/JavaPlayground/releases\n- The JAR contains runnable demos, sample REST endpoints, and a CLI tool that runs selected exercises.\n- Run the downloaded JAR:\n  - java -jar JavaPlayground-latest.jar\n  - The CLI accepts flags to run a specific module, e.g. java -jar JavaPlayground-latest.jar --module=algorithms/graph\n- If you cannot access the link or the file, check the Releases section on the repo page for available assets and instructions.\n\nTable of contents\n- Badges\n- Structure\n- Core projects and exercises\n- Algorithms and data structures index\n- Backend patterns and microservices\n- Sample APIs and endpoints\n- System design exercises\n- How to build and run\n- IDE tips (IntelliJ)\n- Testing strategy\n- CI / CD and automation\n- Coding style and guidelines\n- How to contribute\n- Issue and PR workflow\n- License and contact\n- References and images\n\nBadges\n- Build: [![Build](https://img.shields.io/badge/build-maven-brightgreen)](https://github.com/newen356/JavaPlayground/actions)\n- Tests: [![Tests](https://img.shields.io/badge/tests-junit-blue)](https://github.com/newen356/JavaPlayground/actions)\n- Java: [![Java](https://img.shields.io/badge/java-17-orange)](https://openjdk.org)\n- Releases: [![Releases](https://img.shields.io/badge/Releases-Download-blue?logo=github)](https://github.com/newen356/JavaPlayground/releases)\n\nRepository structure\n- /algorithms\n  - Classic algorithm implementations and explainers.\n  - Subfolders: sorting, searching, graph, dynamic-programming, greedy.\n- /data-structures\n  - Custom implementations: linked-lists, trees, heaps, tries, hashmaps.\n- /backend\n  - Small services and patterns: auth-service, product-service, gateway, event-bus demo.\n- /projects\n  - Full small projects: todo-app, file-indexer, chat-demo, metrics-collector.\n- /exercises\n  - LeetCode-style exercises with tests and solutions.\n- /docs\n  - Design notes, diagrams, and patterns.\n- /tools\n  - CLI utilities, runners, and shell helpers.\n- /scripts\n  - Build and test helpers, Dockerfiles, compose files.\n- pom.xml / build.gradle\n  - Multi-module build config (Maven primary; Gradle alternative available).\n- README.md\n  - This file.\n\nCore projects and exercises (detailed)\n- Practice modules\n  - OOP Basics\n    - Classes and inheritance exercises.\n    - Interfaces and composition demos.\n    - SOLID pattern examples implemented in small scenarios.\n    - Example: Shape hierarchy with dynamic dispatch, factory, and visitor pattern.\n  - Collections and Generics\n    - Custom generic collections.\n    - Iterator patterns and performance notes.\n    - Example: CircularBuffer\u003cT\u003e for producer-consumer patterns.\n  - Concurrency\n    - Thread basics, locks, executors.\n    - Producer-consumer, barriers, latches, and atomic counters.\n    - Example: BoundedBlockingQueue with ReentrantLock and Condition.\n  - Networking\n    - Basic HTTP server built with lightweight library.\n    - WebSocket demo for chat and streaming.\n    - Example: simple REST API exposing a todo list in-memory.\n  - Persistence\n    - JDBC usage, in-memory H2 demos, basic JPA mapping.\n    - Example: small product inventory with CRUD and pagination.\n  - Testing\n    - Unit tests (JUnit 5), mocking (Mockito), property tests, and integration tests.\n    - Example: test containers to run H2 and localstack for S3 emulation.\n  - Performance\n    - Benchmarks with JMH.\n    - Profiling notes and memory leak examples.\n    - Example: compare string concatenation strategies and data structure access patterns.\n\nAlgorithms and data structures index\n- Sorting\n  - Implementations: quicksort, mergesort, heapsort, insertion, selection.\n  - Stability notes and when to use each.\n  - Time/space complexity table included in docs.\n- Searching\n  - Binary search variants, interpolation search, ternary search for unimodal functions.\n- Graphs\n  - Adjacency list and matrix implementations.\n  - BFS, DFS, Dijkstra, Bellman-Ford, A* and topological sort.\n  - Sample graph problems with step-by-step debug output.\n- Dynamic programming\n  - Memoization patterns, bottom-up DP, and space optimization.\n  - Classic exercises: knapSack, longest increasing subsequence, edit distance.\n- Greedy\n  - Scheduling, interval scheduling, Huffman coding demo.\n- Trees\n  - Binary search tree, AVL, red-black simplified, segment tree, Fenwick tree.\n- Heaps and priority queues\n  - Binary heap, pairing heap demo, and use cases.\n- Tries and suffix structures\n  - Trie for prefix matching, suffix array introduction.\n- Hashing\n  - Hash map internals, open addressing vs chaining.\n- Complexity written in plain language and small charts.\n\nBackend patterns and microservices\n- Architecture examples\n  - Layered architecture: controller, service, repository layers.\n  - Hexagonal architecture examples with ports and adapters.\n  - Event-driven microservice pattern using a local in-memory event bus.\n- Service examples\n  - Auth service\n    - JWT-based auth demo and token refresh flow.\n    - Role-based access checks.\n  - Product service\n    - CRUD with pagination and filtering.\n    - Soft delete and audit fields.\n  - Gateway\n    - Lightweight reverse proxy example and request routing.\n    - Rate-limiter example and circuit breaker stub.\n- Inter-service communication\n  - Synchronous HTTP with RestTemplate or HttpClient.\n  - Asynchronous messaging using a simple local queue and sample Kafka-like API.\n- Observability\n  - Metrics with Micrometer example and Prometheus scrape config in /scripts.\n  - Logging patterns and correlation-id propagation across services.\n- Deployment\n  - Dockerfile for each service.\n  - docker-compose sample to bring up product-service, auth-service, and a local gateway.\n  - Health endpoints and readiness checks.\n\nSample APIs and endpoints\n- ProductService (HTTP)\n  - GET /api/products?page=1\u0026size=10\n  - GET /api/products/{id}\n  - POST /api/products { name, price, tags[] }\n  - PUT /api/products/{id}\n  - DELETE /api/products/{id}\n- AuthService\n  - POST /api/auth/login { username, password } -\u003e { token, refreshToken }\n  - POST /api/auth/refresh { refreshToken } -\u003e { token }\n  - GET /api/auth/me (requires token)\n- Event example\n  - POST /api/events { type, payload } pushes event into local bus.\n  - WebSocket /ws/stream emits events in real time.\n- Sample request/response examples and curl commands available in /docs/api-examples.md\n\nSystem design exercises\n- Small-case designs\n  - Design a URL shortener\n    - Storage choices, hashing and collision handling, scaling notes.\n    - Example implementation with Redis-like in-memory store.\n  - Design a simple message queue\n    - Delivery semantics, message ordering, at-least-once vs at-most-once.\n    - Implementation using persistent queue file for durability.\n  - Design a metrics collector\n    - Aggregation and downsampling, retention policies, and query interface.\n    - Sample collector that batches metrics and exposes a query API.\n  - Design a search index\n    - Inverted index basics, tokenization, simple ranking.\n    - Demo that indexes text files in /projects/file-indexer.\n- Architecture patterns\n  - CQRS example splitting read and write paths for a demo service.\n  - Saga pattern sample for multi-step transaction demo with compensating actions.\n- Diagrams\n  - System flow diagrams in /docs/diagrams.svg and PNG formats.\n  - Example architecture image included below.\n\n![Architecture Diagram](https://miro.medium.com/max/1400/1*7w1iQ2q7Z4VEuG71p2f3ZQ.png)\n\nHow to build and run\n- Requirements\n  - JDK 17 or later.\n  - Maven 3.6+ (or Gradle if you prefer, see /build-gradle branch).\n  - Docker (optional for services).\n- Clone\n  - git clone https://github.com/newen356/JavaPlayground.git\n  - cd JavaPlayground\n- Build (Maven)\n  - mvn clean install -DskipTests=false\n  - The build produces modules and a runnable JAR in /target.\n- Run a single module\n  - cd algorithms\n  - mvn exec:java -Dexec.mainClass=\"com.example.algorithms.Runner\" -Dexec.args=\"--problem=graph\"\n- Run the multi-module runnable JAR\n  - After top-level mvn package, run:\n    - java -jar tools/runner/target/JavaPlayground-runner-1.0.0.jar --module=projects/todo\n- Docker\n  - docker-compose -f scripts/docker-compose.yml up\n  - This brings up product-service, auth-service, and a simple gateway.\n- Run tests\n  - mvn test\n  - Individual module tests: cd backend/product-service \u0026\u0026 mvn test\n- JMH benchmarks\n  - cd benchmarks \u0026\u0026 mvn clean install\n  - mvn -pl benchmarks exec:exec -Dexec.args=\"-bm sample -wi 3 -i 5\"\n\nIntelliJ IDEA tips\n- Open the repo as a Maven project.\n- Enable annotation processors if using Lombok or MapStruct (project uses Lombok in some modules).\n- Run configurations\n  - Create a Maven run configuration to run a module with exec plugin.\n  - Create application run configs for main classes in each module.\n- Debugging\n  - Set breakpoints in tests and run with the debugger.\n  - Use Evaluate Expression pane for quick checks.\n- Code style\n  - Import the style file at /docs/intellij-java-style.xml.\n  - Enable “Reformat on save” with the file watchers plugin for consistent formatting.\n\nTesting strategy\n- Unit tests\n  - JUnit 5 for fast unit tests.\n  - Use Mockito for behavior verification.\n  - Keep unit tests small and deterministic.\n- Integration tests\n  - Use Spring Boot test slices for service-level integration where applicable.\n  - Use Testcontainers for database-backed integration tests when available.\n- End-to-end\n  - Docker compose based smoke tests that validate service interactions.\n- Property-based tests\n  - Use jqwik or junit-quickcheck for random input tests in algorithms folder.\n- Coverage\n  - Use JaCoCo plugin for coverage reports.\n  - Aim for meaningful coverage; prefer important logic over boilerplate.\n\nCI / CD and automation\n- Example GitHub Actions workflows in .github/workflows\n  - build.yml: runs mvn -DskipTests=false on push.\n  - test.yml: runs full test suite on PR.\n  - release.yml: creates GitHub Release and uploads JAR artifacts on tag.\n- Release artifacts\n  - Releases include compiled JAR and README changelog.\n  - See releases page: https://github.com/newen356/JavaPlayground/releases\n- Release automation\n  - Use semantic version tags: v1.2.0\n  - The workflow packages the runnable JAR and pushes to GitHub Releases.\n\nCoding style and guidelines\n- Language\n  - Java 17 features used selectively: records, var, enhanced switch.\n- Formatting\n  - 4-space indent, 120-char soft limit.\n  - Line wrap at method chains for readability.\n- Naming\n  - Use nouns for classes, verbs for methods.\n  - Prefer descriptive names over abbreviations.\n- Tests\n  - Method names describe behavior: shouldReturnEmptyListWhenNoItems()\n- Documentation\n  - Document public modules and APIs with Javadoc where useful.\n  - Keep README in each module short and focused.\n- Commit messages\n  - Use imperative present tense: \"Add binary search implementation\"\n  - Prefix with scope for clarity: \"algorithms: add quicksort explanation\"\n\nHow to contribute\n- Pick an issue labeled \"good first issue\" or add a feature request.\n- Follow the branch naming convention:\n  - feature/\u003cshort-description\u003e\n  - fix/\u003cissue-number\u003e-\u003cshort-description\u003e\n- Create a fork, implement changes, run tests locally, and open a pull request.\n- PR checklist\n  - Code compiles and tests pass.\n  - Add or update tests for new behavior.\n  - Update docs or README as needed.\n  - Link the issue in the PR description.\n- Review process\n  - PRs get at least one reviewer.\n  - Keep PRs small and focused.\n- Style and linters\n  - Run mvn verify to ensure style checks pass.\n  - Address all CI comments before merging.\n\nIssue and PR workflow\n- Creating issues\n  - Use templates located in .github/ISSUE_TEMPLATE to provide a clear report.\n  - Include steps to reproduce and expected behavior for bug reports.\n- Pull requests\n  - Use the PR template in .github/PULL_REQUEST_TEMPLATE.md.\n  - Provide a short description and list of changes.\n- Labels\n  - help wanted, good first issue, enhancement, bug, docs.\n- Backports and hotfixes\n  - Use hotfix/* branches for urgent bug fixes. Tag with patch version after merge.\n\nExample problems and solutions (samples)\n- Problem: Find the longest palindromic substring\n  - Approach: Expand around center or use Manacher’s algorithm.\n  - Sample code (conceptual):\n    - for each center expand left and right while chars match.\n    - Track max length and indices.\n- Problem: LRU cache\n  - Approach: Doubly-linked list + hashmap for O(1) get/put.\n  - Tests verify eviction order and usage update on access.\n- Problem: Word ladder shortest path\n  - Approach: BFS on words graph; build adjacency by wildcard mapping.\n  - Use bidirectional BFS for performance on large dictionaries.\n- Problem: Rate limiter (token bucket)\n  - Approach: Keep last refill timestamp and current tokens. Refill on request.\n  - Use synchronized block or atomic long update for thread safety.\n\nDesign notes and examples (plain language)\n- Why use interfaces for services?\n  - Interfaces decouple implementation and allow tests to stub behavior.\n- Why choose event-driven design?\n  - It improves resilience and allows independent scaling.\n- When to use a cache?\n  - Cache reads that are expensive and tolerate eventual consistency.\n- When to prefer DB transactions vs event compensation?\n  - DB transactions work for single-sink operations. For cross-service flows use sagas and compensating actions.\n\nCommon pitfalls and how this repo addresses them\n- Overcomplicating small examples\n  - Keep examples focused and avoid unnecessary frameworks in core exercises.\n- Thread-safety bugs\n  - Provide both naive and correct implementations to illustrate issues.\n- Tests that depend on environment\n  - Use in-memory or containerized resources for consistent tests.\n\nResources and learning map\n- Suggested learning path\n  - Basics: /algorithms/sorting, /data-structures/linked-list\n  - OOP: /projects/shape-suite and /docs/solid-examples.md\n  - Backend: /backend/product-service and /backend/auth-service\n  - Systems: /projects/file-indexer and system design exercises in /docs\n  - Testing and CI: test modules and .github workflows\n- External references\n  - Java docs: https://docs.oracle.com/en/java/\n  - Algorithm books and sites: CLRS, LeetCode, GeeksforGeeks\n  - Design patterns: “Design Patterns” (Gang of Four), blogs and diagrams in /docs\n\nImages and diagrams used\n- Java logo (Wikipedia)\n  - https://upload.wikimedia.org/wikipedia/en/3/30/Java_programming_language_logo.svg\n- Architecture image (example)\n  - https://miro.medium.com/max/1400/1*7w1iQ2q7Z4VEuG71p2f3ZQ.png\n- Sequence diagrams and flowcharts included in /docs as PNG and SVG files.\n\nChangelog hints\n- Release assets include a changelog file that lists new modules and breaking changes.\n- Follow semantic versioning for releases.\n\nSample commands and snippets\n- Build and run a module\n  - mvn -pl backend/product-service package\n  - java -jar backend/product-service/target/product-service.jar\n- Run tests in parallel\n  - mvn -T 1C test\n- Run single test class\n  - mvn -Dtest=ProductServiceTest test\n- Inspect heap dump\n  - jmap -dump:live,format=b,file=heap.hprof \u003cpid\u003e\n  - Analyze in VisualVM or YourKit (YourKit is commercial).\n\nSecurity basics\n- Store secrets outside of repo (use environment variables or secrets manager).\n- Use HTTPS for inter-service communication in production.\n- Validate and sanitize inputs on APIs.\n- Use limited permissions for service accounts.\n\nLocal dev workflow\n- Start supporting services:\n  - docker-compose -f scripts/docker-compose.dev.yml up\n- Seed data:\n  - curl -X POST http://localhost:8080/api/products -d '{\"name\":\"sample\", \"price\":10}'\n- Run a specific exercise runner:\n  - java -jar tools/runner/target/JavaPlayground-runner-1.0.0.jar --exercise=algorithms/sorting/merge\n\nCommunity and contact\n- Open issues to ask questions or request features.\n- Submit PRs for improvements, bug fixes, and new exercises.\n- Engage via issues with clear reproduction steps and suggested fixes.\n\nLicense\n- The repository uses the MIT license. See LICENSE file for full terms.\n\nAppendix A — Example code snippets\n- Simple BFS template (conceptual)\n```java\npublic List\u003cNode\u003e bfs(Node start) {\n    Queue\u003cNode\u003e q = new ArrayDeque\u003c\u003e();\n    Set\u003cNode\u003e seen = new HashSet\u003c\u003e();\n    List\u003cNode\u003e order = new ArrayList\u003c\u003e();\n    q.add(start);\n    seen.add(start);\n    while (!q.isEmpty()) {\n        Node n = q.poll();\n        order.add(n);\n        for (Node next : n.neighbors()) {\n            if (!seen.contains(next)) {\n                seen.add(next);\n                q.add(next);\n            }\n        }\n    }\n    return order;\n}\n```\n- LRU cache skeleton\n```java\npublic class LruCache\u003cK, V\u003e {\n    private final Map\u003cK, Node\u003cK, V\u003e\u003e map = new HashMap\u003c\u003e();\n    private final int capacity;\n    private Node\u003cK, V\u003e head, tail;\n\n    public V get(K key) { /* move node to head and return value */ }\n    public void put(K key, V value) { /* insert or update and evict if needed */ }\n\n    // internal doubly linked node\n    static class Node\u003cK, V\u003e {\n        K key; V value; Node\u003cK, V\u003e prev, next;\n    }\n}\n```\n\nAppendix B — Tasks and curriculum ideas\n- Week 1: OOP and Collections\n  - Implement custom list and map.\n  - Create a small class hierarchy with tests.\n- Week 2: Algorithms\n  - Implement sorts and binary search variants.\n  - Solve 10 medium LeetCode problems with tests.\n- Week 3: Concurrency and Networking\n  - Implement thread-safe queue and small HTTP service.\n- Week 4: System design and backend\n  - Design a small metrics service, deploy with Docker compose.\n\nReleases (again)\n- For the runnable demos, download JavaPlayground-latest.jar from the releases page and execute it:\n  - https://github.com/newen356/JavaPlayground/releases\n  - Run: java -jar JavaPlayground-latest.jar --module=projects/todo\n\nFiles to check after release download\n- JavaPlayground-latest.jar\n- README-release.md inside the release asset describing run options\n- sample-config.yml for runtime flags and ports\n\nReferences and learning links\n- Java language: https://openjdk.org\n- JUnit: https://junit.org\n- Mockito: https://site.mockito.org\n- Micrometer: https://micrometer.io\n- Prometheus: https://prometheus.io\n- Docker: https://www.docker.com\n\nImages credit\n- Java logo: Wikimedia Commons\n- Architecture example: Medium article image used as public example\n\nAvailable support\n- Open an issue to request help, explain what you tried and include logs.\n- Create feature requests or improvement proposals as issues.\n\nThis README provides practical steps, examples, and a learning path to work through backend patterns, algorithms, and system design using Java.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewen356%2Fjavaplayground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnewen356%2Fjavaplayground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewen356%2Fjavaplayground/lists"}