A full-stack library management system for physical and digital libraries. Supports book search, borrowing, returning, reviews, staff administration, and analytics using MySQL and MongoDB.
- Frontend: Next.js, React, TypeScript, Tailwind CSS
- Backend: Express.js, Node.js, TypeScript
- Databases: MySQL (relational), MongoDB (NoSQL)
- Dev Tools: Docker, npm, ESLint, Prettier, Flyway
Smart-Library-Platform/
โโโ frontend/ # Next.js frontend application
โ โโโ src/
โ โ โโโ app/ # Next.js app router
โ โ โ โโโ page.tsx # Home page
โ โ โโโ components/ # Reusable UI components
โ โ โโโ hooks/ # Custom React hooks
โ โ โโโ services/ # API service layer
โ โ โโโ store/ # State management
โ โ โโโ types/ # TypeScript type definitions
โ โโโ public/ # Static assets
โ โโโ package.json # Frontend dependencies
โ โโโ next.config.js # Next.js configuration
โ โโโ tailwind.config.js # Tailwind CSS configuration
โโโ backend/ # Express.js backend application
โ โโโ src/
โ โ โโโ index.ts # Main application entry point
โ โ โโโ controllers/ # Request handlers
โ โ โโโ models/ # Database models
โ โ โโโ routes/ # API routes
โ โ โโโ middleware/ # Custom middleware
โ โ โโโ services/ # Business logic
โ โ โโโ database/ # Database connections
โ โโโ compose.yaml # Docker Compose for MySQL & Flyway
โ โโโ flyway/ # Database migration files
โ โ โโโ flyway.toml # Flyway configuration
โ โ โโโ migrations/ # SQL migration scripts
โ โโโ package.json # Backend dependencies
โ โโโ tsconfig.json # TypeScript configuration
โ โโโ .env # Environment variables
โโโ docs/ # Documentation
โโโ .env.sample # Environment configuration sample
โโโ .gitignore # Git ignore rules
โโโ README.md # Project documentation
---
## ๐ Prerequisites
- **Node.js** (v18+)
- **npm** (v9+)
- **Git** (v2+)
- **Docker** & **Docker Compose**
- **MongoDB** (local or Atlas)
---
## ๐ Installation
### 1. Clone the Repository
```bash
git clone https://github.com/BaoHo205/Smart-Library-Platform.git
cd Smart-Library-Platform
First, start the Docker services for the databases:
# Navigate to backend directory
cd backend
# Start Docker services (MySQL with Flyway migrations)
docker-compose up -d
# Verify containers are running
docker-compose psThis will start:
- MySQL Server on port
6446(mapped from container port 3306) - Flyway Migration Service to set up the database schema automatically
# Install backend dependencies (if not already in backend directory)
cd backend
npm install
# Install frontend dependencies
cd ../frontend
npm installCopy the sample environment file and configure your settings:
# Copy environment sample (backend)
cd backend
cp .env.sample .env
# Edit with your actual values
nano .env # or use your preferred editorConfigure both database connections in your backend/.env file:
# Backend Configuration
PORT=5000
NODE_ENV=development
APP_NAME="Smart Library Platform Backend"
APP_VERSION=1.0.0
# MongoDB Configuration (with Connection Pool)
MONGODB_URI=mongodb+srv://username:[email protected]/?retryWrites=true&w=majority&appName=Cluster0
# Or local: mongodb://localhost:27017/library-platform
# MySQL Configuration (Dockerized Database)
MYSQL_HOST=localhost
MYSQL_PORT=6446
MYSQL_USER=root
MYSQL_PASSWORD=ftech2005
MYSQL_DATABASE=library_platform
# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key-min-32-characters-long
JWT_EXPIRE=7d
JWT_COOKIE_EXPIRE=7
# CORS Configuration
CORS_ORIGIN=http://localhost:3000,http://localhost:3001
CORS_CREDENTIALS=true# For development, you can use MongoDB Atlas (recommended)
# Update MONGODB_URI in your .env file with your Atlas connection string
# Or start MongoDB locally (if using local installation)
mongodThe MySQL database is already running in Docker from step 2. The Docker setup includes:
- MySQL Server: Running on port
6446 - Database:
library_platform(auto-created) - User:
rootwith passwordftech2005 - Flyway Migrations: Automatically applied on startup
To verify the database is working:
# Connect to the dockerized MySQL database
mysql -h localhost -P 6446 -u root -pftech2005 library_platform
# Or check tables
mysql -h localhost -P 6446 -u root -pftech2005 -e "SHOW TABLES;" library_platformStep 1: Ensure Docker services are running
cd backend
docker-compose ps # Check if containers are running
# If not running: docker-compose up -dStep 2: Start the backend server
# Terminal 1: Backend (make sure you're in backend directory)
cd backend
npm run devStep 3: Start the frontend
# Terminal 2: Frontend (in a new terminal)
cd frontend
npm run dev- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
- API Health Check: http://localhost:5000/
- MySQL Database: localhost:6446 (user: root, password: ftech2005)
When starting the backend, you should see:
๐ Starting Smart Library Platform Backend...
โ
Connected to MongoDB successfully!
โ
Connected to MySQL successfully!
๐ App: Smart Library Platform Backend
๐ Server running at http://localhost:5000
-
Staff:
Username:staff
Password:123456 -
User:
Username:user
Password:123456
Useful Docker commands:
# Check container status
docker-compose ps
# View container logs
docker-compose logs db
docker-compose logs flyway
# Stop all services
docker-compose down
# Restart services
docker-compose restart
# Stop and remove containers with volumes (โ ๏ธ This will delete data)
docker-compose down -vBackend:
npm run dev # Start development server with nodemon
npm run build # Build TypeScript to JavaScript
npm start # Start production server
npm run lint # Run ESLint
npm run lint:fix # Fix ESLint issuesFrontend:
npm run dev # Start development server (port 3000)
npm run build # Build for production
npm start # Start production server
npm run lint # Run Next.js linting
npm run lint:fix # Fix linting issuesThis project uses ESLint and Prettier for code formatting:
# Backend linting
cd backend
npm run lint
npm run lint:fix
# Frontend linting
cd frontend
npm run lint
npm run lint:fix- Create feature branch:
git checkout -b feature/your-feature-name - Make changes and commit:
git commit -m "feat: add new feature" - Push branch:
git push origin feature/your-feature-name - Create Pull Request
Follow Conventional Commits:
feat:New featuresfix:Bug fixesdocs:Documentation changesstyle:Code style changesrefactor:Code refactoringtest:Test additions or modificationschore:Maintenance tasks
# Run backend tests
cd backend
npm test
# Run frontend tests
cd frontend
npm test
# Run tests with coverage
npm run test:coverage
# Test database connections
curl http://localhost:5000/# Build backend
cd backend
npm run build
# Build frontend
cd frontend
npm run builddocker-compose up -d(in backend) โ Start databasesnpm install(in backend & frontend) โ Install dependenciescp .env.sample .env(in backend) โ Configure environment- Open two terminals:
- Terminal 1:
cd backend && npm run dev - Terminal 2:
cd frontend && npm run dev
- Terminal 1:
- Visit http://localhost:3000 for the app
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- ๐ Documentation
- ๐ฌ GitHub Issues
- ๐ง Email: [email protected]
https://jackydo2005.github.io/video_player_test/
This project is actively maintained. For feature requests and bug reports, please use the GitHub Issues page.
Made with โค๏ธ by FTECH