Skip to content

Latest commit

Β 

History

History
149 lines (123 loc) Β· 3.81 KB

File metadata and controls

149 lines (123 loc) Β· 3.81 KB

🎡Music Tracker API

A local RESTful API which is made by using Node.js, Express.js and SQLite3 that allows users to manage a list of songs and playlists. We can perform tasks like creating,viewing and playing a song, as well as creating, viewing and running a playlist. Optionally includes a basic frontend to interact with the API.

πŸ“ Project Structure

πŸ“ MusicTrackerAPI
β”œβ”€β”€ _tests/
β”‚ β”œβ”€β”€ api/
β”‚ β”œβ”€β”€ integration/
β”‚ └── unit/
β”œβ”€β”€ controllers/
β”‚ └── songController.js
β”œβ”€β”€ routes/
β”‚ └── songRoutes.js
β”œβ”€β”€ music.db
β”œβ”€β”€ db.js
β”œβ”€β”€ server.js
β”œβ”€β”€ MusicAPI.html
β”œβ”€β”€ package.json
β”œβ”€β”€ coverage/
β”œβ”€β”€ .github/workflows/
β”œβ”€β”€ appss.png
β”œβ”€β”€ appss2.png
└── README.md

πŸ“Œ Features

βœ… Create, view and play songs and playlists using API
βœ… Local database using SQLite3
βœ… Integrated with DB Browser for SQLite3
βœ… HTML frontend (optional)
βœ… Backend using Node.js and Express.js
βœ… Fully local setup β€” no external APIs used

πŸš€ How to Run This Project

  1. πŸ“₯ Clone the Repository git clone https://github.com/your-username/music-tracker-api.git
    cd music-tracker-api

  2. πŸ“¦ Install Dependencies Node.js (v14 or above)
    β†’ Required to run the backend server.
    npm (Node Package Manager)
    npm install
    β†’ Comes with Node.js. Used to install project dependencies.

  3. βœ… Start the Server
    Run this command :
    node server.js
    The server will start at:
    http://localhost:5000

🧠 API Endpoints

GET /api/songs
Returns all songs in the database.
Response:

  {
    "id": 1,
    "title": "Test Song",
    "artist": "Tester",
    "genre": "Rock"
  }

POST /api/songs
Adds a new song to the database.
Request Body:

{
  "title": "Shape of You",
  "artist": "Ed Sheeran",
  "genre": "Pop"
}

Response:

{
  "id": 2,
  "title": "Shape of You",
  "artist": "Ed Sheeran",
  "genre": "Pop"
}

πŸ—ƒοΈ Database Used

πŸ“Œ SQLite Database File: music.db
πŸŽ›οΈ Managed Using: DB Browser for SQLite
πŸ› οΈ Tables are auto-created on server start (via db.js)

🎼 Table Schema:

CREATE TABLE IF NOT EXISTS songs (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  title TEXT,
  artist TEXT,
  genre TEXT
);

🌐 Frontend

You can easily run the frontend by opening the MusicAPI.html file in your browser.
πŸ”§ Features:
🎡 Add a song using a simple form
πŸ“‹ View all added songs in a list

πŸš€ How to Use:

Make sure your server is running (node server.js)
Double-click on MusicAPI.html to open it in your browser
Fill out the form and hit β€œAdd Song” to submit 🎢

Sample curl Requests

  • 🎡 Add a New Song
Copy
Edit
curl -X POST http://localhost:5000/api/songs \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Test Song",
    "artist": "Tester",
    "genre": "Rock"
  }'
  • Get All Songs:
curl http://localhost:5000/api/songs

πŸ› οΈ Built With

  • 🟩 Node.js – For backend JavaScript runtime
  • πŸš‚ Express.js – Web framework to handle routes and APIs
  • πŸ—ƒ SQLite3 – Lightweight database for storage
  • 🌐 HTML/CSS/JavaScript – To power the frontend UI

πŸ“„ License

This project is open-source and free to use!
Feel free to fork it, play around, or even use it to build something cooler.
Just don’t forget to give credit if you’re vibing with it πŸ’«