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.
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)
- defaultdb (
- monthly-app-server
- Monthly-app-client
and one on Postmark:
- Monthly App - Production (reset password email - template managed within their template editor)
-
All secrets are split between
development
andproduction
(managed within Digitial Ocean) environments -
Auth JWT token (login/register/reset-password)
-
Digital Ocean DB keys
-
Postmark API key
- We use Postgres DB with Prisma ORM (migrations and DB management)
To run the server we need to run:
npm start
which starts the server onhttp://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
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.
pushing master
branch will trigger migrations automatically on production
DB