A backend REST API for a music platform where artists can upload songs and create albums and users can browse music.
The project demonstrates authentication, validation, file upload, database relations and testing using a structured backend architecture.
- Node.js
- Express.js
- MongoDB + Mongoose
- JWT Authentication (Cookie based)
- ImageKit (Cloud Storage)
- express-validator
- Jest + Supertest
- Register user / artist
- Login with JWT cookie
- Logout
- Role-based access control
- Artist uploads music files
- Files stored on ImageKit
- Public music listing
- Artist information populated
- Artist creates album
- Multiple songs inside an album
- Fetch all albums
- Fetch album by ID with songs
- Request validation middleware
- Protected routes
- Environment variables protection
- API tested using Jest & Supertest
- External services mocked during testing
Complete_Backend
│── src
│ ├── controllers
│ ├── db
│ ├── middlewares
│ ├── models
│ ├── routes
│ ├── services
│ ├── test
│ └── app.js
│
├── server.js
├── package.json
└── README.md
git clone <your-repo-url>
cd Complete_Backend
npm install
Create .env file in root directory:
MONGODB_URI=
JWT_SECRET=
NODE_ENV=development
IMAGEKIT_PUBLIC_KEY=
IMAGEKIT_PRIVATE_KEY=
IMAGEKIT_URL_ENDPOINT=
npm run dev
Server runs at:
http://localhost:3000
npx jest
| Method | Route | Description |
|---|---|---|
| POST | /api/auth/register |
Register user |
| POST | /api/auth/login |
Login user |
| POST | /api/auth/logout |
Logout |
| Method | Route | Description |
|---|---|---|
| POST | /api/music/upload |
Upload music (artist only) |
| GET | /api/music |
Get all musics |
| Method | Route | Description |
|---|---|---|
| POST | /api/music/album |
Create album |
| GET | /api/music/album |
Get all albums |
| GET | /api/music/albums/:albumId |
Get album by ID |
| Role | Permissions |
|---|---|
| User | View musics and albums |
| Artist | Upload music and create albums |
This project demonstrates:
- REST API design
- Authentication using cookies
- Cloud file storage integration
- MongoDB relationships using populate
- Validation middleware
- Service layer architecture
- Backend API testing
This project is created for learning and portfolio use.