The project is built using the following technologies:
- React (front-end)
- Express.js (back-end)
- Docker (for containerization)
- Playwright (for end-to-end testing)
- React Styleguidist (for component documentation)
- Swagger (for API documentation)
- GitHub Actions (for CI/CD)
react-router-dom
: For routingreact-bootstrap
: For stylingreact-icons
: For iconsag-grid-react
: For tables
The project has the following folder structure:
client
: React client-side applicationdocs
: React Styleguidist documentation sitee2e
: End-to-end tests by Playwright
server
: Express.js back-enddocs
: Swagger documentation site__tests__
: Jest tests
To run the server, follow these steps:
- Create a MySQL database, with port
3306
, and a user with the following credentials:- Username:
root
- Password:
secret
- Username:
- Run the SQL script in
server/movies.sql
to create the database schema and populate it with data - Navigate to the
server
folder:cd server
- Install the dependencies:
npm install
- Start the server:
npm start
- The server will be available at
https://localhost:3001
. Try accessinghttps://localhost:3001/
on your browser and allow the connection. - The Swagger documentation site will be available at
https://localhost:3001/
To run the client, follow these steps:
- Navigate to the
client
folder:cd client
- Install the dependencies:
npm install
- Start the client:
npm start
- The client will be available at
http://localhost:3000
To run the application, follow these steps:
- Install Docker on your machine
- Clone the repository:
git clone https://github.com/yourusername/cinehub.git
- Navigate to the root of the project:
cd cinehub
- Build the Docker images:
docker-compose build
- Start the containers:
docker-compose up
The application will be available at http://localhost:3000
.
The Swagger documentation site will be available at https://localhost:3001/
.
To run the client tests, follow these steps:
- Go to the
client
folder:cd client
- Run the tests:
npm run playwright
- The test results will be displayed in the browser, at
http://localhost:9323
(by default), and can be found in theclient/playwright-report
folder
To run the server tests, follow these steps:
- Go to the
server
folder:cd server
- Start the server:
npm start
- Run the tests:
npm run test
- When working with
react-router-dom
, theuseDetailedMovies
hook was still sending requests to the server even when the user was on a different page. This caused unnecessary requests to be sent to the server, causing issues due to the server's rate limiting.- To fix this, the
fetcher
function was added ansignal
parameter, which is used to cancel the request when the user navigates away from the page. - The
useDetailedMovies
'suseEffect
returned a cleanup function that calls theabort
method on anAbortController
instance. The controller'ssignal
is passed to all relevantfetcher
calls.
- To fix this, the