Skip to content

a3-VishnuPriya-Dendukuri #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
127 changes: 28 additions & 99 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,116 +1,45 @@
Assignment 3 - Persistence: Two-tier Web Application with Database, Express server, and CSS template
===

Due: September 22nd, by 11:59 AM.
## GRADER
a3-persistance-vsph22
Vishnu Priya Dendukuri

This assignnment continues where we left off, extending it to use the most popular Node.js server framework (express),
a database (mongodb), and a CSS application framework / template of your choice (Boostrap, Material Design, Semantic UI, Pure etc.)
link: http://143.198.129.216/
Hey! You want to calculate your grade? Here is your grade calculator.
Just type in your scores (out of 100) and you will be able to recieve your grade in seconds! Above 90% would be an A, above 80% = B, above 70% is C and anything less than 70% would give you NR.

Baseline Requirements
---
To add information, go to the form below and type the details to add a class and the scores and click on "Submit"
To delete, you can just click in the "X" button corresponding to the row you want to delete
To edit, click on the "O" button corresponsing to the row you want to edit and the data would appear back on the form.You can edit whatever specific data you want and click on the "Submit the edited changes" button.

Your application is required to implement the following functionalities:

- a `Server`, created using Express (no alternatives will be accepted for this assignment)
- a `Results` functionality which shows all data associated with a logged in user (except passwords)
- a `Form/Entry` functionality which allows users to add, modify, and delete data items (must be all three!) associated with their user name / account.
- Use of at least five [Express middleware packages](https://expressjs.com/en/resources/middleware.html). Explore! One of these five middleware
can be a custom function that you write yourself; if you choose to do this, make sure to describe what this function is in your README.
- Persistent data storage in between server sessions using [mongodb](https://www.mongodb.com/cloud/atlas)
- Use of a [CSS framework or template](https://github.com/troxler/awesome-css-frameworks).
This should do the bulk of your styling/CSS for you and be appropriate to your application.
For example, don't use [NES.css](https://nostalgic-css.github.io/NES.css/) (which is awesome!) unless you're creating a game or some type of retro 80s site.
- challenges you faced in realizing the application: I really faced a lot of challenges while implementing the git auth. I also faced difficulties with mongo as I have never worked with it

- what authentication strategy you chose to use and why: I chose git auth as it is something that our grader can access and also it seemed easier to implement.

Your application is required to demonstrate the use of the following concepts:
- what CSS framework you used and why: For the CSS, I used pure template and CSS because they seemed simple which is perfect for my simple app. I have also changed up the colors in the css files such that I like them

- the five Express middleware packages you used and a short (one sentence) summary of what each one does. If you use a custom function for *one* (and one alone) middleware please : For the middleware
first one was passport, which helps me to handle the git oauth. Second one was response-time which records the response time for requests in HTTP servers so that I'm able check it. Thirdly, i used cookie-parser which parses cookies attached to the client request object and helps keep track of cookies in the server. Lastly, I used cookieSession to encrypt and manage the cookies

Persistent data storage in between server sessions I used [mongodb]

HTML:
- HTML input tags and form fields of various flavors (`<textarea>`, `<input>`, checkboxes, radio buttons etc.)
- HTML that can display all data *for a particular authenticated user*. Note that this is different from the last assignnment, which required the display of all data in memory on the server.

Note that it might make sense to have two pages for this assignment, one that handles login / authentication, and one that contains the rest of your application.
For example, when visiting the home page for the assignment, users could be presented with a login form. After submitting the login form, if the login is
successful, they are taken to the main application. If they fail, they are sent back to the login to try again. For this assignment, it is acceptable to simply create
new user accounts upon login if none exist, however, you must alert your users to this fact.

CSS:
- CSS styling should primarily be provided by your chosen template/framework.
Oftentimes a great deal of care has been put into designing CSS templates;
don't override their stylesheets unless you are extremely confident in your graphic design capabilities.
The idea is to use CSS templates that give you a professional looking design aesthetic without requiring you to be a graphic designer yourself.

JavaScript:
- At minimum, a small amount of front-end JavaScript to get / fetch data from the server.
See the [previous assignment](https://github.com/cs4241-19a/a2-shortstack) for reference.

Node.js:
- A server using Express, at least five pieces of Express middleware, and a persistent database (mongodb).

General:
- Your site should achieve at least 90% on the `Performance`, `Best Practices`, `Accessibility`, and `SEO` tests
using Google [Lighthouse](https://developers.google.com/web/tools/lighthouse) (don't worry about the PWA test, and don't worry about scores for mobile devices).
Test early and often so that fixing problems doesn't lead to suffering at the end of the assignment.

Deliverables
---

Do the following to complete this assignment:

1. Implement your project with the above requirements. A good potential starting point is to use the "hello-express" project template inside of Glitch; this appears as an option when you hit the "New Project" button. Use the work you did in the last assignment as a reference to implement functionality.
2. If you developed your project locally, deploy your project to Glitch (unless completing the alternative server technical acheivement described below), and fill in the appropriate fields in your package.json file.
3. Test your project to make sure that when someone goes to your main page on Glitch, it displays correctly.
4. Ensure that your project has the proper naming scheme `a3-yourfirstname-yourlastname` so we can find it.
5. Fork this repository and modify the README to the specifications below.
6. Create and submit a Pull Request to the original repo. Name the pull request using the following template: `a3-firstname-lastname`.

Acheivements
---

Below are suggested technical and design achievements. You can use these to help boost your grade up to an A and customize the
assignment to your personal interests, for a maximum twenty additional points and a maximum grade of a 100%.
These are recommended acheivements, but feel free to create/implement your own... just make sure you thoroughly describe what you did in your README,
why it was challenging, and how many points you think the achievement should be worth.
ALL ACHIEVEMENTS MUST BE DESCRIBED IN YOUR README IN ORDER TO GET CREDIT FOR THEM.

*Technical*
- (10 points) Implement OAuth authentication, perhaps with a library like [passport.js](http://www.passportjs.org/).
*You must either use Github authenticaion or provide a username/password to access a dummy account*.
Course staff cannot be expected, for example, to have a personal Facebook, Google, or Twitter account to use when grading this assignment.
Please contact the course staff if you have any questions about this. THIS IS THE HARDEST ACHEIVEMENT OFFERED IN WEBWARE. You have been warned!
- (5 points) Instead of Glitch, host your site on a different service like [Heroku](https://www.heroku.com) or [Digital Ocean](https://www.digitalocean.com). Make sure to describe this a bit in your README. What was better about using the service you chose as compared to Glitch? What (if anything) was worse?
- (5 points) Get 100% (not 98%, not 99%, but 100%) in all four lighthouse tests required for this assignment.

*Design/UX*
- (10 points) Make your site accessible using the [resources and hints available from the W3C](https://www.w3.org/WAI/), Implement/follow twelve tips from their [tips for writing](https://www.w3.org/WAI/tips/writing/), [tips for designing](https://www.w3.org/WAI/tips/designing/), and [tips for development](https://www.w3.org/WAI/tips/developing/). *Note that all twelve must require active work on your part*.
For example, even though your page will most likely not have a captcha, you don't get this as one of your twelve tips to follow because you're effectively
getting it "for free" without having to actively change anything about your site.
Contact the course staff if you have any questions about what qualifies and doesn't qualify in this regard.
List each tip that you followed and describe what you did to follow it in your site.
- (5 points) Describe how your site uses the CRAP principles in the Non-Designer's Design Book readings.
Which element received the most emphasis (contrast) on each page?
How did you use proximity to organize the visual information on your page?
What design elements (colors, fonts, layouts, etc.) did you use repeatedly throughout your site?
How did you use alignment to organize information and/or increase contrast for particular elements.
Write a paragraph of at least 125 words *for each of four principles* (four paragraphs, 500 words in total).

Sample Readme (delete the above when you're ready to submit, and modify the below so with your links and descriptions)
---
- OAuth authentication: I implemented the github authentication
- Hosting on the digital ocean and go daddy
- 100% on both th lighthouse
* ![image](https://user-images.githubusercontent.com/101887949/195431606-bbd9b058-096e-4c6b-adf6-692934c64e93.png)
* ![image](https://user-images.githubusercontent.com/101887949/195431629-2606c44f-b498-4c75-a7a3-52034e2e625b.png)

## Your Web Application Title

your glitch (or alternative server) link e.g. http://a3-charlie-roberts.glitch.me
*Design/UX*
- (5 points) Describe how your site uses the CRAP principles in the Non-Designer's Design Book readings.

Include a very brief summary of your project here. Images are encouraged, along with concise, high-level text. Be sure to include:
For the login page, I made sure I have contrast on different elements such that it's easier to read stuff. Every color on this page are contrasting. I made sure that my app name is highlighted by coloring it black and putting it in a black box.I have also used opposite color white for the login button so that it is easily visible. I just put them in the order such that people can read it one by one and it easier to understand. I put just enough space between the elements such that they are nicely visible without being cramped. I used the similar fonts for all the text as I'm already differentiating with color and contrast. If I change the font too, to be different it would be too confusing and unorganized. They are all center aligned to make them seem coordinated. As it might be too boring to have a single background color, I just added a pane on the bottom to break it up

- the goal of the application
- challenges you faced in realizing the application
- what authentication strategy you chose to use and why (choosing one because it seemed the easiest to implement is perfectly acceptable)
- what CSS framework you used and why
- include any modifications to the CSS framework you made via custom CSS you authored
- the five Express middleware packages you used and a short (one sentence) summary of what each one does. If you use a custom function for *one* (and one alone) middleware please
add a little more detail about what it does.
For the grader page, I used similar colors that I used in the login page to make it seem like a continuation of the previous page. These colors, similar to the login page, are contrasting enough for easier viewing. I center Aligned the title to make sure the people know that this page is the main page of the grader application. When I read the text about the CRAP principles, the author emphasized that not everything has to be center aligned. I had the paragraph area center aligned at first but I changed it to the left aligned and it looked much better. For the form and the table I made sure to use the same colors so that they seem related and this is where I used the repititiveness and putting them together organizes the website better. I made sure the text fields are different color so that easier to notice. I also put the logout right below the heading so that they can easily find it.

## Technical Achievements
- **Tech Achievement 1**: I used OAuth authentication via the GitHub strategy

### Design/Evaluation Achievements
- **Design Achievement 1**: I followed the following tips from the W3C Web Accessibility Initiative...

18 changes: 18 additions & 0 deletions config/keys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports={
database:{
c_u: 'users',
c_d: 'data',
database: 'CS4241',
client_ID: 'vshp22',
client_Secret: 'vshp22'
},

Session: {
CookieKey: 'alexIsGood'
},

github: {
clientID: 'ecb22791386e0e70676a',
clientSecret: '622222aeb4eb8422d8e995676cd1892d2395ba61'
}
}
14 changes: 14 additions & 0 deletions config/mongodbSetUp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { MongoClient, ServerApiVersion } = require('mongodb');
const keys = require("./keys");

const uri = `mongodb+srv://${keys.database.client_ID}:${keys.database.client_Secret}@cluster0.10yvowg.mongodb.net/?retryWrites=true&w=majority`;
const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });
// client.connect((err) => {
// const collection = client.db("test").collection("devices");
// //perform actions on the collection object
// client.close();
// console.log(err);
// });


module.exports = client;
51 changes: 51 additions & 0 deletions config/passportSetUp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const passport = require("passport");
const GithubStrategy = require("passport-github2").Strategy;
const keys = require("./keys");
const client = require("./mongodbSetUp");
const mongo = require("mongodb");
var session = require("express-session");
const db = client.db(keys.database.database);
const collection = db.collection(keys.database.c_u);

passport.serializeUser((user, done) => {
done(null, user._id);
});

//it create a new mongo object id and tries to find the user with the same id. If it does find the one with the
// same object id in the database it returns the user with the userinfo to
passport.deserializeUser((id, done) => {
let o_id = new mongo.ObjectId(id);
collection.findOne({ _id: o_id }).then((user) => {
done(null, user);
});
});

passport.use(new GithubStrategy(
{ //option for github strategy
// we need the client id and client secret to access the github API
callbackURL: "/auth/github/redirect",
clientID: keys.github.clientID,
clientSecret: keys.github.clientSecret,
},
(accessToken, refreshToken, profile, done) => { //passport callback functionS
collection.findOne({ github_id: profile.id }).then((result) => {
if (result) {
console.log("user is: ", result.username);
console.log("user id is: ", result._id);
done(null, result);
} else {
const username = profile.username;
const github_id = profile.id;
collection
.insertOne({ username: username, github_id: github_id })
.then((newUser) => {
newUser._id = newUser.insertedId;
console.log("New User created:", newUser);
done(null, newUser);
});
}
});
}
)
);

12 changes: 12 additions & 0 deletions node_modules/.bin/ejs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/ejs.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/ejs.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions node_modules/.bin/jake

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/jake.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/jake.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/mime.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading