A full-stack mobile application for managing a books. Users can browse available books, borrow and return books, and manage their own book collection.
- User Authentication: Register, login, and password reset functionality
- Book Catalog: Browse all available books with search functionality
- Book Management: Add, edit, and delete books
- Borrowing System: Borrow and return books with due date tracking
- User Profile: View borrowed books and personal statistics
book-borrowing-app/
├── backend/ # Backend Node.js application
│ ├── config/ # Configuration files
│ ├── controllers/ # API controllers
│ ├── middleware/ # Express middleware
│ ├── routes/ # API routes
│ ├── .env # Environment variables
│ ├── .env.example # Example environment variables
│ ├── package.json # Backend dependencies
│ └── server.js # Entry point
│
├── frontend/ # React Native application
│ ├── src/
│ │ ├── components/ # Reusable components
│ │ ├── context/ # React context providers
│ │ ├── navigation/ # Navigation configuration
│ │ ├── screens/ # Application screens
│ │ ├── theme/ # Theme configuration
│ │ ├── types.ts # TypeScript type definitions
│ │ └── config.ts # Application configuration
│ ├── App.tsx # Main application component
│ └── package.json # Frontend dependencies
│
└── README.md # Project documentation
- React Native
- React Navigation
- React Native Paper (UI components)
- AsyncStorage (local storage)
- TypeScript
- Node.js
- Express.js
- MySQL (with mysql2 driver)
- JWT Authentication
- Bcrypt (password hashing)
- Nodemailer (for password reset emails)
- Node.js (v14 or higher)
- npm or yarn
- MySQL database
- React Native development environment (Expo CLI)
git clone https://github.com/ElazzouziHassan/books-app.git
cd books-app
- Navigate to the backend directory:
cd backend
- Install dependencies:
npm install
- Create a
.env
file in the backend directory with the following variables:
# Server Configuration
PORT=3000
# Database Configuration
DB_HOST=localhost
DB_USER=your_db_username
DB_PASSWORD=your_db_password
DB_NAME=db_name
# JWT Secret
JWT_SECRET=your_jwt_secret_key
# Email Configuration (for password reset)
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_email_password
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
BASE_URL=http://localhost:3000
- Create the MySQL database:
CREATE DATABASE db_name;
- Start the backend server:
npm run dev
The server will automatically create the necessary tables when it starts for the first time.
- Navigate to the frontend directory:
cd frontend
- Install dependencies:
npm install
- Update the API URL in
src/config.ts
to point to your backend server:
export const API_URL = "http://your-ip-address:3000/api"
- Start the frontend application:
npx expo start
- Use the Expo Go app on your mobile device to scan the QR code, or run on an emulator.
The application uses the following database tables:
id
: INT (Primary Key, Auto Increment)name
: VARCHAR(255)email
: VARCHAR(255) (Unique)password
: VARCHAR(255) (Hashed)reset_token
: VARCHAR(255) (For password reset)reset_token_expiry
: DATETIMEcreated_at
: TIMESTAMPupdated_at
: TIMESTAMP
id
: INT (Primary Key, Auto Increment)title
: VARCHAR(255)author
: VARCHAR(255)isbn
: VARCHAR(50) (Unique)published_year
: INTdescription
: TEXTcover_image
: TEXT (URL to book cover)available
: BOOLEAN (Default: TRUE)user_id
: INT (Foreign Key to users.id)created_at
: TIMESTAMPupdated_at
: TIMESTAMP
id
: INT (Primary Key, Auto Increment)user_id
: INT (Foreign Key to users.id)book_id
: INT (Foreign Key to books.id)borrowed_at
: TIMESTAMPdue_date
: DATETIMEreturned_at
: DATETIME (NULL until returned)
- URL:
/api/auth/register
- Method:
POST
- Body:
{ name, email, password }
- Response:
{ message, userId }
- URL:
/api/auth/login
- Method:
POST
- Body:
{ email, password }
- Response:
{ token, user: { id, name, email } }
- URL:
/api/auth/me
- Method:
GET
- Headers:
Authorization: Bearer {token}
- Response:
{ id, name, email }
- URL:
/api/auth/forgot-password
- Method:
POST
- Body:
{ email }
- Response:
{ message }
- URL:
/api/auth/reset-password
- Method:
POST
- Body:
{ token, password }
- Response:
{ message }
- URL:
/api/books
- Method:
GET
- Headers:
Authorization: Bearer {token}
- Response: Array of book objects
- URL:
/api/books/available
- Method:
GET
- Headers:
Authorization: Bearer {token}
- Response: Array of available book objects
- URL:
/api/books/:id
- Method:
GET
- Headers:
Authorization: Bearer {token}
- Response: Book object
- URL:
/api/books
- Method:
POST
- Headers:
Authorization: Bearer {token}
- Body:
{ title, author, isbn, publishedYear, description, coverImage }
- Response: Created book object
- URL:
/api/books/:id
- Method:
PUT
- Headers:
Authorization: Bearer {token}
- Body:
{ title, author, isbn, publishedYear, description, coverImage }
- Response: Updated book object
- URL:
/api/books/:id
- Method:
DELETE
- Headers:
Authorization: Bearer {token}
- Response:
{ message }
- URL:
/api/books/:id/borrow
- Method:
POST
- Headers:
Authorization: Bearer {token}
- Response:
{ message, dueDate }
- URL:
/api/books/:id/return
- Method:
POST
- Headers:
Authorization: Bearer {token}
- Response:
{ message }
- URL:
/api/books/borrowed
- Method:
GET
- Headers:
Authorization: Bearer {token}
- Response: Array of borrowed book objects
- URL:
/api/books/user
- Method:
GET
- Headers:
Authorization: Bearer {token}
- Response: Array of book objects added by the user
- URL:
/api/books/user/stats
- Method:
GET
- Headers:
Authorization: Bearer {token}
- Response:
{ ownedBooks, borrowedBooks }
- Open the app and navigate to the registration screen
- Create a new account with your name, email, and password
- Login with your credentials
- Browse available books on the home screen
- Use the search bar to find specific books
- Tap on a book to view details
- Press the "Borrow" button to borrow a book
- Navigate to the "Borrowed" tab to see your borrowed books
- View due dates for each book
- Return books by pressing the "Return Book" button
- Navigate to the "Manage" tab
- Add new books by pressing the "+" button
- Edit or delete your books by selecting them from the list
- Navigate to the "Profile" tab to view your information
- See statistics about your borrowed and added books
- Log out from the application
- Ensure your MySQL server is running
- Verify the database credentials in the
.env
file - Check that the database has been created
- Verify the API_URL in the frontend config.ts file
- Ensure the backend server is running
- Check for network connectivity issues
- Ensure JWT_SECRET is properly set in the .env file
- Check that tokens are being properly stored and sent with requests
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
No licence has been setup for this project yet. (When I add it I will mentioned it here)