Client-Server Communication Basics

  • Clients (e.g., browsers like Chrome running JavaScript apps such as React or Angular) communicate with servers (e.g., running on localhost or cloud like AWS, GCP, Azure) via networks.
  • Communication methods include HTTP (REST APIs), gRPC, or WebSockets; video focuses on HTTP as the most common for REST-style interactions.
  • HTTP requests include method (e.g., GET/POST), URL, headers, and request body; servers respond with data that clients parse and use.

The Challenge of Data Transmission

  • Clients and servers may use different languages (e.g., JavaScript client vs. Rust server) with incompatible data types (dynamic vs. strict/compiled).
  • Key question: How does data transmitted over the network get understood by both sides to perform business logic, send responses, and update UI?
  • Recommendation: Understand the OSI model at a high level (application layer to physical layer) for context on network data transmission; not covered in depth here.

Solution: Serialization and Deserialization

  • Definition: Converting data to/from a common, language-agnostic format for transmission or storage.
  • Process:
    • Client converts its data (e.g., JavaScript object) to the standard format and sends it.
    • Server receives, converts to its format (e.g., Rust struct), processes, then converts response back to standard and sends.
    • Client receives and converts to its format.
  • Enables machines in different locations/environments to parse and make sense of data.
  • Applies to transmission (focus of video) and storage.

Focus Areas in Backend

  • Backend involves many technologies; video prioritizes widely used ones:
    • Communication: HTTP (REST APIs) over WebSockets or gRPC.
    • Databases: PostgreSQL (relational) over MySQL, SQLite, MongoDB, or DynamoDB.
    • Serialization: JSON as the most popular (80% estimate) for client-server.

Types of Serialization Standards

  • Text-based: Human-readable formats like JSON, YAML, XML; used in configs, logs, HTTP transmission.
  • Binary: Formats like Protocol Buffers (Protobuf); more efficient but less readable.
  • Video focuses on JSON for HTTP communication.

JSON Details

  • Stands for: JavaScript Object Notation; resembles JS objects but language-agnostic.
  • Use Cases: HTTP transmission, config files, logging.
  • Structure:
    • Enclosed in curly braces {}.
    • Keys: Must be strings in double quotes (e.g., “name”).
    • Values: String, number, boolean, array, or nested object.
    • Supports nesting (e.g., address object inside main object).
  • Human-readable and fundamental data types; rules ensure consistency.