CPSC-2650-M01 Full Stack Web Development II Final Project
- Yujie Peng
- Shushama Tahsin
- Yuna Hu
https://github.com/yunahu/purrfect-neighbors
https://github.com/yunahu/purrfect-neighbors-api
- Clone this repository.
- Create a
.env
file containing the sample structure below at the root of the directory - Ensure you have a Redis server running.
- Run
docker-compose build
. - Run
docker-compose up
. - Run purrfect-neighbors (Please refer to its own readme file.)
PORT=
GOOGLE_CLIENT_ID=your_google_client_id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your_google_client_secret
SECRET=your_secret_key
FRONTEND_URI=
DB_HOST=your-rds-endpoint.amazonaws.com
DB_USER=your_db_user
DB_PASS=your_db_password
DB_NAME=your_db_name
- Sidebar: Navlinks to each page
- Header: Quick search and user login status
- [Page Content]
- Footer
- Homepage
- Search and Filter
- Map, with markers for adoptable pets and pet products:
- Click to open a popup with more information
- Click the popup to view the details page
- Pet Details
- Pet bio(image, description, attributes)
- Contact
- Product Details
- Product Post
- Comment input
- Comments List
- Share Items
- Post Form to share pet products
- User Profile
- User Information
- Edit Profile
- Manage Posts and Comments
- Login
- Login Form (currently supports Google Login)
- Schema Setup: The MySQL database schema was defined to include tables for users, pets, pet photos, tags, pet tags, posts, and comments
- Setup Script: A setup script (
setup.js
) was created to initialize the database schema. - AWS RDS: The MySQL database was set up on AWS RDS.
- Database Connection: Code was set up to connect to the AWS RDS instance using the credentials specified in the
.env
file.
- Environment Variables: Ensure the
.env
file contains the correct database credentials as specified above. - Running the Setup Script: Execute the setup script to create the tables in the database (only the first time):
npm run setup
- Login Endpoint: Users initiate Google login via
/login/federated/google
. - Google Callback: Google redirects to
/oauth2/redirect/google
after authentication. - Verify and Handle User Data: Passport's Google Strategy handles user authentication by verifying the user's Google profile and either creating a new user or retrieving an existing user from the database.
- Session Creation: On successful authentication, a session is created and stored in Redis.
- Serialization: The user ID is serialized and stored in the session cookie.
- Deserialization: For each subsequent request, the user ID is deserialized from the session cookie to retrieve the full user details from the database, maintaining the user's logged-in state.
- Express Session: Sessions are managed using express-session to maintain user login state across requests.
- Sessions are configured with a secret key (SECRET), and the session is stored in Redis for persistence.
- Passport is used for the serialization and deserialization of user information.