Book Directory is a full stack MERN app with the following features:
- Provides user signup and sign in.
- Provides features which lets the user add, edit, remove and view books.
- Provides protected APIs that means no unauthorized user can have access to protected resources.
- Getting Started
- Demo
- The src folder
- The database
- Installation
- Configuration
- Start up
- Launching in browser
- License
- Author
The app uses a Mysql database, TypeORM,and RESTful APIs in the backend. The backend is structured using MVC pattern, and uses entities and repository pattern.
Some of the backend endpoints are public and others are protected. That means no unauthorized user can have access to protected resources. This is achieved by the use of access token for authorizing client requests.
The frontend is build using react and uses react router dom library for navigating between different web pages without reload. And it also usese the axios library for making client requests to the server.
The app uses JWT (Json Web Token) for authoirzing the client/user requests to the server. Each client request to the server contains an access token which is used by the server to identify the user.
Users table
CREATE TABLE `Users` (
`userID` int NOT NULL AUTO_INCREMENT,
`username` varchar(45) NOT NULL,
`email` varchar(45) NOT NULL,
`password` varchar(256) NOT NULL,
PRIMARY KEY (`userID`)
)
Books table
CREATE TABLE `books` (
`id` int NOT NULL AUTO_INCREMENT,
`title` varchar(250) NOT NULL,
`description` varchar(2000) NOT NULL,
`coverImage` varchar(250) NOT NULL,
`userID` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
)
- Installing dependencies for backend
npm install
- Installing dependencies for frontend
cd src/frontend
npm install
Add these keys as environment variable in a .env file.
DB_HOST: loclhost or website url
DB_NAME: Database name
DB_USER: Database user
DB_PASSWORD: Database password
PORT: API server port (8080)
ACCESS_TOKEN_SECRET: Use to sign jwt tokens
To start the project in development mode.
Starting backend:
npm run dev
Starting frontend:
cd src/frontend
npm start
To start the project in production.
Starting backend:
npm run build <!-- To generate the build -->
npm start
Starting frontend
cd src/frontend
npm start
For generating errors and warnings:
npm run lint
- Frontend: http://localhost:3000/
- Backend: http://localhost:8080/
- Backend Swagger API docs: http://localhost:8080/api-docs
Read more about the license here:
Apache License 2.0
Lokesh Bisht