A RESTful API for a cinema ticket booking system built with Express.js, TypeScript, and PostgreSQL.
This Cinema API provides endpoints for user authentication, movie browsing, ticket reservation, seat selection, and admin functionalities for managing theaters and movie screenings.
- Backend: Express.js with TypeScript
- Database: PostgreSQL with Prisma ORM
- Authentication: JWT with refresh tokens
- Documentation: Swagger/OpenAPI
- Email Service: Nodemailer
- File Upload: Cloudinary
- Validation: Zod
- Development Tools: ESLint, Prettier
- User registration with email verification via OTP
- Login/Logout functionality
- Password reset
- JWT-based authentication with token refresh
- Browse available movies
- View movie details
- Browse available screenings
- Reserve tickets for movie screenings
- Select available seats
- View reservation history
- Cancel reservations
- Manage movies (CRUD operations)
- Manage theater halls
- Create and manage movie screenings/parties
- Upload movie images to Cloudinary
Cinema API/
├── prisma/ # Database schema and migrations
├── src/
│ ├── controllers/ # Route handlers
│ ├── middlewares/ # Auth, validation middleware
│ ├── routes/ # API routes
│ ├── schemas/ # Validation schemas
│ ├── services/ # Business logic
│ ├── utils/ # Utility functions
│ ├── app.ts # Express app setup
│ ├── env.ts # Environment variables
│ └── db.ts # Database connection
├── emailTemplates/ # Email templates
├── swagger.yaml # API documentation
├── .env # Environment variables
├── tsconfig.json # TypeScript configuration
└── package.json # Project dependencies
- Node.js (v18 or higher)
- PostgreSQL database
- Cloudinary account (for image uploads)
- SMTP email service
- Clone the repository:
git clone https://github.com/yourusername/cinema-api.git
cd cinema-api- Install dependencies:
pnpm install- Set up environment variables:
# Create a .env file with the following variables
DATABASE_URL="postgresql://user:password@localhost:5432/cinema"
JWT_SECRET="your-jwt-secret"
REFRESH_TOKEN_SECRET="your-refresh-token-secret"
CLOUDINARY_CLOUD_NAME="your-cloudinary-cloud-name"
CLOUDINARY_API_KEY="your-cloudinary-api-key"
CLOUDINARY_API_SECRET="your-cloudinary-api-secret"
EMAIL_SERVICE="your-email-service"
EMAIL_USER="your-email"
EMAIL_PASS="your-email-password"
- Run Prisma migrations:
npx prisma migrate dev --name init- Start the development server:
pnpm run devThe API is documented using Swagger/OpenAPI. Once the server is running, you can access the documentation at:
http://localhost:3000/api-docs
pnpm run build- Build the projectpnpm run start- Start the production serverpnpm run dev- Start the development server with hot reloadpnpm run studio- Open Prisma Studio to explore the databasepnpm run format- Format code with Prettier
The database includes models for:
- Customer - User management
- Movie - Movie details
- Party - Movie screening events
- Hall - Theater halls
- Seat - Individual seats in halls
- Reservation - Ticket bookings
This project is licensed under the ISC License.
Saleh Enab