Giter Site home page Giter Site logo

monthly-app-server's Introduction

Architecture

Flow

When user registers, we store the encrypted password to DB. Next time they login we use auth context to verify email and password with the DB records and send back request Auth token. If they reset a password, Postmark service will send a token over email for secure reset flow.

Resolvers are structured in a CRUD manner (create, update, delete mutations) and read is split based on schema: category, subcategory, expenses (everything is scoped based on UI needs, such as chartExpenses). Every query (non public one) is protect with is unauthenticated check.

GraphQL schema defined which data from DB is gonna be available as a response to Client side requests.

Prisma Schema defines our Database structure.

Services

We have a total of 5 services running.

one on Godaddy:

  • Domain hosting - yourmonthly.app (SSL and DNS managed within Digital Ocean)

three on Digital Ocean:

  • monthly-app-db
    • defaultdb (development DB)
    • defaultdb-prod (production DB)
  • monthly-app-server
  • Monthly-app-client

and one on Postmark:

Secrets

  • All secrets are split between development and production (managed within Digitial Ocean) environments

  • Auth JWT token (login/register/reset-password)

  • Digital Ocean DB keys

  • Postmark API key

Database

  • We use Postgres DB with Prisma ORM (migrations and DB management)

Local development

To run the server we need to run:

  • npm start which starts the server on http://localhost:3001
  • we connect to remote development DB hosted on Digital Ocean (env files hooked up to Prisma client)

When making Prisma schema changes:

  • npm run build - this will generate and execute Prisma migration on remote/dev DB

Debugging

We can inspect and check database with tools like DBeaver and connect to either development or production DB by using DATABASE_URL from either .env or .env.prod local files (or by checking the URL string from Digital Ocean).

Inspecting and checking GraphQL schema, queries and migrations can be done by running npm run prisma-studio and typing in the local development API (http://localhost:3001) or production API (https://yourmonthly.app), or just go to http://localhost:3001/api or https://yourmonthly.app/api and let Prisma Studio to guide you.

Production deploy

pushing master branch will trigger migrations automatically on production DB

monthly-app-server's People

Contributors

smikulic avatar

Stargazers

 avatar

Watchers

 avatar

monthly-app-server's Issues

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.