Building a Reddit clone using the popular MERN (Mongo – Express – React – Node) stack.
git clone
this repo- Install all dependencies for both the front-end and back-end
- Make sure MongoDB is running (
mongod
), then start your Node and React servers- Back-end and front-end servers should be running on separate ports, in separate Terminal tabs
- Ensure both servers are up and running by visiting their existing endpoints in your browser
- Take a look around:
- BACK-END: What routes, models, and controllers have been set up? What kind of database is it connecting to?
- FRONT-END: What components have been set up?
- Install
nodemon
and change yournpm start
for the back-end to runnodemon server.js
- Create a
TextPost
model that containstitle
,content
,thumbnail_image_url
,votes
,comments
(comments
should be an array of (embedded)[https://github.com/SF-WDI-LABS/mongoose-associations]Comment
models) - Add the following API CRUD routes for
Posts
/api/posts
– GET, POST/api/posts/:post_id
– GET, PUT, DELETE
- Fill out the
Posts
controller using Mongoose queries - Add to your
seed.js
file to create aPost
– verify that it shows up at the appropriate endpoint - Use POSTMAN to confirm that the other CRUD routes are working as well (PUT, DELETE)
- Create a
Comment
model that containscontent
,votes
- Add the following API CRUD routes for
Comments
/api/posts/:post_id/comments
– POST/api/posts/:post_id/comments/:comment_id
– GET, PUT, DELETE
- Fill out the
Comments
controller using Mongoose queries - Add to your
seed.js
file to create aComment
, attached to aPost
you've created – verify that it shows up at the appropriate endpoint - Use POSTMAN to confirm that the other CRUD routes are working as well (PUT, DELETE)
- Use POSTMAN to create two
Post
s - Use POSTMAN to create two
Comment
s, both attached to the firstPost
you created - Populate the
seed.js
file to automate data seeding
- Go to your React app's homepage – research how you can access your local Node server from your React app here
- run
npm init
in the base of yourreddit-clone-mern/
directory - run
npm install concurrently --save
- change your
start
script in your newpackage.json
directory to be"start": "concurrently \"cd front-end && npm start\" \"cd back-end && npm start\""
- In your
front-end/package.json
, add a line for your React app to proxy to your Node API:"proxy": "http://localhost:8080/"
- Close all running servers – go to the base of your
reddit-clone-mern/
directory and runnpm start
- run
- Pull in react-router to implement the following routes
/
– Should show home dashboard where posts' titles and thumbnail images are displayed/posts/:post_id
– Clicking on a post should redirect to its show page (all post content, attached comments, and form for adding comments)
- Put in some placeholder text at the above pages to confirm that your React routing is working
- Think about the containers you will need
- What components will each container contain
- What API requests will each container make
- Think about the HTTP request library you'd like to use to fetch data from your Node API endpointments (e.g.
$.ajax
,fetch
,axios
, etc.)
- User should see all posts on the home page, ranked in descending order by
votes
- User should be able to click on a "Create Post" button and see a modal to create a new
Post
- User should be able to vote on a post
- User should be able to create a
Comment
on aPost
- User should be able to vote on a
Comment
- User should be able to comment on a comment (requires adding field to
Comment
model)
- Create a
LinkPost
resource- Another kind of post a Reddit user can upload (simply links to an external link, e.g. news article or imgur page)
- Model should contain fields
title
,link_url
,thumbnail_image_url
,votes
- Create a
User
resource- Model should contain fields
first_name
,last_name
,email
, andpassword_hash
- Implement authentication
- Both
Post
andComment
should haveauthor_id
(views should include author names)
- Model should contain fields
- Implement a
SubReddit
model- Should have
name
andslug
(e.g. 'Software Engineering', 'software-engineering') Post
should have asubreddit_id
- There should be a React route for going to subreddit routes (e.g.
/r/software-engineering
)
- Should have