Skip to content

Commit

Permalink
Merge branch 'main' into E2E-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jhagendoornCP authored Jun 5, 2024
2 parents 8985f3e + 8dfc514 commit f1e1916
Show file tree
Hide file tree
Showing 44 changed files with 853 additions and 303 deletions.
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
# Gather
## Gather ( NOT SURE WHICH ONE OF THESE DESCRIPTIONS WE PREFER )

Just a cool little inventory project.
Gather is for individuals who need a way to keep track of items when planning large events like a party or family gathering, moving to a new house, or going on a trip. Gather is a digital inventory management website that helps maintain, share, and organize multiple people’s items. Unlike traditional inventory management sites and check-off list tools that are designed for either an individual or a larger corporation, our product is made for both individuals and small groups of friends and family making it more friendly and easier to collaborate and communicate who has what items through integrated group functionalities.

## Overview
To allow students to keep track of their items after moving to college and organize the purchasing of items with their roommates!

Hi guys fixing my stuff.
## UI Prototype ( MIGHT NOT BE SHARED WITH ZIELKE??? )

### Purpose
https://www.figma.com/design/I5uSIz4KLxSyf4NDAFPLNC/Gather?node-id=40-177&t=qQE31y83u1B30ge8-0

To allow students to keep track of their items after moving to college and organize the purchasing of items with their roommates!
## Dev environment setup

1. Clone the remote repository onto local machine
2. Run npm i or npm install
3. To run workspaces:
a) To run frontend: npm run front
b) To run backend: npm run back
c) To run test suite: npm run cyp

## UML Diagram

Create a wikipage (.md file) on your GitHub repository for the UML Class Diagram you have produced. Include the date the diagrams were last updated. Link to this page from your project README file. Also, push the source files of your diagram to the repo. I suggest you create a docs folder for the sake of organization.

### Team

The Target Share team consists of 5 Cal Poly students. Over the course of about a month, we worked as a team to deploy this web application. The team members are listed below:
The gather team consists of 5 Cal Poly students. Over the course of about a month, we worked as a team to deploy this web application. The team members are listed below:

