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 start
The 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": "[email protected]", "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.json
firestore.rules
storage.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.