How coding-parrot/low-level-design works
This repository is a small multi-module low-level design workspace. Each top-level module is a separate Maven project with its own source tree, tests, and build output, so the architectures are intentionally isolated rather than forming one shared application.
1. Repo-level structure
The codebase is organized around four independent system-design exercises: distributed cache, distributed event bus, rate limiter, and service orchestrator. There is no shared runtime between them; the common pattern is a thin public API plus internal model classes, algorithms, and test scaffolding.
2. Distributed Cache module
The cache module centers on Cache and CacheBuilder. CacheBuilder is the construction/binding layer for configuring policies, while Cache is the operational core that serves reads and writes. Supporting types under models define cache behavior such as eviction strategy, fetch strategy, record state, access metadata, and time abstraction.
3. Cache data flow
The cache likely sits in front of a DataSource: read requests check the cache first, miss paths delegate to the data source, and writes update both the stored record and cache metadata. The events package (Load, Write, Update, Eviction) suggests the cache emits lifecycle events around these state changes, which makes it easy to reason about observability or policy hooks in the design.
4. Cache policy boundaries
The presence of EvictionAlgorithm and FetchAlgorithm indicates the cache separates “what to do” from “how to do it.” That boundary is important for architecture diagrams: Cache orchestrates the flow, while strategy-like models decide eviction and fetch behavior. Timer plus SettableTimer in tests indicate time-based eviction or TTL logic is part of the design and is testable by injecting time.
5. Distributed Event Bus module
The event bus module exposes EventBus as the primary entry point. Internally it uses Subscription and event models to manage publish/subscribe behavior, with EventType and FailureEvent representing the payload and failure path. This is a message-dispatch subsystem rather than a queue or broker implementation.
6. Event bus delivery model
KeyedExecutor is the key architectural clue: events are likely routed through per-key execution lanes so related events preserve ordering while unrelated keys can process in parallel. The RetryLimitExceededException and UnsubscribedPollException classes show the bus has explicit delivery-state and retry semantics, so subscribers and polling are first-class lifecycle concerns.
7. Event bus timing and configuration
The util.Timer abstraction and application.properties file indicate the bus has time-sensitive behavior and at least some configurable runtime settings. For a diagram, the main boundary is: producers publish to EventBus, subscribers register through Subscription, and failures/timeouts are handled through the retry and timer subsystems.
8. Rate Limiter module
The rate limiter is centered on TimerWheel, Request, and RateLimitExceededException. The module is built around admission control: a request enters, the limiter decides whether it is allowed, and a rejection is surfaced via the exception path. The Timer utility and TestTimer show that time is abstracted for deterministic testing.
9. Rate limiting data flow
TimerWheel suggests a time-bucketed or expiry-wheel implementation for tracking request windows efficiently. In architectural terms, requests are associated with timestamps or slots, the wheel advances with time, and expired counts are removed to enforce the configured limit. This makes the limiter stateful, time-driven, and optimized around fast updates rather than external storage.
10. Service Orchestrator module
The service orchestrator models request routing across service instances. LoadBalancer is the entry point, Router defines the routing contract, and the algorithms package contains WeightedRoundRobin and ConsistentHashing as alternative placement strategies. The models package defines the domain objects: Service, Node, and Request.
11. Orchestration and routing boundaries
This module cleanly separates topology from policy. Service and Node describe the available backend pool, while Router and the algorithm classes decide where a request should go. WeightedRoundRobin favors capacity-aware distribution, and ConsistentHashing favors stable key-to-node mapping, so the diagram should show a pluggable routing layer under the load balancer.
12. Cross-cutting implementation style
Across all four modules, the design style is consistent: a single public facade, small domain models, strategy/policy objects, and test-focused time abstractions. There is little evidence of external infrastructure or network dependencies; the repo is primarily an in-memory LLD reference set meant to demonstrate system behavior, lifecycle boundaries, and algorithm choice rather than production deployment topology.
Main entry points: EventBus.java EventBus · Cache.java Cache · TimerWheel.java TimerWheel · LoadBalancer.java LoadBalancer
Components 18
Distributed Cache
Independent cache module with configurable policies and lifecycle events.
- CacheBuilder · Configures cache policies and wires runtime dependencies.
distributed-cache/src/main/java/CacheBuilder.java - Cache · Operational cache that serves reads, writes, and eviction.
distributed-cache/src/main/java/Cache.java - Policies · Eviction, fetch, record state, access metadata, and time abstraction.
distributed-cache/src/main/java/models - Cache Events · Load, write, update, and eviction event flow around cache state changes.
distributed-cache/src/main/java/events - DataSource · Upstream source consulted on cache misses.
distributed-cache/src/main/java/DataSource.java
Event Bus
Independent publish/subscribe dispatch module with ordered execution and retry handling.
- EventBus · Primary publish/subscribe entry point.
distributed-event-bus/src/main/java/EventBus.java - Subscription · Tracks subscriber registration and delivery state.
distributed-event-bus/src/main/java/models/Subscription.java - KeyedExecutor · Routes events through per-key execution lanes to preserve ordering.
distributed-event-bus/src/main/java/lib/KeyedExecutor.java - Event Models · Event payloads, event types, and failure events.
distributed-event-bus/src/main/java/models - Delivery Errors · Retry-limit and unsubscribe failure paths.
distributed-event-bus/src/main/java/exceptions
Rate Limiter
Independent admission-control module driven by time windows.
- TimerWheel · Time-bucketed request tracking for limit enforcement.
rate-limiter/src/main/java/TimerWheel.java - Request · Incoming request subject to rate checks.
rate-limiter/src/main/java/models/Request.java - Timer · Abstracted clock for deterministic tests and window progression.
rate-limiter/src/main/java/utils/Timer.java - Limit Error · Raised when the configured limit is exceeded.
rate-limiter/src/main/java/exceptions/RateLimitExceededException.java
Service Orchestrator
Independent routing module with pluggable placement algorithms.
- LoadBalancer · Entry point for service routing decisions.
service-orchestrator/src/main/java/LoadBalancer.java - Router · Defines the routing interface used by the balancer.
service-orchestrator/src/main/java/algorithms/Router.java - Placement Algo · Weighted round robin and consistent hashing strategies.
service-orchestrator/src/main/java/algorithms - Topology · Service, node, and request domain objects used for routing.
service-orchestrator/src/main/java/models
Connections 18
- CacheBuilder → Cache: builds · Builder configures and constructs the cache runtime.
- Cache → Policies: uses · Cache depends on policies, records, and timer abstractions.
- Cache → DataSource: misses · Cache consults the upstream source on miss paths.
- Cache → Cache Events: emits · Cache publishes lifecycle events around load, write, update, and eviction.
- Policies → Cache Events: drives · Policy and record state determine lifecycle transitions.
- EventBus → Subscription: manages · Event bus registers and tracks subscriptions.
- EventBus → KeyedExecutor: dispatches · Published events are routed through keyed execution lanes.
- EventBus → Event Models: publishes · Bus carries event payloads and failure events.
- EventBus → Delivery Errors: signals · Delivery and polling failures surface through explicit exceptions.
- KeyedExecutor → Event Models: orders · Execution lanes preserve ordering for related events.
- Subscription → Delivery Errors: guards · Subscription state determines unsubscribe and retry failures.
- TimerWheel → Request: tracks · Requests are recorded into time windows or slots.
- TimerWheel → Timer: advances · Window expiry depends on the abstract clock.
- TimerWheel → Limit Error: rejects · Excess traffic is surfaced as a limit exception.
- LoadBalancer → Router: delegates · Load balancer delegates routing decisions to the router contract.
- Router → Placement Algo: implements · Routing contract is realized by placement strategies.
- LoadBalancer → Topology: routes · Balancer uses service, node, and request topology.
- Placement Algo → Topology: uses · Algorithms evaluate service topology and request keys.