# aydesai/coding-challenge architecture

> Architecture diagram of the GitHub repository aydesai/coding-challenge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aydesai/coding-challenge
- Repository: https://github.com/aydesai/coding-challenge

## Overview

##### Project type and purpose
- This repository contains two coding‐challenge starters. The one with real code is “self‐driving‐car,” a .NET/C# console client that interacts with a remote REST API to drive a simulated car around a course. It demonstrates a layered client application (API‐consumer) with domain entities, a service interface, and REST communication logic.

##### File structure
- Top level:
- elevator/README.md – placeholder for second challenge, no code to analyze here.
- self-driving-car/ – the main project directory.
- Under self-driving-car/src:
- SelfDrivingCar.Client/ – the client application: console entry point, the REST‐client wrapper SelfDrivingCarRestClient.cs, and its .csproj.
- SelfDrivingCar/ – core library:
– Entities/ – domain model classes (Car, Road, SpeedLimit, TokenRequest, etc.).
– ISelfDrivingCarService.cs – service interface defining operations.
– LawsOfMotion.cs – business logic that translates CAR state + commands into next state.
– SelfDrivingCar.csproj – the core library project file.

##### README for additional insights
- It defines the challenge: drive a car using a hosted REST API, obey speed limits, complete the course as fast as possible.

##### Elements
- Another for “data models” (Entities).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Subgraphs for layers
    subgraph "Client Application"
        direction TB
        ClientApp["SelfDrivingCar.Client\n(Console Loop)"]:::presentation
    end

    subgraph "Service Layer"
        direction TB
        ServiceInterface["ISelfDrivingCarService"]:::service
    end

    subgraph "Data Access Layer"
        direction TB
        RestClient["SelfDrivingCarRestClient\n(HttpClient)"]:::data
    end

    subgraph "Domain Model"
        direction TB
        Car["Car"]:::entity
        CarAction["CarAction"]:::entity
        Engine["Engine"]:::entity
        ErrorMessage["ErrorMessage"]:::entity
        Road["Road"]:::entity
        SpeedLimit["SpeedLimit"]:::entity
        SpeedLimitAhead["SpeedLimitAhead"]:::entity
        Token["Token"]:::entity
        TokenRequest["TokenRequest"]:::entity
    end

    subgraph "Business Logic"
        direction TB
        LawsOfMotion["LawsOfMotion"]:::logic
    end

    ExternalAPI["External REST API"]:::external

    %% Connections
    ClientApp -->|"GetToken()\nGetCarState()\nPostCarAction()"| ServiceInterface
    ServiceInterface -->|"implements"| RestClient
    RestClient -->|"HTTP Requests\n(serialize/deserialize)"| ExternalAPI
    ExternalAPI -->|"JSON payloads"| RestClient
    RestClient -->|"maps to entities"| Car & CarAction & Engine & ErrorMessage & Road & SpeedLimit & SpeedLimitAhead & Token & TokenRequest
    Car & CarAction & Engine & ErrorMessage & Road & SpeedLimit & SpeedLimitAhead & Token & TokenRequest --> LawsOfMotion
    LawsOfMotion -->|"ComputeNextAction(Car)"| ClientApp

    %% Click Events
    click ClientApp "https://github.com/aydesai/coding-challenge/blob/master/self-driving-car/src/SelfDrivingCar.Client"
    click ServiceInterface "https://github.com/aydesai/coding-challenge/blob/master/self-driving-car/src/SelfDrivingCar/ISelfDrivingCarService.cs"
    click RestClient "https://github.com/aydesai/coding-challenge/blob/master/self-driving-car/src/SelfDrivingCar.Client/SelfDrivingCarRestClient.cs"
    click Car "https://github.com/aydesai/coding-challenge/blob/master/self-driving-car/src/SelfDrivingCar/Entities/Car.cs"
    click CarAction "https://github.com/aydesai/coding-challenge/blob/master/self-driving-car/src/SelfDrivingCar/Entities/CarAction.cs"
    click Engine "https://github.com/aydesai/coding-challenge/blob/master/self-driving-car/src/SelfDrivingCar/Entities/Engine.cs"
    click ErrorMessage "https://github.com/aydesai/coding-challenge/blob/master/self-driving-car/src/SelfDrivingCar/Entities/ErrorMessage.cs"
    click Road "https://github.com/aydesai/coding-challenge/blob/master/self-driving-car/src/SelfDrivingCar/Entities/Road.cs"
    click SpeedLimit "https://github.com/aydesai/coding-challenge/blob/master/self-driving-car/src/SelfDrivingCar/Entities/SpeedLimit.cs"
    click SpeedLimitAhead "https://github.com/aydesai/coding-challenge/blob/master/self-driving-car/src/SelfDrivingCar/Entities/SpeedLimitAhead.cs"
    click Token "https://github.com/aydesai/coding-challenge/blob/master/self-driving-car/src/SelfDrivingCar/Entities/Token.cs"
    click TokenRequest "https://github.com/aydesai/coding-challenge/blob/master/self-driving-car/src/SelfDrivingCar/Entities/TokenRequest.cs"
    click LawsOfMotion "https://github.com/aydesai/coding-challenge/blob/master/self-driving-car/src/SelfDrivingCar/LawsOfMotion.cs"

    %% Styles
    classDef presentation fill:#E8F7FF,stroke:#1E90FF,stroke-width:2px
    classDef service fill:#DFFFE0,stroke:#2E8B57,stroke-width:2px
    classDef data fill:#FFF8DC,stroke:#DAA520,stroke-width:2px
    classDef logic fill:#FFE4E1,stroke:#FF4500,stroke-width:2px
    classDef entity fill:#FFF0F5,stroke:#C71585,stroke-width:2px
    classDef external fill:#F0F0F0,stroke:#808080,stroke-width:2px,stroke-dasharray: 5 5
```
