A small Learning Management System built with Node.js, Express, EJS, and MySQL.
This project is meant for learning how a full-stack application works with:
- routes
- views
- middleware
- database queries
- authentication
- authorization
- file uploads
- end-to-end tests
Install these before starting:
- Node.js 24 or newer
- npm
- MySQL server
From the project folder, run:
npm installCreate a .env file in the project root.
Update the database username and password if your MySQL setup is different.
Create the development database and run the schema from db/schema.sql:
npm run db:setupSeed the database with initial data:
npm run db:seedThe seed command uses the database connection from .env. It creates DB_NAME if it does not exist.
For development with auto-restart:
npm run devFor normal start:
npm startThen open:
http://localhost:3000
server.js Express app setup and server entrypoint
config/db.js MySQL connection pool
middlewares/ Auth, role, and error middleware
routes/ App routes
views/ EJS templates
public/style.css CSS
uploads/ Uploaded lesson files
db/schema.sql Database schema
scripts/db-setup.js Sets up the database schema
scripts/db-seed.js Seeds initial data
tests/e2e/ End-to-end tests
The tests use a separate database so they do not delete development data.
Create a .env.test file.
The test database name must include test. The test reset helper will refuse to run otherwise.
Create the test database:
CREATE DATABASE lms_clone_test;Run all tests:
npm testOr run the E2E suite directly:
npm run test:e2eThe E2E tests will:
- reset the test database
- seed admin, teacher, and student users
- start the Express app on a random port
- test login, logout, roles, courses, lessons, uploads, validation, and error pages
Seeded test users all use this password:
password123
Test users:
admin@example.com
teacher@example.com
student@example.com
- Do not commit
.env. - Uploaded files are ignored by git, except
uploads/.gitkeep. - Use parameterized SQL queries when adding database code.
- Keep the code simple and readable because this project is for learning.