Explore the server-side powerhouse behind CivicCircle: managing a dynamic volunteer database, perfecting matchmaking algorithms, and facilitating seamless user interactionsβall in one place.
- CivicCircle Backend
/home/ranuga/Programming/Projects/All/CivicCircle/BackEnd/
βββ .history
βββ config
βββ firebase
βββ handlers
βββ middlewares
βββ models
β βββ admin
β βββ home
β βββ organization
βββ node_modules
βββ path
βββ routes
βββ utils
βββ .deepsource.toml
βββ .firebaserc
βββ .gcloudignore
βββ .gitignore
βββ app.yaml
βββ database.rules.json
βββ firebase.json
βββ firestore.indexes.json
βββ firestore.rules
βββ index.js
βββ LICENSE
βββ package-lock.json
βββ package.json
βββ README.md
βββ storage.rules
βββ structure.txt
To set up the project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/yourusername/CivicCircle-Backend.git cd CivicCircle-Backend -
Install dependencies:
npm install
-
Set up Firebase: Make sure you have Firebase CLI installed and configured. You can log in and configure Firebase using the following commands:
firebase login firebase init
Configure your Firebase credentials and other settings in the appropriate configuration files under the config directory.
To start the Express server, run:
npm startThe server will run on the default port 3000. You can access the API at http://localhost:3000.
All routes require authentication via a uid header. This UID should correspond to a valid user ID in your Firebase authentication system.
- Endpoint:
/volunteer/profile - Method:
GET - Headers:
{ "uid": "user-uid" } - Response:
{ "response": { "name": "John Doe", "email": "john@example.com", "country": "USA", "skills": "JavaScript, Node.js" } }
- Endpoint:
/volunteer/trainings - Method:
GET - Headers:
{ "uid": "user-uid" } - Response:
{ "response": [ { "id": "1", "title": "Web Development", "description": "Learn HTML, CSS, and JavaScript", "level": "Beginner", "skillsCovered": "HTML, CSS, JavaScript" } ] }
- Endpoint:
/volunteer/trainings/apply/:trainingID - Method:
POST - Headers:
{ "uid": "user-uid" } - Response:
{ "message": "Successfully applied for training :trainingID" }
- Endpoint:
/volunteer/opportunities - Method:
GET - Headers:
{ "uid": "user-uid" } - Response:
{ "response": [ { "id": "1", "name": "Volunteer at Local Shelter", "description": "Help with daily tasks", "country": "USA", "applicants": 10, "employees": 5, "skillsCovered": "Organization, Teamwork" } ] }
- Endpoint:
/volunteer/opportunities/apply/:opportunityID - Method:
POST - Headers:
{ "uid": "user-uid" } - Response:
{ "message": "Successfully applied for opportunity :opportunityID" }
- Endpoint:
/organization/trainings - Method:
GET - Headers:
{ "uid": "org-uid" } - Response:
{ "response": [ { "id": "1", "title": "Web Development", "description": "Learn HTML, CSS, and JavaScript", "level": "Beginner", "skillsCovered": "HTML, CSS, JavaScript" } ] }
- Endpoint:
/organization/trainings/create - Method:
POST - Headers:
{ "uid": "org-uid" } - Body:
{ "title": "Web Development", "description": "Learn HTML, CSS, and JavaScript", "level": "Beginner", "skillsCovered": "HTML, CSS, JavaScript" } - Response:
{ "response": "Training created successfully!" }
- Endpoint:
/organization/trainings/update/:trainingID - Method:
POST - Headers:
{ "uid": "org-uid" } - Body:
{ "title": "Advanced Web Development", "description": "Learn advanced topics in web development", "level": "Advanced", "skillsCovered": "React, Node.js" } - Response:
{ "response": "Training updated successfully!" }
- Endpoint:
/organization/trainings/delete/:trainingID - Method:
POST - Headers:
{ "uid": "org-uid" } - Response:
{ "response": "Training deleted successfully!" }
- Endpoint:
/organization/volunteers - Method:
GET - Headers:
{ "uid": "org-uid" } - Response:
{ "response": [ { "id": "1", "name": "Volunteer at Local Shelter", "description": "Help with daily tasks", "country": "USA", "applicants": 10, "employees": 5, "skillsCovered": "Organization, Teamwork" } ] }
- Endpoint:
/organization/volunteers - Method:
POST - Headers:
{ "uid": "org-uid" } - Body:
{ "name": "Volunteer at Local Shelter", "description": "Help with daily tasks", "country": "USA", "applicants": 10, "employees": 5, "skillsCovered": "Organization, Teamwork" } - Response:
{ "response": "Volunteer opportunity created successfully!" }
Authentication middleware is used to verify the presence of a uid header and ensure that the user is authenticated.
const authMiddleware = (req, res, next) => {
const uid = req.headers["uid"];
if (!uid) {
return res.status(401).json({ message: "Unauthorized: No UID provided" });
}
req.uid = uid;
next();
};
module.exports = authMiddleware;Utility functions and configurations can be added to the utils directory as needed.
Firebase rules are defined to ensure data security and integrity. You can find the rules in the following files:
database.rules.jsonfirestore.rulesstorage.rules
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch.
- Make your changes.
- Submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.