Architecture - Afulton11/writzsol GitHub Wiki

High-level Overview

High Level Diagram

The Application


Writzsol is a Next.js Application hosted on the Vercel platform.

Our backend is a simple API handling queries and mutations on our data. Due to Next.js' nature of handling API requests, Vercel auto-magically hosts each of our API functions on the AWS Lambda platform. One lambda function is used to represent our graphql database.

Our frontend is a (mostly) static website generated by Next.js using React. If a webpage is considered static, it's served directly from Vercel's CDN. Otherwise, the page will be rendered on the server and sent to the user (SSR).

The Data


Entity Relation Diagram

Our data is hosted in a heroku postgresql hobby-tier database.

Entity Definitions

Here, we'll explain what each entity represents along with some uses.

User-Specific Entities

User The entity representing Writzsol's user. Here, we store basic user information. This information is gernally retrieved upon logging into writzsol for the first time. Additionally, this data is auto-populated by next-auth.js.

  • name the user's full name as retrieved from a authentication provider. e.g. "Andrew Fulton"
  • email the user's email, retrieved from a provider.
  • emailVerified the date & time the user's email was verified
  • image the user's avatar, sometimes populated by a provider.

Authorization-Related Entities

https://next-auth.js.org/schemas/models

VerificationRequest An entity used during an email verification request.

  • identifier the email the verification request was sent to.
  • token the verification token sent to the email address provided. It's valid for 24 hours.

Account An entity that represents an account from an authentication provider.

  • userId The id of the user this account is linked with. A user may have multiple provider accounts.
  • providerType The type of provider the account is from. e.g. "Google" or "Apple"
  • providerId The provider's account Id
  • refreshToken A token given by the provider to generate access tokens; allows multiple uses without signing in again.
  • accessToken A token used to access the provider's OAuth API.
  • accessTokenExpires Date & Time when the accessToken expires.

Session Represent's a user's session within the Writzsol application. Each user can have multiple sessions, but each session can only have one user.

  • expires the Date & Time when this session expires and the user is logged out.

Site-Related Entities

Website An entity representing an individual user's website. A user may have multiple different websites, but a site only belongs to a single user.

  • defaultTheme the default theme a user is presented when first visiting the site. e.g. "light" or "dark"

Page An entity representing a page within a individual website. A Website may belong to multiple pages, but a page only belongs to a single site.

  • path the expected url path for this page from the root of the url. e.g. /user/writzsol
  • blocks A json array of blocks that represent data displayed on the page. This will represent the entire page and is really just a json object. The object data is based loosely off of editor.js' blocks. More information on this can be found on the blocks page.
    {
      "title": "Writzsol",
      "blocks": [
        {
          "type": "header",
          "data": {
            "size": 1,
            "text": "Hello Writzsol!"
          }
        },
        {
          "type": "Image",
          "data": {
            "url": "https://..../../",
            "caption": "A Turtle",
            "...Image Settings": "...More Settings"
          }
        }
      ],
      "version": "0.2.5"
    }
⚠️ **GitHub.com Fallback** ⚠️