Skip to content

Explore the server-side powerhouse behind CivicCircle: managing a dynamic volunteer database, perfecting matchmaking algorithms, and facilitating seamless user interactions—all in one place.

License

Notifications You must be signed in to change notification settings

CodeChefs123/CivicCircle-BackEnd

Repository files navigation

CivicCircle Backend

Explore the server-side powerhouse behind CivicCircle: managing a dynamic volunteer database, perfecting matchmaking algorithms, and facilitating seamless user interactions—all in one place.

Table of Contents

Project Structure

/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

Installation

To set up the project locally, follow these steps:

  1. Clone the repository:

    git clone https://github.com/yourusername/CivicCircle-Backend.git
    cd CivicCircle-Backend
  2. Install dependencies:

    npm install
  3. 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

Configuration

Configure your Firebase credentials and other settings in the appropriate configuration files under the config directory.

Running the Server

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.

API Documentation

Authentication

All routes require authentication via a uid header. This UID should correspond to a valid user ID in your Firebase authentication system.

Volunteer Routes

Get Volunteer Profile

  • Endpoint: /volunteer/profile
  • Method: GET
  • Headers: { "uid": "user-uid" }
  • Response:
    {
      "response": {
        "name": "John Doe",
        "email": "[email protected]",
        "country": "USA",
        "skills": "JavaScript, Node.js"
      }
    }

Get Volunteer Trainings

  • 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"
        }
      ]
    }

Apply for Training

  • Endpoint: /volunteer/trainings/apply/:trainingID
  • Method: POST
  • Headers: { "uid": "user-uid" }
  • Response:
    {
      "message": "Successfully applied for training :trainingID"
    }

Get Volunteer Opportunities

  • 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"
        }
      ]
    }

Apply for Opportunity

  • Endpoint: /volunteer/opportunities/apply/:opportunityID
  • Method: POST
  • Headers: { "uid": "user-uid" }
  • Response:
    {
      "message": "Successfully applied for opportunity :opportunityID"
    }

Organization Routes

Get Organization Trainings

  • 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"
        }
      ]
    }

Create Training

  • 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!"
    }

Update Training

  • 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!"
    }

Delete Training

  • Endpoint: /organization/trainings/delete/:trainingID
  • Method: POST
  • Headers: { "uid": "org-uid" }
  • Response:
    {
      "response": "Training deleted successfully!"
    }

Get Volunteer Opportunities

  • 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"
        }
      ]
    }

Create Volunteer Opportunity

  • 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!"
    }

Middleware

Authentication middleware is used to verify the presence of a uid header and ensure that the user is authenticated.

middlewares/auth.js

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;

Utilities

Utility functions and configurations can be added to the utils directory as needed.

Firebase Rules

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

Contributing

Contributions are welcome! Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch.
  3. Make your changes.
  4. Submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Explore the server-side powerhouse behind CivicCircle: managing a dynamic volunteer database, perfecting matchmaking algorithms, and facilitating seamless user interactions—all in one place.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •