MelodyMates

Share music with your mates

Test Client Add me on MelodyMates Test Client

This repository contains the database configuration and a PWA test client for MelodyMates deployed at MelodyMates.app.

MelodyMates is a social network for close friends who want to share new songs they've discovered. Users can post the song they're currently listening to or search for specific titles. They can react to their friend's posts and reply by text or songs. MelodyMates is made for young music lovers.



Running the PWA Test Client

  1. Install dependencies using npm i
  2. Run and open the dev server using npm run dev --open

Deploying the PWA Test Client

This client is continuously deployed on Netlify on pushes to main.
If you still want to create a production version of the client, use npm run build and preview using npm run preview

Database Configuration

The database is currently not managed as IaC, meaning it has to be set up manually.
The .fauna directory includes a GraphQL schema including relationship indexes, as well as generated indexes, role definitions and user-defined functions.


Project Architecture

For learning purposes, I decided to build most of the backend functionality using Fauna's user-defined functions and using narrow attribute-based access control.
The only function not contained within Fauna or the client is the authentication service on Google Cloud Functions. It validates a user's spotify key and generates a JWT for authorization on Fauna.

This is how the authentication & authorization process works:

  1. A Client completes an OAuth2 handshake with a Music API to get an access key and refresh token.
  2. The client then sends the access key to the authentication service to get a MelodyMates JWT.
  3. The authentication service validates the authenticity and validity of the access key and generates the token using our private key.
  4. The client then uses this token in its request to the Fauna API.
  5. Fauna retrieves our public key from Netlify and validates the JWT. If correct, it uses the token's sub attribute to control which resources can be accessed.

MelodyMates

Data Model

Data Model

GraphQL schema