A full-stack web application for managing yoga studio operations, including session scheduling, teacher management, and user registrations.
- Node.js 22 LTS
- Express.js 4.x
- TypeScript 5.4+ (Strict Mode)
- Prisma ORM
- PostgreSQL 16
- Zod (validation)
- JWT (authentication)
- bcrypt (password hashing)
- React 19 (Hooks only)
- TypeScript 5.9+ (Strict Mode)
- Vite 7.x
- TailwindCSS 4.x
- React Router 6.x
- Axios
- Docker + Docker Compose
- PostgreSQL container
- User registration
- User login with JWT tokens
- List all yoga sessions
- View session details
- Create new sessions (admin only)
- Update sessions (admin only)
- Delete sessions (admin only)
- Join/leave sessions (regular users)
- View list of teachers
- View teacher details
- View user profile
- Delete user account
- Node.js 22 LTS or higher
- Docker and Docker Compose
- npm or yarn
cd p4-dfsjs-startercd backend
npm installcd ../frontend
npm installCreate a .env file in the backend directory:
cd ../backend
cp .env.example .envThe default configuration should work with Docker Compose:
DATABASE_URL="postgresql://yogauser:yogapass@localhost:5432/yogastudio"
JWT_SECRET="your-secret-key-change-me-in-production"
PORT=8080
NODE_ENV=developmentFrom the project root:
docker-compose up -dThis will start a PostgreSQL container on port 5432.
cd backend
npm run prisma:migratenpm run prisma:seedThis will create:
- 1 admin user:
yoga@studio.com/test!1234 - 1 regular user:
user@test.com/test!1234 - 3 teachers
- 4 yoga sessions
cd backend
npm run devThe API will run on http://localhost:8080
cd frontend
npm run devThe frontend will run on http://localhost:3000
Admin User:
- Email:
yoga@studio.com - Password:
test!1234
Regular User:
- Email:
user@test.com - Password:
test!1234
POST /api/auth/register- Register a new userPOST /api/auth/login- Login and get JWT token
GET /api/session- Get all sessions (protected)GET /api/session/:id- Get session by ID (protected)POST /api/session- Create session (admin only)PUT /api/session/:id- Update session (admin only)DELETE /api/session/:id- Delete session (admin only)POST /api/session/:id/participate/:userId- Join session (protected)DELETE /api/session/:id/participate/:userId- Leave session (protected)
GET /api/teacher- Get all teachers (protected)GET /api/teacher/:id- Get teacher by ID (protected)
GET /api/user/:id- Get user by ID (protected)DELETE /api/user/:id- Delete user account (protected)
model User {
id Int @id @default(autoincrement())
email String @unique
firstName String
lastName String
password String
admin Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
sessions SessionParticipation[]
}
model Teacher {
id Int @id @default(autoincrement())
firstName String
lastName String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
sessions Session[]
}
model Session {
id Int @id @default(autoincrement())
name String
date DateTime
description String
teacherId Int
teacher Teacher @relation(fields: [teacherId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
participants SessionParticipation[]
}
model SessionParticipation {
sessionId Int
userId Int
session Session @relation(fields: [sessionId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([sessionId, userId])
}npm run dev # Start development server with nodemon
npm run build # Build TypeScript to JavaScript
npm start # Start production server
npm run prisma:generate # Generate Prisma client
npm run prisma:migrate # Run database migrations
npm run prisma:seed # Seed the database
npm run prisma:studio # Open Prisma Studionpm run dev # Start Vite development server
npm run build # Build for production
npm run preview # Preview production buildp4-dfsjs-starter/
├── backend/
│ ├── src/
│ │ ├── controllers/ # Request handlers
│ │ ├── middleware/ # Auth middleware
│ │ ├── dto/ # Zod validation schemas
│ │ ├── utils/ # JWT utilities
│ │ ├── routes/ # API routes
│ │ └── app.ts # Express app setup
│ ├── prisma/
│ │ ├── schema.prisma # Database schema
│ │ └── seed.ts # Database seeding
│ ├── package.json
│ ├── tsconfig.json
│ └── .env
├── frontend/
│ ├── src/
│ │ ├── pages/ # React page components
│ │ ├── components/ # Reusable components
│ │ ├── services/ # API services
│ │ ├── types/ # TypeScript types
│ │ ├── App.tsx
│ │ └── main.tsx
│ ├── package.json
│ ├── vite.config.ts
│ └── tailwind.config.js
├── docker-compose.yml
└── README.md
The project supports comprehensive testing with the following frameworks:
- Unit tests: For testing individual components and utilities
- Integration tests: For testing API endpoints
- End-to-end tests: For testing critical user flows
Run tests with the appropriate npm scripts in each directory.
# Check if PostgreSQL is running
docker ps
# Restart PostgreSQL
docker-compose restart postgres
# View logs
docker-compose logs postgres# Check what's using port 8080
lsof -i :8080
# Check what's using port 3000
lsof -i :3000
# Kill the process if needed
kill -9 <PID># Reset database (WARNING: deletes all data)
npx prisma migrate reset
# Regenerate Prisma client
npx prisma generatePlease follow the existing code style and ensure all tests pass before submitting changes.
MIT