Our project serves as a dynamic bridge, uniting individuals with non-profit organizations to create a profound societal impact through volunteering. By connecting users with events aligned to their passions, we foster a sense of purpose and collaboration, allowing interactions to extend beyond virtual boundaries. Together, we empower meaningful connections that fuel positive change, enriching communities and leaving an enduring legacy of unity and growth.
- Clone this repository.
cd
into the directory.npm install
to install the dependencies.npm start
to run the server.npm test
to run the tests.
The project follows a well-organized directory structure to promote modularity and maintainability. Here's an overview of the key directories:
โโโ src
โ โโโ app.js
โ โโโ db
โ โ โโโ connection.js
โ โ โโโ models
โ โ โโโ event.js
โ โ โโโ user.js
โ โ โโโ organization.js
โ โโโ middleware
โ โ โโโ authentication.js
โ โ โโโ authorization.js
โ โโโ routes
โ โ โโโ event.js
โ โ โโโ user.js
โ โ โโโ organization.js
โ โ โโโ index.js
โ โโโ __tests__
โ โโโ event.test.js
โ โโโ user.test.js
โ โโโ organization.test.js
โ
โโโ .env
โโโ .gitignore
โโโ package-lock.json
โโโ .lintstagedrc
โโโ package.json
For authentication purposes, JWT tokens have been used which can only access certain endpoints after being authenticated by the server. The token is generated when the user logs in and is stored in the session. The token is then sent to the server with each request and the server verifies the token before sending the response. The token is valid for 24 hours and the user has to log in again after the token expires.
For authorization purposes, the user's role is checked before sending the response. The user's role is stored in the session and is sent to the server with each request. The server checks the user's role before sending the response. If the user's role is not authorized to access the endpoint, the server sends a 401 Unauthorized or 403 Forbidden response.
Our application consists of several essential data models that define the structure of our database entities. These models serve as the foundation for creating, storing, and managing data in our platform:
- ๐งโ๐ผ Users: Represents user profiles and their related information, facilitating seamless interactions and personalized experiences.
- ๐ Events: Defines the attributes of various events, including their titles, descriptions, dates, and other relevant details.
- ๐ข Organizations: Captures information about non-profit organizations, enabling effective collaboration and partnership.
- ๐ค Administrators: Represents administrators of the platform with specialized privileges for managing users, events, and organizations.
- ๐ฐ Donation: Describes the aspects of donations, including the donors, recipients, and transaction details.
These models are meticulously crafted using Mongoose schemas and reside within the db/models
directory.
Our application features distinct routes that correspond to different entities and functionalities, allowing for efficient handling of various actions and requests:
- ๐ฅ Users: Manages user-related operations, such as registration, login, profile management, and interaction with events.
- ๐ Events: Handles event-related functionalities, including event creation, retrieval, and updates.
- ๐ข Organizations: Provides routes for non-profit organizations to manage their accounts, events, and interactions.
- ๐ Administrators: Facilitates administrative tasks, granting authorized personnel control over users, events, and organizations.
These routes are defined within the routes
directory and offer comprehensive endpoints for user-friendly interactions.
Controllers serve as the core logic of our application, orchestrating and executing various actions based on user requests. Here's an overview of the key controllers and their functionalities:
- ๐งโ๐ผ Users Controller: Manages user-related operations, enabling registration, authentication, profile updates, and event interactions.
- ๐ Events Controller: Handles event-related tasks, including event creation, retrieval, and modification.
- ๐ข Organizations Controller: Governs non-profit organizations' functionalities, facilitating account management, event creation, and updates.
- ๐ Administrators Controller: Facilitates administrative tasks, granting administrators control over users, events, and organizations.
- ๐ฐ Donation Controller: Manages donation-related actions, such as initiating donations, tracking transactions, and reporting.
These controllers, located within the controllers
directory, implement intricate business logic to ensure smooth platform operations.
Middleware functions play a crucial role in enhancing the security, authentication, and authorization aspects of our platform. They provide a structured way to handle various tasks before processing requests or granting access. Here are the middleware functions used in our project:
isAdminMiddleware
: Checks if the user is an admin.isAuthenticated
: Redirects unauthenticated users to the Swagger API documentation.authMiddleware
: Verifies JWT token for authentication and attaches the user object to the request.isOrganization
: Verifies if the authenticated user is an organization.isEventOwner
: Checks if the authenticated organization is the owner of an event.googleAuthMiddleware
: Handles Google OAuth authentication for user accounts. ๐
These middleware functions collectively ensure a secure, organized, and seamless experience for users and organizations as they interact with our platform.
Utils are utility functions that serve specific purposes and enhance the functionality of our platform. They simplify complex tasks and streamline various processes. Here are the utils used in our project:
updateExpiredEvent
: This utility function is responsible for updating expired events using a cron job that runs every 15 minutes.emailUtil
: Utilizes Nodemailer to send emails, ensuring effective communication with users and organizations.googleAuthUtil
: Implements Passport.js and Google Strategy for Google OAuth authentication, enabling secure user login and registration.
These utility functions significantly contribute to the efficiency and reliability of our platform, enabling seamless event management, email communication, and secure user authentication.
In this project we are using MongoDB database and set our models with Mongoose.
It includes a user
collection, an event
collection, a donation
collection, and a organization
collection.
We are using referenced approach to connect two collections.
The database connection is setup in db/connection.js.
API ๐
We provide our APIs under different routes such as user
, event
, donation
, organization
, and admin
.
The routes are set up in routes/index.js.
These routes allow users, organizations, and administrators to interact with the platform and perform various actions.
Jest and Supertest are utilized for testing.
As a guest, I want to be able to:
- See all events.
- Login to my account.
- See the home page.
- Create an account.
- Filter events by category, location, and date.
- Search for events.
As a user, I want to be able to:
- See all events and events I'm attending.
- Attend and unattend events.
- Update and delete my account.
- Filter events by category, location, and date.
- Search for events.
- Sign out.
As an organization, I want to be able to:
- Create and login to my account.
- Create, update, and delete events.
- See events I've created and attendees.
- Update and delete my account.
- Notify attendees about event changes.
- Filter events by category, location, and date.
- Search for events.
All environment variables required by application should be defined before running it on production or development environments. The environment variables are defined in .env file. The .env file is not included in the repository. You should create your own .env file and define the environment variables in it. To run locally you need to have environment variables defined:
- PORT
- MONGODB_URI
- JWT_SECRET
- JWT_EXPIRES_IN
- JWT_COOKIE_EXPIRES_IN
- JWT_COOKIE_SECURE
- JWT_COOKIE_HTTPONLY