How priyanka-pitla277/ridewise works
1. Overall shape
RideWise is a single-process, console-driven Java application with an in-memory backend. There is no external database or web layer in this repo; the architecture is centered on a command-line Main entrypoint that orchestrates domain services.
2. Entry and interaction layer
com.airtribe.ridewise.Main is the user-facing shell. It exposes the CLI menu for:
registering riders/drivers, listing available drivers, requesting rides, completing rides, and viewing rides. This layer should be drawn as the top boundary that calls into services only.
3. Service layer as the business boundary
The core workflow lives in:
- RiderService
- DriverService
- RideService
These classes coordinate validation, entity creation, state transitions, and repository access. They are the main application boundary between the CLI and domain/persistence concerns.
4. Domain model
The primary entities are:
- Rider
- Driver
- Ride
- Location
- FareReceipt
These represent the ride-sharing domain state: users, vehicle/availability, trip lifecycle, coordinates, and fare output. Ride is the central aggregate tying rider, driver, locations, status, and pricing together.
5. Repositories are in-memory persistence
Persistence is abstracted via repository interfaces and implementations:
- DriverRepository / DriverRepositoryImpl
- RiderRepository / RiderRepositoryImpl
- LocationRegistry
This is not database-backed; state is likely held in memory using concurrent collections. LocationRegistry is a supporting repository-like component used to track or resolve location-related data for matching.
6. Strategy-based ride matching
Driver allocation is pluggable through RideMatchingStrategy with implementations:
- NearestDriverStrategy
- LeastActiveDriverStrategy
RideService depends on the strategy interface rather than a concrete algorithm, so matching behavior can be swapped without changing ride orchestration. This is the main variability point in the system.
7. Strategy-based fare calculation
Pricing is also pluggable through FareStrategy with implementations:
- DefaultFareStrategy
- PeakHourFareStrategy
Fare computation is separated from ride lifecycle logic, allowing standard pricing and surge/peak pricing to be selected independently. FareReceipt is likely the output artifact of this pricing path.
8. Ride lifecycle flow
The main business flow is:
1. register rider / driver
2. request ride
3. choose driver via matching strategy
4. compute fare via fare strategy
5. create/update Ride
6. mark ride completed and release driver availability
RideStatus captures lifecycle state transitions, and NoDriverAvailableException handles the failure path when matching cannot find a driver.
9. Shared domain rules and configuration
Supporting pieces include:
- VehicleType and RideStatus enums for constrained domain values
- Constants for shared configuration
- IdGenerator for unique identifiers
The readme emphasizes thread safety; the architecture likely relies on atomic ID generation and concurrent maps to keep the in-memory state safe under concurrent access.
10. Testing and documentation boundary
Tests are manual, not a full automated suite:
- repository manual test for DriverRepositoryImpl
- service manual tests for rider, driver, and ride services
The docs/ folder contains class model, object relationships, requirements, and SOLID reflection, which are useful for diagramming the object graph and service/repository responsibilities.
11. What to show in an architecture diagram
A clear diagram should show:
- Main at the top
- services in the middle
- repositories and strategy interfaces below
- domain models as shared objects between them
The most important dependency arrows are: Main -> Services, RideService -> Strategy interfaces, Services -> Repositories, and Repositories <-> Domain models. The system is intentionally layered and interface-driven, with in-memory state at the bottom.
Main entry points: RideService.java Ride Service · Ride.java Ride · RiderService.java Rider Service · DriverService.java Driver Service
Components 25
Entry
Console entrypoint and user interaction
- Main · Console menu and application bootstrap
src/com/airtribe/ridewise/Main.java
Services
Application orchestration and business workflows
- Rider Service · Registers and manages riders
src/com/airtribe/ridewise/service/RiderService.java - Driver Service · Registers and manages drivers
src/com/airtribe/ridewise/service/DriverService.java - Ride Service · Coordinates ride requests, matching, pricing, and lifecycle
src/com/airtribe/ridewise/service/RideService.java
Domain
Core ride-sharing entities and enums
- Ride · Trip lifecycle, assignments, and status
src/com/airtribe/ridewise/model/Ride.java - Driver · Driver availability and profile
src/com/airtribe/ridewise/model/Driver.java - Rider · Rider profile
src/com/airtribe/ridewise/model/Rider.java - Location · Coordinates and trip endpoints
src/com/airtribe/ridewise/model/Location.java - Fare Receipt · Computed fare summary
src/com/airtribe/ridewise/model/FareReceipt.java - Ride Status · Ride lifecycle states
src/com/airtribe/ridewise/enums/RideStatus.java - Vehicle Type · Driver vehicle categories
src/com/airtribe/ridewise/enums/VehicleType.java - Id Generator · Unique ID generation
src/com/airtribe/ridewise/util/IdGenerator.java - Constants · Shared configuration values
src/com/airtribe/ridewise/constants/Constants.java - No Driver · Raised when matching fails
src/com/airtribe/ridewise/exception/NoDriverAvailableException.java
Data
In-memory repositories and registries
- Rider Repo · Rider persistence contract
src/com/airtribe/ridewise/repository/RiderRepository.java - Rider Repo Impl · In-memory rider store
src/com/airtribe/ridewise/repository/RiderRepositoryImpl.java - Driver Repo · Driver persistence contract
src/com/airtribe/ridewise/repository/DriverRepository.java - Driver Repo Impl · In-memory driver store
src/com/airtribe/ridewise/repository/DriverRepositoryImpl.java - Location Registry · Tracks or resolves locations for matching
src/com/airtribe/ridewise/repository/LocationRegistry.java
Policies
Pluggable ride matching and fare calculation
- Match Strategy · Driver selection contract
src/com/airtribe/ridewise/strategy/RideMatchingStrategy.java - Nearest Driver · Chooses the closest available driver
src/com/airtribe/ridewise/strategy/NearestDriverStrategy.java - Least Active · Chooses the least active available driver
src/com/airtribe/ridewise/strategy/LeastActiveDriverStrategy.java - Fare Strategy · Fare calculation contract
src/com/airtribe/ridewise/strategy/FareStrategy.java - Default Fare · Standard fare calculation
src/com/airtribe/ridewise/strategy/DefaultFareStrategy.java - Peak Fare · Peak-hour fare calculation
src/com/airtribe/ridewise/strategy/PeakHourFareStrategy.java
Connections 30
- Main → Rider Service: uses · CLI delegates rider actions
- Main → Driver Service: uses · CLI delegates driver actions
- Main → Ride Service: uses · CLI delegates ride actions
- Rider Service → Rider Repo: depends on · Rider workflow reads and writes rider state
- Rider Repo → Rider Repo Impl: implemented by · Repository contract backed by in-memory store
- Driver Service → Driver Repo: depends on · Driver workflow reads and writes driver state
- Driver Repo → Driver Repo Impl: implemented by · Repository contract backed by in-memory store
- Ride Service → Driver Repo: reads · Ride flow needs driver availability
- Ride Service → Rider Repo: reads · Ride flow resolves rider data
- Ride Service → Location Registry: uses · Ride flow resolves or tracks locations
- Ride Service → Match Strategy: uses · Ride flow selects a matching algorithm
- Ride Service → Fare Strategy: uses · Ride flow selects pricing logic
- Match Strategy → Nearest Driver: implemented by · Nearest-driver matching option
- Match Strategy → Least Active: implemented by · Least-active matching option
- Fare Strategy → Default Fare: implemented by · Standard pricing option
- Fare Strategy → Peak Fare: implemented by · Peak pricing option
- Ride Service → Ride: creates/updates · Owns ride lifecycle state
- Ride Service → Fare Receipt: produces · Returns fare summary after pricing
- Ride → Rider: references · Ride binds to rider
- Ride → Driver: references · Ride binds to driver
- Ride → Location: uses · Ride uses pickup and drop-off locations
- Ride → Ride Status: uses · Ride state transitions are constrained by enum
- Driver → Vehicle Type: uses · Driver profile includes vehicle category
- Ride Service → No Driver: throws · Failure when no eligible driver exists
- Rider Service → Id Generator: uses · Creates unique rider identifiers
- Driver Service → Id Generator: uses · Creates unique driver identifiers
- Ride Service → Id Generator: uses · Creates unique ride identifiers
- Rider Service → Constants: uses · Shared configuration for service logic
- Driver Service → Constants: uses · Shared configuration for service logic
- Ride Service → Constants: uses · Shared configuration for ride workflow