Smart Library Docs

Getting Started

Step-by-step guide to install, configure, and run the SLMS project locally.

Getting Started

This guide walks you through setting up the Smart Library Management System (SLMS) for local development.

Prerequisites

Before you begin, make sure you have the following installed:

  • Node.js v18 or later (LTS recommended)
  • npm v9 or later
  • Git
  • MongoDB Atlas account (or a local MongoDB server)

1. Clone the Repository

git clone <repository-url>
cd slms-project

2. Backend Setup

Navigate to the backend directory:

cd backend

Install Dependencies

npm install

Configure Environment Variables

Create a .env file inside the backend folder.

PORT=5000
DATABASE_URL=mongodb+srv://<username>:<password>@<cluster>.mongodb.net/<database>
JWT_SECRET=your_secret_key_here
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your_email@gmail.com
SMTP_PASS=your_app_password
VariableDescription
PORTExpress server port
DATABASE_URLMongoDB Atlas or local MongoDB connection string
JWT_SECRETSecret used for signing JWT tokens
SMTP_HOSTSMTP server hostname
SMTP_PORTSMTP server port
SMTP_USEREmail account used to send notifications
SMTP_PASSApp password for SMTP authentication

Start the Backend

Development mode:

npm run dev

Production mode:

npm start

Backend API:

http://localhost:5000

Health Check:

curl http://localhost:5000/health

Expected response:

{
  "status": "ok",
  "message": "SLMS API is running"
}

3. Frontend Setup

Navigate to the frontend directory:

cd frontend

Install Dependencies

npm install

Configure Environment Variables

Create a .env.local file inside the frontend folder.

NEXT_PUBLIC_API_URL=http://localhost:5000/api/v1

Start the Development Server

npm run dev

Frontend URL:

http://localhost:3000

4. Initial Application Setup

When starting with an empty database:

  1. Open:
http://localhost:3000/setup
  1. Enter the Super Admin details:
  • First Name
  • Last Name
  • Email
  • Contact Number
  • Password
  1. Click Complete Setup.

The application will:

  • Create the first administrator account.
  • Assign the ROLE_ADMIN role.
  • Log you in automatically.
  • Redirect you to:
/admin/overview

Note

The setup endpoint can only be used once. If an administrator already exists, the API returns 403 Forbidden.


5. Documentation Site

Navigate to the documentation project:

cd docs

Install dependencies:

npm install

Start the documentation server:

npm run dev

Documentation URL:

http://localhost:3000

(If port 3000 is already in use, Next.js will automatically use the next available port.)


Project Structure

slms-project/

├── backend/
│   ├── server.js
│   ├── package.json
│   ├── models/
│   ├── controllers/
│   ├── routes/
│   ├── middleware/
│   ├── utils/
│   └── src/

├── frontend/
│   ├── package.json
│   └── src/
│       ├── app/
│       ├── components/
│       ├── context/
│       ├── hooks/
│       └── lib/

└── docs/
    ├── content/
    │   └── docs/
    └── package.json

Available Scripts

Backend

npm run dev

Start the backend in development mode.

npm start

Start the backend in production mode.


Frontend

npm run dev

Start the Next.js development server.

npm run build

Create a production build.

npm run start

Start the production server.


Documentation

npm run dev

Run the Fumadocs development server.

npm run build

Build the documentation site.


Next Steps

After completing the installation:

  • Log in using the Super Admin account.
  • Configure library settings.
  • Add librarians and staff.
  • Register students.
  • Import or add books.
  • Begin issuing and returning books.

Happy coding! 🚀

On this page