diff --git a/README.md b/README.md index c9f367b..6977056 100644 --- a/README.md +++ b/README.md @@ -1,119 +1,151 @@ -🎡Music Tracker API -A simple Node.js + SQLite3 project to manage a list of songs using RESTful APIs. Optionally includes a basic frontend to interact with the API. +# 🎡 Music Tracker API -πŸ“ Project Structure -πŸ“¦ Music Tracker API -β”œβ”€β”€ controllers/ +A simple yet powerful RESTful API built with **Node.js** and **SQLite** that lets users manage a list of songs. It supports adding, retrieving, and storing songs locally, with an optional frontend for browser-based interaction. + +## πŸ“ Project Structure + +``` +MusicTrackerAPI/ +β”œβ”€β”€ controllers/ # Contains logic to handle API requests β”‚ └── songController.js -β”œβ”€β”€ routes/ +β”œβ”€β”€ routes/ # Defines API endpoints and routing β”‚ └── songRoutes.js -β”œβ”€β”€ db.js -β”œβ”€β”€ music.db -β”œβ”€β”€ server.js -β”œβ”€β”€ MusicAPI.html (optional frontend) -└── README.md - -πŸ“Œ Features -βœ… Create, Read songs using API -βœ… Local database using SQLite -βœ… Integrated with DB Browser for SQLite -βœ… HTML frontend (optional) -βœ… Fully local setup β€” no external APIs used - -πŸš€ How to Run This Project -1. πŸ“₯ Clone the Repository - bash - git clone https://github.com/your-username/music-tracker-api.git - cd music-tracker-api - -2. πŸ“¦ Install Dependencies - Make sure you have Node.js installed, then: - bash - npm install - -3. βœ… Start the Server - bash - node server.js - The server will start at: - http://localhost:5000 - -🧠 API Endpoints -GET /api/songs -Returns all songs in the database. -Response: -json +β”œβ”€β”€ music.db # SQLite database file +β”œβ”€β”€ db.js # Database connection and setup +β”œβ”€β”€ server.js # Main server file to run the API +β”œβ”€β”€ MusicAPI.html # Optional HTML frontend for testing API +└── README.md # Project documentation +``` +## πŸš€ Features - { - "id": 1, - "title": "Test Song", - "artist": "Tester", - "genre": "Rock" - } +- 🎧 Add and retrieve songs using REST APIs +- πŸ—ƒοΈ Local database using **SQLite** +- πŸ“Š Easy integration with **DB Browser for SQLite** +- 🌐 Optional HTML frontend to view/add songs via a form +- πŸ”’ Fully local β€” no external APIs or cloud services + +## βš™οΈ Getting Started + +### 1. Clone the Repository + +```bash + git clone https://github.com/Ananya-te/MusicTrackerAPI.git + cd MusicTrackerAPI +``` + +###2. Install Dependencies + +Ensure you have Node.js installed, then run: +```bash + +npm install +``` + +###3. Start the Server +```bash +node server.js + +The server will start at: http://localhost:5000 +``` + + +## πŸ”Œ API Endpoints + +πŸ“₯ Add a Song +```bash POST /api/songs -Adds a new song to the database. +``` + Request Body: -json +```bash +Json + { "title": "Shape of You", "artist": "Ed Sheeran", "genre": "Pop" } +``` -Response: +πŸ“€ Get All Songs +```bash +GET /api/songs +``` + +## Response: +```bash json -{ - "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) +[ + { + "id": 1, + "title": "Shape of You", + "artist": "Ed Sheeran", + "genre": "Pop" + } +] +``` + + +## πŸ§ͺ Database Schema +```bash +SQL -🎼 Table Schema: -sql CREATE TABLE IF NOT EXISTS songs ( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, artist TEXT, genre TEXT ); +``` + +Managed with: db.js + +Uses local file: music.db + +Tables are created automatically on server start + + +## 🌐 Optional Frontend Usage + +Open MusicAPI.html in your browser to: + +1. View all songs in a list + +2. Add songs via a simple form + +Make sure your server is running before using the frontend. + + +## πŸ› οΈ Tech Stack + +> Node.js + +> Express.js + +> SQLite3 + +> HTML, CSS, JavaScript for UI + + +## 🀝 Contributing + +We welcome contributions! πŸ’› + +1. Fork this repo + +2. Create a new branch: feature/your-feature-name + +3. Make your changes and commit + +4. Open a Pull Request with a meaningful description -🌐 Frontend -You can open the MusicAPI.html file directly in your browser: -πŸ”— Features: - 1.Add a song using a form - 2.View all songs in a list -To use: - 1.Make sure the server is running. - 2.Double-click MusicAPI.html to open it in your browser. - 3.Fill in the form and click β€œAdd Song”. - -πŸ“¬ Sample curl Requests -Add a Song: -bash -curl -X POST http://localhost:5000/api/songs \ - -H "Content-Type: application/json" \ - -d "{\"title\":\"Test Song\", \"artist\":\"Tester\", \"genre\":\"Rock\"}" - -Get All Songs: -bash -curl http://localhost:5000/api/songs - -πŸ›  Built With -1.Node.js -2.Express.js -3.SQLite3 -4.[HTML/CSS/JS] for frontend - -πŸ“„ License -This project is open-source and free to use. Feel free to fork and modify for learning or improvement! +## License +This project is open-source and free to use, modify, or improve. +Let's build something awesome! πŸš€