Giter Site home page Giter Site logo

message-board's Introduction

Message Board App

Requirements

Functional Requirements

  • Create a single-page application (SPA)
  • It should allow users who visit the page to post a message to a global board
  • Anybody should be able to see the messages posted on the board (there need not be any authentication system)
  • Messages should show a name (provided when posting a message by the user), the date it was posted, and the message itself
  • Messages should be displayed by most-recent first
    • Stretch: Implement 'infinite scrolling' where the first 10 load initially, and when the user scrolls to the bottom, more load until there are none left, as is common on most social apps these days

Technical Specification

  • The App should be built using NextJS
  • The App should be hosted on Compute Engine, by running NextJS in a Virtual Machine (VM)
  • The App should be packaged onto a Machine Image using Packer
  • Infrastructure should be managed using Terraform
  • The App should scale with demand - try using scaling groups!
  • You should build this in your sandbox!

Basic architecture: User -> Load Balancer -> VM -> Firestore

This Google guide for HTTP Regional Load Balancing basically sums up the whole architecture https://cloud.google.com/load-balancing/docs/https/setting-up-reg-ext-https-lb. It doesn't discuss using Firestore as a database though. (They even have some Terraform snippets!)

Don't worry too much about HTTPS - HTTP is fine. Also don't worry about DNS, just connecting to the load balancer via IP is fine.

Important Notes

  • You cannot assign public IPs to VMs in our organisation
    • this means you'll have to configure OSLogin and IAP to build your images - I've set up the packer file for you, but you'll have to make sure your VPC is set up for it (take special notice of the TCP firewall rule!)
    • you'll also have to use a load balancer to direct web-traffic at your instances

Guidance

Remember to break down your problems into individual tasks.

For example, in order to post a message, think about each step in the process

  • How do I create the graphical interface to allow the user to post their message?
  • How do I take that information and pass it to the API?
  • How do I put that information in the database?
  • How can I display that message to the user?

When things aren't working - consider permissions!

  • How can I allow my VM to communicate with Firestore?
  • Every deployed VM has the permissions of it's associated service account, what permissions does it have? (Hint: take a look in IAM and look for a service account with Firebase Admin permissions, that'll be permitted to communicate with firestore!)

Don't try and dive straight in and write some Terraform, figure out what infrastructure you need first - you can make it all in the Cloud Console first and codify it later!

Repository Structure

I recommend you fork this repository and commit your changes to your own copy.

You'll notice a few folders in this repository:

/packer - this contains anything related to Packer, which is a tool which will help you make VM images. It's made by the same people as Terraform, and uses the same markup language. I've created a bit of a starting point for you since you've not used it before and it was a bit tricky to configure. You'll have to come up with the build script yourself, which I've left hints for in the provision.sh file.

/terraform - here you should create your terraform modules and deployments:

/terraform/modules/vpc - here you should put your "permenant" infrastructure, for example, a VPC and subnets in which your machine should live.

You'll need to create a VPC before starting with the Packer stuff, since it starts up a VM and 'saves' it, and it needs somewhere to do that. Start here!

/terraform/modules/app - here you should put your more "destructable" infrastructure, for example, VM, load balancer

This setup will allow you to easily redeploy VMs when you're having trouble, without having to delete and redeploy a whole VPC! You can also find example modules in our terraform-stacks repository.

/terraform/deployment - here you should "consume" your modules, by providing the required variables for that module declared in each module's variables.tf files, here is where you should run your terraform applys!

/app - Your NextJS app

Notes

You'll have to make sure you've got the right Terraform version installed, you can see that version in ./terraform/modules/vpc/versions.tf

Reference material

Good luck! Trial and error is your friend.

message-board's People

Contributors

mdinos avatar

Watchers

 avatar

Forkers

ugonnaa

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.