The Book Rental System is a web application that allows users to manage and search for books. It provides features such as listing all books, searching for books by title or author, and renting/returning books.
The system is built using the following technologies:
- Node.js: A JavaScript runtime for server-side development.
- Nest.js: A progressive Node.js framework for building efficient and scalable web applications.
- Prisma: A modern database toolkit for TypeScript and Node.js that simplifies database access.
The application follows a layered architecture, separating concerns into modules, controllers, services, and data access layers. It uses RESTful API endpoints to handle requests and responses.
Before running the application, make sure you have the following installed on your machine:
- Node.js (v14 or higher)
- npm (Node Package Manager)
- Docker for (PostgreSQL database)
Follow these steps to set up and run the application:
- Clone the repository:
git clone https://github.com/rvslan/book-rental-app
- Navigate to the project directory:
cd book-rental-app
- Install dependencies:
npm install
- Run docker:
docker compose up -d
Before running the application, you need to configure the database connection. Open the .env
file in the project root directory and update the database credentials:
NODE_ENV=testing
APP_PORT=3000
AT_SECRET=at-secret
RT_SECRET=rt-secret
SALT_ROUNDS=10
DATABASE_URL="postgresql://postgres:123@localhost:5432/nestjs?schema=public"
The application uses Prisma for database access and management. To migrate the database schema, run the following command:
npx prisma migrate dev
This will create the necessary tables and relationships in the database.
To migrate the database seeders with book stores/books, run the following command:
npx prisma db seed
This will create the necessary dummy data in the database.
To start the application, run the following command:
npm run start:dev
The application will start on http://localhost:3000 by default. You can access the API endpoints using a tool like Postman or through a web browser.
The application includes unit tests and integration tests to ensure its correctness. To run the tests, use the following command:
#unit tests
npm run test
#e2e tests
npm run test:e2e
This will execute all the test cases and display the results.
The API documentation is generated using Swagger. You can access the documentation by visiting http://localhost:3000/docs in your web browser. It provides detailed information about each API endpoint, including request and response examples.
- Elasticsearch integration for advanced book search capabilities
- Sentry integration for error handling and monitoring
- CloudWatch integration for comprehensive error monitoring and log analysis