Node.js GraphQL backend for Next.js Masters course. Provides mock e-commerce data for demo record store.
Apollo GraphQL API with Express middleware. Automated GraphQL workflow with Codegen. Postgresql via Prisma ORM. Recombee AI recommender API integration.
- Start DB container & admin panel:
docker-compose -f docker-compose-dev.yaml up adminer db
. - DB admin panel @ localhost:8080, user: admin, pass: password.
- Start Node server in hot reload (Nodemon):
npm run dev
.
Based on @graphql-codegen/cli package with https://www.npmjs.com/package/@eddeee888/gcg-typescript-resolver-files plugin for more opinionated setup.
pnpm codegen
to create/update GraphQL resolvers based on schema changes.
Update & apply migrations locally: DATABASE_URL=postgresql://admin:password@localhost:5432/njm pnpm exec prisma migrate dev
.
Refresh Prisma client: pnpm exec prisma generate
.
Mock data management:
Run seed script: DATABASE_URL=postgresql://admin:password@localhost:5432/njm pnpm exec ts-node prisma/seed.ts
.
Available options:
--drop
- clean all.--seed
- seed products.--seed-collections
- generate collections for existing products.--seed-users
- generate some registered users.--seed-reviews
- generate random lorem ipsum reviews.
Data for app testing is provided by Spotify API - store items are bulk generated by Spotify recommendation engine based on list of arbitrarily selected genres.
See prisma/mockdata/ folder for implementation details.
Production server is running on RKE2 Kubernetes. Deployment is automatic on push/merge to main branch - GitOps process runs via GitHub actions and ArgoCD.
Auto deployment workflow:
- Developer PR / push / merge to main.
- GitHub actions CICD pipeline:
- Automatic build of new Docker image (commit SHA based versioning).
- Push to GitHub container registry.
- Automatic update of image tag in Kubernetes manifest - auto-commit to main branch & skip CI option to avoid pipeline loop.
- On main branch update - ArgoCD webhook triggers cluster update.
All production secrets are encrypted using sealed secrets controller - https://github.com/bitnami-labs/sealed-secrets.
Required settings must be provided in Kubernetes configmaps / secrets.
# database
POSTGRES_USER
POSTGRES_PASSWORD
# app
DATABASE_USER
DATABASE_PASS
DATABASE_HOST # as "host:port" e.g. db:5432
DATABASE_NAME
NODE_ENV # development || production
NODE_PORT # graphql & rest server port, default 8000
# recommender
RECOMBEE_DB_NAME
RECOMBEE_API_KEY
RECOMBEE_DEFAULT_REGION
# configure database definitions
npx ts-node src/recommender/init.ts