Skip to content

About

Backend for VibeWQuest workshop

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 VibeWQuest Workshop API

A dynamic, multi-tenant REST API built with Node.js, Express, and Firebase.

Build frontend applications without configuring a backend or database. Every student gets an isolated Firestore workspace automatically.


Table of Contents

  • Overview
  • Quick Start
  • Student Guide
  • API Reference
  • Frontend Examples
  • Error Responses
  • Admin Deployment Guide
  • Project Structure
  • Security
  • FAQ

Overview

VibeWQuest Workshop API is designed for workshops, bootcamps and hackathons.

Instead of asking every student to install Firebase or MongoDB, each student receives a unique workspace where all data is stored automatically.

Features

  • ✅ Zero backend setup
  • ✅ Automatic database provisioning
  • ✅ Multi-tenant architecture
  • ✅ Dynamic Firestore collections
  • ✅ REST API
  • ✅ Firebase Firestore
  • ✅ Render ready

⚡ One-Minute Quick Start

  1. Call /api/v1/init
  2. Save the returned studentId
  3. POST data to /api/v1/{studentId}/{collectionName}
  4. GET data from the same endpoint

That's it.


Student Guide

1. Initialize

GET https://vibewquest-be.onrender.com/api/v1/init

Response

{
  "studentId":"a1b2c3d4",
  "apiUrl":"https://vibewquest-be.onrender.com/api/v1/a1b2c3d4"
}

Save the studentId or apiUrl in localStorage.


2. Save Data

POST https://vibewquest-be.onrender.com/api/v1/{studentId}/{collectionName}
Content-Type: application/json
{
  "task":"Learn React",
  "completed":false
}

3. Retrieve Data

GET https://vibewquest-be.onrender.com/api/v1/{studentId}/{collectionName}
{
  "success":true,
  "data":[
    {
      "id":"7xYz9AbC123",
      "task":"Learn React",
      "completed":false
    }
  ]
}

4. Update Data

PUT https://vibewquest-be.onrender.com/api/v1/{studentId}/{collectionName}/{documentId}
Content-Type: application/json
{
  "completed":true
}

5. Delete Data

DELETE https://vibewquest-be.onrender.com/api/v1/{studentId}/{collectionName}/{documentId}

API Reference

Method Endpoint Description Request Body Response
GET /api/v1/init Creates a new student workspace None studentId, apiUrl
POST /api/v1/{studentId}/{collection} Creates a document Any JSON Created document
GET /api/v1/{studentId}/{collection} Retrieves all documents None Array of documents
PUT /api/v1/{studentId}/{collection}/{documentId} Updates a specific document Any JSON Success message
DELETE /api/v1/{studentId}/{collection}/{documentId} Deletes a specific document None Success message

Response Codes

Code Meaning
200 Success
201 Created
400 Bad Request
404 Collection Not Found
500 Internal Server Error

Frontend Examples

JavaScript (fetch)

Initialize

const res = await fetch("https://vibewquest-be.onrender.com/api/v1/init");
const data = await res.json();
localStorage.setItem("studentId", data.studentId);

Save

const studentId = localStorage.getItem("studentId");

await fetch(
`https://vibewquest-be.onrender.com/api/v1/${studentId}/todos`,
{
method:"POST",
headers:{
"Content-Type":"application/json"
},
body:JSON.stringify({
task:"Learn React",
completed:false
})
});

Retrieve

const studentId = localStorage.getItem("studentId");

const res = await fetch(
`https://vibewquest-be.onrender.com/api/v1/${studentId}/todos`
);

const data = await res.json();

console.log(data.data);

Axios

npm install axios
import axios from "axios";

const {data:init} = await axios.get(
"https://vibewquest-be.onrender.com/api/v1/init"
);

localStorage.setItem("studentId",init.studentId);
await axios.post(
`https://vibewquest-be.onrender.com/api/v1/${studentId}/todos`,
{
task:"Learn React",
completed:false
});
const {data}=await axios.get(
`https://vibewquest-be.onrender.com/api/v1/${studentId}/todos`
);

console.log(data.data);

React Example

import {useEffect,useState} from "react";

export default function App(){

const [todos,setTodos]=useState([]);

useEffect(()=>{

async function load(){

let studentId=localStorage.getItem("studentId");

if(!studentId){

const res=await fetch("https://vibewquest-be.onrender.com/api/v1/init");

const init=await res.json();

studentId=init.studentId;

localStorage.setItem("studentId",studentId);

}

const response=await fetch(
`https://vibewquest-be.onrender.com/api/v1/${studentId}/todos`
);

const data=await response.json();

setTodos(data.data);

}

load();

},[]);

return(
<ul>
{todos.map(todo=>(
<li key={todo.id}>{todo.task}</li>
))}
</ul>
);

}

Error Responses

{
  "success": false,
  "message": "Collection not found"
}
{
  "success": false,
  "message": "Invalid request"
}
{
  "success": false,
  "message": "Internal server error"
}

Admin Deployment Guide

Clone

git clone https://github.com/QuestIT-Cell/VibeWQuest-BE.git

cd VibeWQuest-BE

npm install

Configure Firebase

  1. Open Firebase Console
  2. Project Settings
  3. Service Accounts
  4. Generate New Private Key
  5. Rename to
serviceAccountKey.json
  1. Place inside
src/secrets/serviceAccountKey.json

Security Warning

Ensure .gitignore contains:

src/secrets/

Never commit your Firebase Admin SDK key.

Convert to Base64

node -e "console.log(require('fs').readFileSync('./src/secrets/serviceAccountKey.json').toString('base64'))"

Copy the output.

Deploy to Render

Setting Value
Runtime Node
Build Command npm install
Start Command node server.js

Environment Variable

Key Value
FIREBASE_SERVICE_ACCOUNT_BASE64 Base64 Firebase Key

Deploy.


Project Structure

.
├── src
│   ├── routes
│   ├── controllers
│   ├── middleware
│   ├── secrets
│   └── utils
├── server.js
├── package.json
└── README.md

Security

  • Never expose your Firebase Admin SDK.
  • Use environment variables in production.
  • Do not commit secrets.
  • Restrict Firestore permissions where applicable.

FAQ

Do I need Firebase?

No.

Do I need a backend?

No.

Can I create any collection?

Yes.

Is authentication required?

No.

Where should I store the student ID?

localStorage.


Made with ❤️ by QUEST IT Cell.

About

Backend for VibeWQuest workshop

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages