Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

86 changes: 74 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,15 @@ StressLess/

### Installation

1. Clone the repository:
1. Clone the repository if you have read/write access:

```bash
git clone https://github.com/trappaly/StressLess
git clone git@github.com:StressLess-Team/StressLess.git
cd StressLess
```

If you do not have read/write access to this repository but you want to contribute to **StressLess**, please see [Contributing Guidelines](docs/dev%20docs/contributing.md) for instructions on forking and making pull requests. You can keep following the steps below to set up your local environment. **In order for your forked repo's GitHub actions to run correctly, you have to enter every environment variables into GitHub secrets in Settings.** You should also get your deploy services secrets and put them into GitHub secrets for the `deploy.yml` action file to run.

### Setting Environment Variables (Please contact a team member for the three .env files)
In the `backend` directory, create a `.env` file and add the following variables:

Expand Down Expand Up @@ -197,11 +199,22 @@ NEXT_PUBLIC_FIREBASE_APP_ID=<get-from-firebase>
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=<get-from-firebase>
```

**Note:**
After Spring 2025 grades are released by Grinnell College, the availability of database credentials used for our development cannot be guaranteed.
The availability of Firebase credentials cannot be guaranteed as well.
Therefore, after grades are released, team members may be unable to provide `.env` files.
You may need to provide your own PostgreSQL database and Firebase credentials after this point.

### Setting Other Secrets
The file `backend/serviceAccountKey.json` is the Firebase service account key JSON.
An example is provided. This file is used to authenticate with Firebase services.
Ask a team member for the content of this file.

**Note:**
After Spring 2025 grades are released by Grinnell College, the availability of Firebase credentials used for our development cannot be guaranteed.
Therefore, after grades are released, team members may be unable to provide the `serviceAccountKey.json` file.
You may need to provide your own Firebase credentials after this point.

### Installing Dependencies

At root level, run:
Expand All @@ -212,20 +225,63 @@ pnpm install

This will install 3 workspaces, because we have specified so in [pnpm-workspace.yaml](pnpm-workspace.yaml). This will install the dependencies for the backend and frontend. Alternatively, you can go into each directory and run `pnpm install` separately.

### Setting Up the Database
### Initial Database and Prisma Setup

How to set up the database will depend on whether the database services used for our development are still available:
- Before Spring 2025 grades are released, you may ask a team member for credentials.
- This way, graders may use the team's credentials for grading purposes.
- After grades are released, please provide your own PostgreSQL database and Firebase credentials.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added descriptions on setting up database


Please consult the sections [Setting Environment Variables](#setting-environment-variables-please-contact-a-team-member-for-the-three-env-files) and [Setting Other Secrets](#setting-other-secrets) for more details on how to configure database and Firebase credentials.

#### Option A. Before Spring 2025 grades are released (for grading purposes):

##### Getting Onboard with Neon (Our Database)
1. Optional: Ask Madel to add you to the StressLess Neon database. (Optional: For testing, you can use ThunderClient, which you can easily download on VSCode under Extensions.)
2. Make sure your `.env` and `.test.env` files in the backend are good. See [Setting Environment Variables](#setting-environment-variables-please-contact-a-team-member-for-the-three-env-files) and [Setting Other Secrets](#setting-other-secrets) for more details. You may contact a team member for the content of these files.


##### Installing Prisma Client (Tool Used to Access Our Database Neon)

```bash
cd backend
pnpm exec prisma generate
```

For more information on how to use **Prisma** after initial setup, check out [Prisma Guide](./docs/dev%20docs/database/Prisma.md)

You may proceed to the section [Development](#development).

### Getting Onboard with Neon (Our Database)
1. Ask Madel to add you to the StressLess Neon database. (Optional: For testing, you can use ThunderClient, which you can easily download on VSCode under Extensions.)
2. Make sure your .env file in the backend is good.
#### Option B. After Spring 2025 grades are released:

### Installing Prisma Client (Tool Used to Access Our Database Neon)
##### Setting Up A Database
1. Please provide **two** PostgreSQL databases on your own (one for development and one for automated testing)
2. Make sure your `.env` and `.test.env` files in the backend are good. See [Setting Environment Variables](#setting-environment-variables-please-contact-a-team-member-for-the-three-env-files) and [Setting Other Secrets](#setting-other-secrets) for more details.

##### Installing Prisma Client (Tool Used to Access Your Database)

```bash
cd backend
pnpm exec prisma generate
```

For more information on **Prisma**, check out [Prisma Guide](./docs/dev%20docs/database/Prisma.md)
##### Adding The Schema to Your Database
Ensure that the two databases are empty.
Ensure you are in the `backend` directory (which you should be if you completed the previous step).

**To add the schema to the development database:**
```bash
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instructions on how to add scheme to database

pnpm exec prisma migrate dev
```

**To add the schema to the automated testing database:**
```bash
pnpm exec env-cmd -f ./.test.env prisma migrate dev
```

For more information on how to use **Prisma** after initial setup, check out [Prisma Guide](./docs/dev%20docs/database/Prisma.md)

You may proceed to the section [Development](#development).

### Development

Expand Down Expand Up @@ -289,11 +345,11 @@ pnpm lint

## Docker

## Install Docker Desktop for your OS.
### Install Docker Desktop for your OS.

https://docs.docker.com/get-started/get-docker/

## Access the application by running
### Access the application by running

Open Docker Desktop. Then run in the command line at root level:

Expand All @@ -314,8 +370,8 @@ For more information, see the [Docker Guide](docs/dev%20docs/docker-guide.md).
- [x] Milestone 7 - Release 1 and demo
- [x] Milestone 8 - Documentation
- [x] Milestone 9 - Code Review and demo
- [ ] Milestone 10 - Bug logging
- [ ] Milestone 11 - Final Presentation
- [x] Milestone 10 - Bug logging
- [x] Milestone 11 - Final Presentation
- [ ] Milestone 12 - Final Release

## Authors
Expand All @@ -329,4 +385,10 @@ For more information, see the [Docker Guide](docs/dev%20docs/docker-guide.md).

## Acknowledgments

We would like to thank Professor Leah Perlmutter and our class mentor Elliot Swaim for their guidance and support throughout this project.

We would like to thank all of our stakeholders who gave us useful feedback to help us improve our app. We want to thank [this YouTube tutorial](https://youtu.be/VrC5XhjW6W0?si=_ibhdo7doCMXNtB3) for helping us implement our frontend calendar.

Finally, we would also like to thank all of our amazing teammates for all of their hard work, dedication, and creativity for making this project possible.

<a href="#readme-top">back to top</a>
60 changes: 60 additions & 0 deletions backend/src/controllers/AuthController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,64 @@ export default class AuthController {
return res.status(500).json({ error: 'Something went wrong' });
}
};

/**
* Delete account should delete all data entry with user_id matched
* @param req
* @param res
* @constructor
*/
public static async deleteAccount(req: Request, res: Response): Promise<any> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleting account by deleting all of the users preferences from the database

try {
const user_id = req.params.user_id;
const user = await prisma.users.findUniqueOrThrow({
where: {
id: user_id,
},
});

if (!user) {
return res.status(404).json({ error: 'User not found' });
}

// Delete their preferences
await prisma.user_preferences.deleteMany({
where: {
user_id: user_id,
},
});

// Delete their events
await prisma.user_events.deleteMany({
where: {
user_id: user_id,
},
});

// Delete their deadlines
await prisma.user_deadlines.deleteMany({
where: {
user_id: user_id,
},
});

// Delete the user instance
await prisma.users.deleteMany({
where: {
id: user_id,
}
});

return res.status(201).json({
user: {
id: user.id,
email: user.email,
},
message: 'Deleted account successfully',
});
} catch (error: any) {
console.error('Sign-in Error:', error);
return res.status(500).json({ error: error.message });
}
}
}
16 changes: 8 additions & 8 deletions backend/src/controllers/DeadlineController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export default class Deadline {
*/
public static async getUserDeadlines(req: Request, res: Response) {
try {
// Finds all of the possible deadlines for each user
// Finds all the possible deadlines for each user
const userDeadlines = await prisma.user_deadlines.findMany({
where: {
user_id: req.params.user_id,
},
});
// Succuesfully is able to get all of the user's deadlines
// Successfully is able to get all the user's deadlines
res.json(userDeadlines);
} catch {
// Unable to found the user's deadlines
Expand All @@ -30,15 +30,15 @@ export default class Deadline {
*
* @param req.params.id - ID of the deadline
*/
public static async getDeadlinebyId(req: Request, res: Response) {
public static async getDeadlineById(req: Request, res: Response) {
try {
// Finds the user's one deadline
const deadline = await prisma.user_deadlines.findUniqueOrThrow({
where: {
id: req.params.id,
},
});
// Succuesfully is able to find the user's deadline
// Successfully is able to find the user's deadline
res.json(deadline);
} catch {
// Unable to find the user's deadline
Expand All @@ -53,7 +53,7 @@ export default class Deadline {
*/
public static async postDeadline(req: Request, res: Response) {
try {
// Accesses all of the deadline variables in the request
// Accesses all the deadline variables in the request
const values = Deadline.getUserDeadlineValues(req);
// Creates a new deadline
const result = await prisma.user_deadlines.create({
Expand All @@ -72,7 +72,7 @@ export default class Deadline {
*/
public static async putDeadline(req: Request, res: Response) {
try {
// Accesses all of the deadline variables in the request
// Accesses all the deadline variables in the request
const values = Deadline.getUserDeadlineValues(req);
// Edits the current deadline
const result = await prisma.user_deadlines.update({
Expand All @@ -98,7 +98,7 @@ export default class Deadline {
id: req.params.id,
},
});
// Succuesfully deletes a deadline
// Successfully deletes a deadline
res.json(deadline);
} catch {
// Unable to delete a deadline
Expand All @@ -107,7 +107,7 @@ export default class Deadline {
}

/**
* Gets all of the values associated with a deadline from the request body
* Gets all the values associated with a deadline from the request body
* (i.e. excluding id, since database generates id automatically)
*/
private static getUserDeadlineValues(req: Request) {
Expand Down
5 changes: 4 additions & 1 deletion backend/src/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ const router = express.Router();
// Sign In route
router.post('/signin', AuthController.signIn);

// Sign up route
// Sign Up route
router.post('/signup', AuthController.signUp);

// Delete Account route
router.delete('/delete/:user_id', AuthController.deleteAccount);

export default router;
2 changes: 1 addition & 1 deletion backend/src/routes/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ router.get('/deadlines/by-user/:user_id', DeadlineController.getUserDeadlines);
router.post('/deadlines', DeadlineController.postDeadline);

// Get a deadline by id
router.get('/deadlines/id/:id', DeadlineController.getDeadlinebyId);
router.get('/deadlines/id/:id', DeadlineController.getDeadlineById);

// Modify a deadline
router.put('/deadlines/id/:id', DeadlineController.putDeadline);
Expand Down
62 changes: 62 additions & 0 deletions docs/dev docs/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Contributing

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detailed instructions on how future users can contribute to our repository

We welcome contributions! To get started:

#### Step 1: Fork the Repository

Click the **Fork** button in the top right corner of [this repo](https://github.com/StressLess-Team/StressLess/) to create your own copy under your GitHub account.

#### Step 2: Clone Your Fork

```bash
git clone https://github.com/<your-username>/StressLess.git
cd StressLess
```

#### Step 3: Set Up the Remote

Set the original repository as the upstream remote to pull in future changes:

```bash
git remote add upstream https://github.com/StressLess-Team/StressLess/
git fetch upstream
```

#### Step 4: Create a New Branch

Always work in a new branch for your feature or fix:

```bash
git checkout -b feat/your-feature-name
```

#### Step 5: Make Changes Locally

Edit the code, commit your changes:

```bash
git add .
git commit -m "Add: brief description of what you changed"
```

Follow the [Prettier](docs/dev%20docs/typescript%20styling/prettier.md) and [ESLint](docs/dev%20docs/typescript%20styling/eslint.md) guidelines to ensure consistent formatting and styling.

#### Step 6: Push to Your Fork

```bash
git push origin your-feature-name
```

#### Step 7: Create a Pull Request

* Go to your fork on GitHub.
* You’ll see a "Compare & pull request" button. Click it.
* Provide a clear description of what you’ve changed and why.
* Submit the pull request to the `development` branch of the original repository.

> ✅ **Note**: Make sure your code passes all CI checks and has been tested locally before opening a PR.

#### Step 8: Collaborate

* A team member will review your PR and may request changes.
* Once approved, your changes will be merged!
Loading