Skip to content

sncey/Hazy-Ripples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Hazy Ripples Project ๐Ÿ‘จโ€๐Ÿ’ป

Description ๐Ÿ“

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.

Setup

  1. Clone this repository.
  2. cd into the directory.
  3. npm install to install the dependencies.
  4. npm start to run the server.
  5. npm test to run the tests.

Structure ๐Ÿ—๏ธ

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

Authentication ๐Ÿ”

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.

Authorization ๐Ÿ”‘

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.

Models ๐Ÿ›๏ธ

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.

Routes ๐Ÿ›ค๏ธ

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 ๐ŸŽฎ

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 โš™๏ธ

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 ๐Ÿ› ๏ธ

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.

Database ๐Ÿ“Š

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.

Tests ๐Ÿงช

Jest and Supertest are utilized for testing.

Guest Stories ๐Ÿ“–

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.

User Stories ๐Ÿ‘ฅ

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.

Organization Stories ๐Ÿข

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.

Technologies Used ๐Ÿ› ๏ธ

  • Node.js
  • Express
  • MongoDB
  • Mongoose
  • Jest
  • Supertest
  • Bcrypt
  • Jsonwebtoken
  • Dotenv
  • Nodemon
  • Morgan
  • Nodemailer
  • Passport.js
  • Nodemailer
  • Cron Job
  • Stripe

Environment Variables ๐ŸŒ

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

Authors ๐Ÿ‘ฅ