Create, share, and see trending decks for Pokemon's PTCGP app.
This guide walks you through setting up the PTCGP full-stack project from scratch, including backend (Node.js + Express + Prisma + PostgreSQL) and frontend (React + Vite + TypeScript + Tailwind + React Query).
Make sure you have installed:
It is recommended to have Postman for API testing, Docker app for GUI, and Github Desktop if you are novice to Git.
cd backendnpm installDependencies include:
- express, cors, dotenv
- prisma, @prisma/client
- pg
- nodemon (dev only)
docker run --name ptcgp-db -e POSTGRES_PASSWORD=pass -e POSTGRES_DB=ptcgp -p 5432:5432 -d postgres- Username:
postgres - Password:
pass - Database:
ptcgp - Port:
5432
Create a .env file in backend:
DATABASE_URL="postgresql://postgres:pass@localhost:5432/ptcgp"
JWT_SECRET="your-super-secret-jwt-key-change-this-in-production-6d14e2f40e1e7183545a9ab7594ea9d1a08cc4f490b5d29e71db1fe020e01a5b"
NODE_ENV="development"
FRONTEND_URL="http://localhost:5173"On Mac, if Prisma fails with P1000 error, try:
DATABASE_URL="postgresql://postgres:pass@host.docker.internal:5432/ptcgp"npx prisma migrate dev --name init
npx prisma generatenpm run dev- Server runs at http://localhost:4000
Run the following command to seed the database with initial data (e.g., roles and users):
npm run db:seedEnsure your .env file includes the following variable for authentication:
JWT_SECRET="your-super-secret-jwt-key-change-this-in-production"cd ../frontendnpm installnpm run dev- Vite dev server runs at http://localhost:5173
If the frontend needs to communicate with the backend, create a .env file in the frontend folder with the following content:
VITE_API_URL=http://localhost:4000npm run dev # start backend in dev mode
npx prisma migrate dev --name <name> # run migrations
npx prisma studio # web GUI for databasenpm run dev # start Vite frontenddocker ps # list containers
docker start ptcgp-db # start DB container
docker logs ptcgp-db # view Postgres logs- GET / - Test Route
- GET /roles
- POST /role
Ensure Tailwind CSS is properly configured in the frontend/src/styles/index.css file. It should include:
@import "tailwindcss";When not in use, stop the PostgreSQL Docker container to save resources:
docker stop ptcgp-dbIf the DB has changed, you will need to reset the migration. This is the easiest way in development.
- Delete the migration folder in backend/prisma if existing.
- Run
cd backend
npx prisma migrate reset
npm run db:migrate- Then run the backend and seed.
npm run db:seed
npm run dev