Owner / Admin Only — this folder contains server-side database files.
Never expose these files to the public or commit real credentials.
| File | Purpose |
|---|---|
schema.sql |
Creates all tables in acadly_db |
seed_videos.sql |
Inserts 8 AI teaching videos |
db_config.js |
Shared MySQL pool (used by all backend routes) |
admin_middleware.js |
API-key guard that blocks public users |
admin_routes.js |
Admin-only REST endpoints (video CRUD, user info, stats) |
Download MySQL Community Server and MySQL Workbench from
https://dev.mysql.com/downloads/
During installation choose the default port 3306 and note your root password.
- Open MySQL Workbench and connect to
localhost:3306asroot. - Click File → Open SQL Script and open
DataBase/schema.sql. - Click the ⚡ Execute All button (or press
Ctrl+Shift+Enter). - Repeat with
DataBase/seed_videos.sqlto load all 8 videos.
You should now see the acadly_db database in the Schemas panel on the left.
Copy .env.example to .env in the project root and fill in your values:
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=your_mysql_root_password
DB_NAME=acadly_db
ADMIN_SECRET_KEY=pick-a-long-random-string-here
PORT=3000
Never commit
.envto git — it is already in.gitignore.
cd Backend
node setup-db.jsThis runs schema.sql + seed_videos.sql automatically and prints each step.
cd Backend
npm install
npm startThe server will print ✅ MySQL connected → database: acadly_db if everything is working.
All admin routes live at /api/admin/... and require the HTTP header:
x-admin-key: <ADMIN_SECRET_KEY from .env>
Without the header every request returns 403 Forbidden.
| Method | Path | Description |
|---|---|---|
| GET | /api/admin/stats |
Total users, videos, completions, XP |
| Method | Path | Description |
|---|---|---|
| GET | /api/admin/videos |
List all videos (including unpublished) |
| POST | /api/admin/videos |
Add a new video |
| PUT | /api/admin/videos/:id |
Update a video |
| DELETE | /api/admin/videos/:id |
Delete a video |
POST / PUT body fields:
title(string, required for POST)src(URL, required for POST)topic,description,duration,thumbnailquality(array e.g.["1080p","720p"])playback_speeds(array e.g.[0.75,1,1.25,1.5,2])is_published(0 or 1)sort_order(integer)tracks(array of subtitle objects)
| Method | Path | Description |
|---|---|---|
| GET | /api/admin/users |
List all users with XP & streak |
| GET | /api/admin/users/:id |
Single user details |
| GET | /api/admin/users/:id/progress |
All video progress for a user |
acadly_db
├── users — login credentials, role (student / admin)
├── user_profiles — bio, XP total, streak, last active date
├── videos — AI teaching video library (admin managed)
├── video_tracks — subtitles / captions per video
├── user_video_progress — per-user watch time, completion, quiz scores
└── attendance — daily check-in records for streak tracking
All tables viewable in MySQL Workbench under acadly_db → Tables.