This is a simple book exchange system that allows members to borrow books and return them after a certain period of time. The system is built using Typescript, Express, and PostgreSQL and adheres to the Domain-Driven Design (DDD) and Command Query Responsibility Segregation (CQRS) patterns.
Other tools used:
- Swagger and Bruno for API docs
- Nix and Direnv for development environment
- Jest for unit testing
- Gitub Actions for CI/CD
- Clone the repo
- Install dependencies with
npm install
orpnpm install
- Create a .env file by copying the .env.example file and fill in the required fields
- Run the command
npm run dev
to start the server locally - Open your browser and navigate to
http://localhost:5000/api-docs
to view the Swagger documentation or if you're using Bruno, you can open the collection provided in thecollections
folder.
- Clone the repo
- Run
direnv allow
to allow direnv to load the .envrc file - Run
nix develop
to enter the nix shell or if direnv is enabled, environment will be prepared for you automagically. - Create a .env file by copying the .env.example file and fill in the required fields
- Run
npm run dev
to start the server locally - Open your browser and navigate to
http://localhost:5000/api-docs
to view the Swagger documentation or if you're using Bruno, you can open the collection provided in thecollections
folder.
- run
npm run test
to run the tests
- Members can borrow books with conditions
POST /api/books/:bookCode/borrow
- Member returns the book with conditions
POST /api/books/:bookCode/return
- Check list of books with conditions
GET /api/books/in-stock
- Check list of members with conditions
GET /api/members
These endpoints and the rest of the endpoints can be accessed through the Swagger documentation here https://eigen-tc-api.hidayattaufiqur.dev/api-docs
- Members can borrow books with conditions
- Members may not borrow more than 2 books
- Borrowed books are not borrowed by other members
- Member is currently not being penalized
- Member returns the book with conditions
- The returned book is a book that the member has borrowed
- If the book is returned after more than 7 days, the member will be subject to a penalty. Member with penalty cannot able to borrow the book for 3 days
- Check the book
- Shows all existing books and quantities
- Books that are being borrowed are not counted
- Member check
- Shows all existing members
- The number of books being borrowed by each member
- Others
- add more tests
- add more swagger docs
- deploy
- edit readme