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-project2. Backend Setup
Navigate to the backend directory:
cd backendInstall Dependencies
npm installConfigure 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| Variable | Description |
|---|---|
PORT | Express server port |
DATABASE_URL | MongoDB Atlas or local MongoDB connection string |
JWT_SECRET | Secret used for signing JWT tokens |
SMTP_HOST | SMTP server hostname |
SMTP_PORT | SMTP server port |
SMTP_USER | Email account used to send notifications |
SMTP_PASS | App password for SMTP authentication |
Start the Backend
Development mode:
npm run devProduction mode:
npm startBackend API:
http://localhost:5000Health Check:
curl http://localhost:5000/healthExpected response:
{
"status": "ok",
"message": "SLMS API is running"
}3. Frontend Setup
Navigate to the frontend directory:
cd frontendInstall Dependencies
npm installConfigure Environment Variables
Create a .env.local file inside the frontend folder.
NEXT_PUBLIC_API_URL=http://localhost:5000/api/v1Start the Development Server
npm run devFrontend URL:
http://localhost:30004. Initial Application Setup
When starting with an empty database:
- Open:
http://localhost:3000/setup- Enter the Super Admin details:
- First Name
- Last Name
- Contact Number
- Password
- Click Complete Setup.
The application will:
- Create the first administrator account.
- Assign the
ROLE_ADMINrole. - Log you in automatically.
- Redirect you to:
/admin/overviewNote
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 docsInstall dependencies:
npm installStart the documentation server:
npm run devDocumentation 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.jsonAvailable Scripts
Backend
npm run devStart the backend in development mode.
npm startStart the backend in production mode.
Frontend
npm run devStart the Next.js development server.
npm run buildCreate a production build.
npm run startStart the production server.
Documentation
npm run devRun the Fumadocs development server.
npm run buildBuild 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! 🚀