2024 01 29 - TheEvergreenStateCollege/upper-division-cs-23-24 GitHub Wiki

Week 04 - Monday

29 Jan 2024

Web Infrastructure - Morning Session

Review from Last Week

  • Created an API server in NodeJS and Express
  • URL routes and route parameters
    • `
  • Found repetitive tags in the DOM of popular websites that can be automated with loops
  • Starting to replace CSV's as our data source
  • Introduction to thinking about web interactions, web art, and final project
  • Model-View-Controller paradigm

This Week

Today in class, we will be following this AWS EC2 Week 3 setup documentation to prepare for Infra Homework 03, Infra Homework 04 (to be published), Frontend Homework 03, and Frontend Homework 04 (to be published).

Docker Containers (Briefly)

We introduce Docker briefly here because it is one way to automate installation and configuration of a complex piece of software, the Postgres database.

More details about why and how to use the Postgres Docker image are here.

We will cover containers in more detail in the second half of this quarter as we are creating reproducible, deployable environments for your final projects.

Ways to Think of It

  • Like a virtual machine (e.g. Virtual Box) but more performant
    • we virtualize the operating system (we can run Linux on Windows, e.g.) but we use bare metal hardware
  • Like logging into a separate machine
    • but it is actually hosted locally alongside our host operating system
  • A "guest" OS inside of the "host" OS
  • We are running Docker inside of our AWS server
    • so there are multiple levels of nesting, it is easy to forget where we are at.
    • it helps to draw a system diagram

Databases

  • Databases as a replacement for CSV's (imagine as a spreadsheet, which is a simple DB)
    • rows/datapoints and columns/fields
    • databases operate via transactions
      • (operations to insert, update, delete rows)
      • consider the operations
    • databases have advantages over CSV files or spreadsheets
      • store and manage data separately from code (separation of concerns)
      • efficiency: databases use indexes (e.g. binary search trees) for fast lookup, binary optimizations
    • database have some disadvantages
      • have to backed up and restored separately from code
      • are generally not human-readable (in binary-optimized files)
      • more complex, require installing separate software
      • for structured queries, uses a separate language (SQL), on top of HTML/CSS/JS
      • often require dedicated staff (DB admins)
    • properties of a database (ACID)
      • atomic - either all of a transaction occurs or none of it does (no partial operations on a row or group of rows)
      • consistent -
      • isolated - multiple readers and writers do not interfere with each other (every reader / writer acts as if it has exclusive access to the database in some serial history, or a known error occurs)
      • durable - transactions that have committed persist even if power goes out, program crashes, or other fault occurs.

Schemas, Data Models

We will follow this introduction to database schemas from freecodecamp.

  • Schemas and models, as fields / columns of the CSV

  • An Object Relational Mapping (ORM) via Prisma

  • provides programmatic access to a database from a programming language

    • the database, programming language of the server, API middleware, and view language define a tech stack
      • well-known tech stacks are LAMP, MEAN, MERN, and ours PERN
    • in the MEAN stack, where MongoDB is the database instead of Postgres, Mongoose is a popular ORM
  • Mob programming exercise

    • We examine 4 different ways to store data
      • hashmap in memory (Java HashMap or Javascript object)
      • CSV file on disk
      • redis key-value store, primarily in-memory for speed, but also caches to disk for persistence
      • (MongoDB) we don't have

Afternoon Session

  • PDF Resume templates on Overleaf
  • Hackerrank Practice
⚠️ **GitHub.com Fallback** ⚠️