This app allows users to upload polls with two photos, and ask friends from friend lists, or the general public to vote on their polls.
cd
to./server
- Make sure MongoDB is setup and running on your localhost on port 27017. The app will connect to "poll" database on your local mongo connection.
yarn install
yarn dev
In a new terminal tab:
-
cd
to./client
yarn install
yarn start
-
[optional] if you want to test out uplodaing photos, go to .env file and enter the following credentials with keys:
AWS_SECRET_ACCESS_KEY = ""
AWS_ACCESS_KEY_ID = ""
- Database
- MongoDB
- Backend
- Express, Mongoose
- Frontend
- React (hooks), Material UI
Backend:
socket.io
- For establishing web socket connections to update active/inactive user status
aws-sdk
,multer
,multer-s3
- For parsing uploaded images and sending them AWS S3
chai
,mocha
,mongodb-memory-server
- For integration testing
Frontend:
socket.io-client
@material-ui/core
,@material-ui/icons
,@material-ui/tabs
react-dropzone
Checkout the dev README for details about API endpoints.
- Web sockets
- Mobile responsiveness
- Integration tests
- React context
- App shows live indicators when users are logged in:
server/bin/www
:
io.on('connection', (socket) => {
console.log('connection');
socket.on('userActive', () => {
socket.emit('makeActive');
io.emit('friendsUpdate');
});
socket.on('userLogout', () => {
io.emit('friendsUpdate');
});
socket.on('disconnect', () => {
console.log('user disconnected');
});
});
client/src/components/contexts/PollContext.js
:
import React from 'react';
// This is what each component should import
export const PollContext = React.createContext();
// This should be imported only by index.js
export const PollContextProvider = ({ children }) => {
const [state, setState] = React.useState({
poll: {},
votes: [],
});
function setPollState(newState) {
setState((prevState) => {
return { ...prevState, ...newState };
});
}
return (
<PollContext.Provider
value={{
...state,
setPollState,
}}
>
{children}
</PollContext.Provider>
);
};