- [Jason Jelincic](https://www.linkedin.com/in/jasonjelincic/) - Software Developer
- [Zach Mattes](https://www.linkedin.com/in/zachmattes/) - Software Developer / Target guy!
- [Zach Mattes](https://www.linkedin.com/in/zachmattes/) - Software Developer
- [Pallavi Das](https://www.linkedin.com/in/palldas/) - Software Developer
- [Jonathan Hagendoorn](https://www.linkedin.com/in/jonathan-t-hagendoorn/) - Software Developer
- [Sofija Dimitrijevic](https://www.linkedin.com/in/sofija-dimitrijevic-903920255/) - Software Developer
3 changes: 3 additions & 0 deletions backend/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dotenv.config();
type User = { username: string; hashedPassword: string };
const creds = [User]; // username, hashedPassword

// Middleware to authenticate user using JWT
export function authenticateUser(req: Request, res: Response, next: any) {
const authHeader = req.headers["authorization"];
//Getting the 2nd part of the auth header (the token)
Expand All @@ -34,6 +35,7 @@ export function authenticateUser(req: Request, res: Response, next: any) {
}
}

// Controller function to handle user login
export const loginUser = async (req: Request, res: Response) => {
connectDB();
const { username, password } = req.body; // from form
Expand Down Expand Up @@ -71,6 +73,7 @@ export const loginUser = async (req: Request, res: Response) => {
}
};

// Function to generate a JWT access token
function generateAccessToken(username: any) {
return new Promise((resolve, reject) => {
jwt.sign(
Expand Down
11 changes: 7 additions & 4 deletions backend/models/basketSchema.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import mongoose, { Schema } from "mongoose";

// Defining the type for a basket object, specifying structure of basket data.
export type IBasket = {
_id: Schema.Types.ObjectId;
_id: Schema.Types.ObjectId; // Unique identifier for the basket, using MongoDB ObjectId.
basketName: string;
description: string;
members: Schema.Types.ObjectId[];
items: Schema.Types.ObjectId[];
created: Date;
members: Schema.Types.ObjectId[]; // Array of ObjectIds referencing the members of the basket.
items: Schema.Types.ObjectId[]; // Array of ObjectIds referencing the items of the basket.
created: Date; // Timestamp for when the basket was creaed
};

// Defining the data types and requirements for each field in our basket schema
const BasketSchema = new Schema<IBasket>({
basketName: { type: String, required: true },
description: { type: String, required: true },
Expand All @@ -17,6 +19,7 @@ const BasketSchema = new Schema<IBasket>({
created: { type: Date, required: true, default: Date.now },
});

// Create a model for the basket schema, using the existing "basket" model if it exists, otherwise creating a new one.
const Basket =
mongoose.models["basket"] || mongoose.model("basket", BasketSchema);

Expand Down
7 changes: 5 additions & 2 deletions backend/models/groupSchema.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import mongoose, { Schema } from "mongoose";

// Defining the type for a group object, specifying structure of group data.
export type IGroup = {
_id: Schema.Types.ObjectId;
groupName: string;
privateGroup: boolean;
description: string;
members: Schema.Types.ObjectId[];
baskets: Schema.Types.ObjectId[];
members: Schema.Types.ObjectId[]; // Array of ObjectIds referencing the members of the group.
baskets: Schema.Types.ObjectId[]; // Array of ObjectIds referencing the baskets of the group.
created: Date;
};

// Defining the data types and requirements for each field in our group schema
const GroupSchema = new Schema<IGroup>({
groupName: { type: String, required: true },
privateGroup: { type: Boolean, required: true },
Expand All @@ -19,6 +21,7 @@ const GroupSchema = new Schema<IGroup>({
created: { type: Date, required: true, default: Date.now },
});

// Create a model for the group schema, using the existing "group" model if it exists, otherwise creating a new one.
const Group =
mongoose.models["groups"] || mongoose.model("groups", GroupSchema);

Expand Down
10 changes: 6 additions & 4 deletions backend/models/itemSchema.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import mongoose, { Schema } from "mongoose";

// Defining the type for an item object, specifying the structure of the item data.
export type IItem = {
_id: Schema.Types.ObjectId;
name: string;
toShare: boolean;
isPrivate: boolean;
type: string;
basket: Schema.Types.ObjectId;
basket: Schema.Types.ObjectId; // ObjectId referencing the basket to which the item belongs.
notes: string;
price: number;
quantity: number;
created: Date;
lastModified: Date;
created: Date; // Timestamp for when the item was created.
lastModified: Date; // Timestamp for when the item was last modified.
};

// Mongoose schema
// Defining the data types and requirements for each field in our item schema.
const itemSchema = new Schema({
name: { type: String, required: true },
toShare: { type: Boolean, required: true },
Expand All @@ -28,6 +29,7 @@ const itemSchema = new Schema({
lastModified: { type: Date, required: true, default: Date.now },
});

// Create a model for the item schema, using the existing "items" model if it exists, otherwise creating a new one.
const Event = mongoose.models["items"] || mongoose.model("items", itemSchema);

export default Event;
6 changes: 3 additions & 3 deletions backend/models/userSchema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import mongoose, { Schema } from "mongoose";

// Defining the type for a user object, specifying the structure of the user data.
export type IUser = {
_id: Schema.Types.ObjectId;
username: string;
Expand All @@ -13,9 +14,7 @@ export type IUser = {
joined: Date;
};

//groupId and digitalWaiver seem to require a schema
//currently there is no schema for them so I am leaving them as null for now
//can groupId just be a string and digitalWaiver be a boolean?
// Defining the data types and requirements for each field in our user schema.
const UserSchema = new Schema<IUser>({
username: { type: String, required: true },
email: { type: String, required: true },
Expand All @@ -28,6 +27,7 @@ const UserSchema = new Schema<IUser>({
joined: { type: Date, required: true, default: Date.now },
});

// Create a model for the user schema, using the existing "users" model if it exists, otherwise creating a new one.
const User = mongoose.models["users"] || mongoose.model("users", UserSchema);

export default User;
15 changes: 8 additions & 7 deletions backend/routes/basketRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { authenticateUser } from "../auth.js";

const router = express.Router();

// Route to get all baskets
router.get("/", authenticateUser, async (req: Request, res: Response) => {
connectDB();
try {
Expand All @@ -20,6 +21,7 @@ router.get("/", authenticateUser, async (req: Request, res: Response) => {
}
});

// Route to get a specific basket by ID or name
router.get(
"/:basketid",
authenticateUser,
Expand Down Expand Up @@ -56,23 +58,19 @@ router.get(
},
);

// Route to create a new basket
router.post("/", authenticateUser, async (req: Request, res: Response) => {
connectDB();
try {
console.log("Creating a new basket with data:", req.body);
//Create new basket to add
// Create new basket to add
const { basketName, description, members, items } = req.body;
if (!basketName || !description) {
console.error("Missing required fields", req.body);
return res.status(400).send("Missing required fields");
}

const basketToAdd = new Basket({
basketName,
description,
members,
items,
});
const basketToAdd = new Basket({ basketName, description, members, items });

const newBasket = await basketToAdd.save();
console.log("New basket created:", newBasket);
Expand All @@ -83,6 +81,7 @@ router.post("/", authenticateUser, async (req: Request, res: Response) => {
}
});

// Route to update a basket by ID
router.patch("/:id", authenticateUser, async (req: Request, res: Response) => {
// Get basket ID from URL
const { id } = req.params;
Expand All @@ -106,6 +105,7 @@ router.patch("/:id", authenticateUser, async (req: Request, res: Response) => {
}
});

// Route to remove an item from a basket
router.patch(
"/:bid/removeitem",
authenticateUser,
Expand Down Expand Up @@ -135,6 +135,7 @@ router.patch(
},
);

// Route to delete a basket by ID
router.delete("/:id", authenticateUser, async (req: Request, res: Response) => {
connectDB();
const { id } = req.params;
Expand Down
8 changes: 5 additions & 3 deletions backend/routes/groupRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import connectDB from "../connection.js";

const router = express.Router();

// Route to get all groups
router.get("/", authenticateUser, async (req: Request, res: Response) => {
connectDB();
try {
Expand All @@ -20,6 +21,7 @@ router.get("/", authenticateUser, async (req: Request, res: Response) => {
}
});

// Route to get a specific group by ID or name
router.get(
"/:groupid",
authenticateUser,
Expand Down Expand Up @@ -61,15 +63,13 @@ router.get(
},
);

// Route to create a new group
router.post("/", authenticateUser, async (req: Request, res: Response) => {
connectDB();
try {
console.log("Creating a new group with data:", req.body);
//Create new group to add
const { groupName, privateGroup, description, members, baskets } = req.body;
//*assuming groupname and privateGroup is required fields need to add a default description ("No description given") etc.
//*ALSO do we want the baskets to be a list of baskets or just one basket (what we have) something to think
//about because arent there going to be multiple baskets per group
if (!groupName || privateGroup == null || !description) {
console.error("Missing required fields", req.body);
return res.status(400).send("Missing required fields");
Expand All @@ -92,6 +92,7 @@ router.post("/", authenticateUser, async (req: Request, res: Response) => {
}
});

// Route to update a group by ID
router.patch("/:id", authenticateUser, async (req: Request, res: Response) => {
// Get user ID from URL
const { id } = req.params;
Expand All @@ -115,6 +116,7 @@ router.patch("/:id", authenticateUser, async (req: Request, res: Response) => {
}
});

// Route to delete a group by ID
router.delete("/:id", authenticateUser, async (req: Request, res: Response) => {
connectDB();
const { id } = req.params;
Expand Down
5 changes: 5 additions & 0 deletions backend/routes/itemRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import connectDB from "../connection.js";

const router = express.Router();

// Route to get all items
router.get("/", authenticateUser, async (req: Request, res: Response) => {
connectDB();
try {
Expand All @@ -20,6 +21,7 @@ router.get("/", authenticateUser, async (req: Request, res: Response) => {
}
});

// Route to get a specific item by ID or name
router.get(
"/:itemid",
authenticateUser,
Expand Down Expand Up @@ -57,6 +59,7 @@ router.get(
},
);

// Route to create a new item
router.post("/", authenticateUser, async (req: Request, res: Response) => {
connectDB();
try {
Expand Down Expand Up @@ -95,6 +98,7 @@ router.post("/", authenticateUser, async (req: Request, res: Response) => {
}
});

// Route to update an item by ID
router.patch("/:id", authenticateUser, async (req: Request, res: Response) => {
// Get user ID from URL
const { id } = req.params;
Expand All @@ -118,6 +122,7 @@ router.patch("/:id", authenticateUser, async (req: Request, res: Response) => {
}
});

// Route to delete an item by ID
router.delete("/:id", authenticateUser, async (req: Request, res: Response) => {
connectDB();
const { id } = req.params;
Expand Down
Loading

0 comments on commit f1e1916

Please sign in to comment.