Skip to content

Krishna-verma97/Complete_Backend_Learning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Complete_Backend — Music API (Node.js + Express + MongoDB)

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.


Tech Stack

  • Node.js
  • Express.js
  • MongoDB + Mongoose
  • JWT Authentication (Cookie based)
  • ImageKit (Cloud Storage)
  • express-validator
  • Jest + Supertest

Features

Authentication

  • Register user / artist
  • Login with JWT cookie
  • Logout
  • Role-based access control

Music

  • Artist uploads music files
  • Files stored on ImageKit
  • Public music listing
  • Artist information populated

Albums

  • Artist creates album
  • Multiple songs inside an album
  • Fetch all albums
  • Fetch album by ID with songs

Validation & Security

  • Request validation middleware
  • Protected routes
  • Environment variables protection

Testing

  • API tested using Jest & Supertest
  • External services mocked during testing

Project Structure

Complete_Backend
│── src
│   ├── controllers
│   ├── db
│   ├── middlewares
│   ├── models
│   ├── routes
│   ├── services
│   ├── test
│   └── app.js
│
├── server.js
├── package.json
└── README.md

Setup Instructions

1. Clone repository

git clone <your-repo-url>
cd Complete_Backend

2. Install dependencies

npm install

3. Create environment variables

Create .env file in root directory:

MONGODB_URI=
JWT_SECRET=
NODE_ENV=development

IMAGEKIT_PUBLIC_KEY=
IMAGEKIT_PRIVATE_KEY=
IMAGEKIT_URL_ENDPOINT=

4. Run server

npm run dev

Server runs at:

http://localhost:3000

Run Tests

npx jest

API Endpoints

Auth

Method Route Description
POST /api/auth/register Register user
POST /api/auth/login Login user
POST /api/auth/logout Logout

Music

Method Route Description
POST /api/music/upload Upload music (artist only)
GET /api/music Get all musics

Album

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

Roles

Role Permissions
User View musics and albums
Artist Upload music and create albums

Purpose

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

License

This project is created for learning and portfolio use.

About

RESTful Music API built with Node.js, Express and MongoDB featuring authentication, music upload, album management and cloud storage integration.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors