Giter Site home page Giter Site logo

mayank0255 / stackoverflow-clone-frontend Goto Github PK

View Code? Open in Web Editor NEW
533.0 18.0 205.0 13.54 MB

Clone project of a famous Q/A website for developers built using MySQL, Express, React, Node, Sequelize :globe_with_meridians:

Home Page: https://stackoverflow-clone-client.vercel.app

License: MIT License

JavaScript 68.78% HTML 1.01% CSS 0.23% SCSS 29.98%
mysql express react nodejs redux sass javascript css mern-stack database

stackoverflow-clone-frontend's Introduction

Stack-Overflow-Clone-V2-Fast.mp4

Version NPM NODE MYSQL License

API Hosted On

As the name suggests, this project is a clone of a famous Q/A website for professional and enthusiast programmers built solely by me using a completely different stack.

This repo consists of the Frontend code of the project, the backend code is in Stackoverflow-Clone-Backend

My Tech Stack (MERN)

Front-end

  • Front-end Framework: React.js (with Redux)
  • Styling: SASS and BOOTSTRAP

Back-end

  • For handling index requests: Node.js with Express.js Framework
  • As Database: MySQL with Sequelize
  • API tested using: POSTMAN

Guidelines to setup

There are two ways to setup the project: manually or using the Dockerfile. Read below for more details:

Manual Setup

  1. Open your local CLI -

    mkdir Stackoverflow-Clone
    cd Stackoverflow-Clone
    
  2. Setup the backend code -

    NOTE: For Frontend Developers, if they dont want to setup the Backend Code, they can skip the Step 2, and make sure they follow the optional step mentioned in Step 4

    • Create a .env file and the format should be as given in .env.example.

    • Clone the code & install the modules-

      git clone https://github.com/Mayank0255/Stackoverflow-Clone-Backend.git
      cd Stackoverflow-Clone-Backend
      
      npm install
      
    • Open your MySQL Client -

      CREATE DATABASE stack_overflow;
      

      NOTE: Don't forget to keep the database name same in the .env and here.

    • Run the index npm start.

  3. Open a new CLI terminal and goto the root Stackoverflow-Clone folder you created in the first step.

  4. Setup the Frontend code -

    • Clone the code & install the modules-

      git clone https://github.com/Mayank0255/Stackoverflow-Clone-Frontend.git
      cd Stackoverflow-Clone-Frontend
      
      npm install
      
    • Run the client index npm start.

    OPTIONAL (Recommended For Frontend Developers): Can just change the path here to this https://stackoverflow-clone-backend.herokuapp.com Now, it will hit PROD

Let me know if you are interested and would want me to assign it to you

Docker Setup

The back-end has support for Docker. So if you want to run the back-end in a container, you need do:

  • Setup environment variables in .env file. Note when you use Docker setup and run the database in localhost (host machine), you need to setup the environment variables for use correct IP of MySQL Database. Please, read here and here for more details.

  • Build the Docker image:

    docker build -t stackoverflowclone .
    
  • Run the container. For example, if you want to run the container in a new terminal, you can do:

    docker run -d -p 5000:5000 stackoverflowclone
    

The default port of api is 5000. After running the container, you can access the api by typing:

http://localhost:5000/api/<endpoint that you request - see next section>

Follow the steps properly (manual or Docker) and you are good to go.

Contributing

  • Go to Contributing.md

DEMO

Video Last Updated on 7th March, 2022

IMAGES

stackoverflow-clone-frontend's People

Contributors

avinashupadhya99 avatar burhanraja avatar ddsuhaimi avatar dependabot[bot] avatar gooddaytoday avatar imgbotapp avatar luko0610 avatar mayank0255 avatar saisridhar783 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stackoverflow-clone-frontend's Issues

Consider using Stacks design system

Super rad, keep going! We've got a design system that might get you closer to the production Stack Overflow.

https://stackoverflow.design

It's got a ton of CSS components and atomic CSS classes. Also a bunch of resources like all our icon set (including logos). It's all open source and might help! โœŒ๏ธ

[FullStack]: Configure Eslint

Setup Eslint and Prettier to the project to maintain some coding conventions.

Might introduce Travis-CI as well for testing.

Add new posts to database!!! from python terminal - it not show in all questions list

I add this line to database
{'id': 8, 'title': 'This is a simple herpes virus-jkjfghdkfjghdkghkgjhdkg', 'body': 'jkljlkjlj ghjgjg ghjhgjhg hghjghj', 'views': 0, 'created_at': datetime.datetime(2021, 1, 15, 3, 59, 13), 'user_id': 8, 'vote': 23, 'unique_id': 1, 'counter': 0, 'language': 'english'}]
sucessfully

>>> def insertDBq(body,user_id,id,vote,unique_id,language,title):
...     mydb=mysql.connector.connect(host="localhost",user="root",password="password",database="stack_overflow_v2");
...     string="""REPLACE INTO posts(body, user_id, id, vote, unique_id, language,title) VALUES ('%s',%d,%d,%d,%d,'%s','%s');""" % (body,int(user_id),id,int(vote),unique_id,language,title);
...     mycursor.execute(string);
...     mydb.commit();
...     return print(mycursor.rowcount, "record inserted.");
... 
>>> insertDBq('jkljlkjlj ghjgjg ghjhgjhg hghjghj',8,8,23,1,'english','This is a simple herpes virus-jkjfghdkfjghdkghkgjhdkg')
1 record inserted.

but it won't to show at main page and when i got to mysite.com/questions/8 throw error to me 404

[BUG]: Rich Text Editors are showing white

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Speed Optimization

Hey Mayank0255!
I can implement Caching to for fast loading ,If you assign me.

[Fullstack]: Enable multiple tags

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Refactor the code base

  • Distribute the code using the best practices of Node.js
  • Introduce necessary setup packages like morgan for logging, compression
  • Add a response handler
  • Improve the add post, comment and answer functionalities in redux
  • setup pool and remove connection
  • Apply best practices for querying MySQL
  • Follow one kind of naming nomenclature - preferably camel case

I try to modify react app and get link to Question inside sidebar component

import React from 'react';
import { NavLink } from 'react-router-dom';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { getPost } from '../../redux/posts/posts.actions';
import { ReactComponent as GlobalIcon } from '../../assets/Globe.svg';
import './SideBar.styles.scss';

const SideBar = ({ getPost, post: { title, id } }) => (
    <div className='side-bar-container'>
        <div className='side-bar-tabs'>

            <NavLink exact activeClassName='active' className='home-link nav_link' to='/' >
                <p>Home</p>
            </NavLink>

            <div className='public-tabs'>
                <p className='title fc-light'>PUBLIC</p>
                <NavLink activeClassName='active' className='icon-link nav_link' to='/questions' >
                    <p>
                        <GlobalIcon className='icon' />
                        Stack Overflow
                    </p>
                </NavLink>
                <NavLink activeClassName='active' className='link nav_link' to={id} >
                    <p>Tags</p>
                </NavLink>
                <NavLink activeClassName='active' className='link nav_link' to='/users' >
                    <p>${ title }</p>
                </NavLink>
                <NavLink activeClassName='active' className='link nav_link' to='/jobs' >
                    <p>Jobs</p>
                </NavLink>
            </div>
            <div className='teams-tabs'>
                <p className='title fc-light'>TEAMS</p>
            </div>
        </div>
    </div>

);
SideBar.propTypes = {
    getPost: PropTypes.func.isRequired,
    post: PropTypes.object.isRequired
};

const mapStateToProps = state => ({
    post: state.post
});

export default connect(mapStateToProps, { getPost })(SideBar);

I get error

TypeError: Cannot read property 'pathname' of undefined
(anonymous function)
/Users/andrejeremcuk/Stackoverflow-Clone/modules/NavLink.js:50
  47 |   resolveToLocation(to, currentLocation),
  48 |   currentLocation
  49 | );
> 50 | const { pathname: path } = toLocation;
     | ^  51 | // Regex taken from: https://github.com/pillarjs/path-to-regexp/blob/master/index.js#L202
  52 | const escapedPath =
  53 |   path && path.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");

I modify sidebar in that way:

`import React from 'react';
import { NavLink } from 'react-router-dom';

import { ReactComponent as GlobalIcon } from '../../assets/Globe.svg';
import './SideBar.styles.scss';

const SideBar = () => (
    <div className='side-bar-container'>
        <div className='side-bar-tabs'>

            <NavLink exact activeClassName='active' className='home-link nav_link' to='/' >
                <p>Home</p>
            </NavLink>

            <div className='public-tabs'>
                <p className='title fc-light'>PUBLIC</p>
                <NavLink activeClassName='active' className='icon-link nav_link' to='/questions' >
                    <p>
                        <GlobalIcon className='icon' />
                        Stack Overflow
                    </p>
                </NavLink>
                <NavLink activeClassName='active' className='link nav_link' to='/tags' >
                    <p>Tags</p>
                </NavLink>
                <NavLink activeClassName='active' className='link nav_link' to='/users' >
                    <p>Users</p>
                </NavLink>
                <NavLink activeClassName='active' className='link nav_link' to='/jobs' >
                    <p>Jobs</p>
                </NavLink>
            </div>
            <div className='teams-tabs'>
                <p className='title fc-light'>TEAMS</p>
            </div>
        </div>
    </div>

);

export default SideBar;`

DB connection error help?

when I run server locally I got Error: Unknown database 'stack_overflow_v2' error will you help me fix that?

Add new features to the project

  • Add gravatars
  • Single post views
  • Profile views
  • Change title based on the current page
  • Search Tags
  • Search Users
  • Add tag description
  • UI improvements
  • Create relevant components
  • Sort posts by various parameters
  • Sort tags by various parameters
  • Sort Users by various parameters
  • Sort Answers in a Post
  • Search Questions
  • Implement getSingleTag endpoint

[Backend/Frontend]: pagination request

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Currently, front-end paging is used. When there is a lot of data, the loading page will crash.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Expect to change to back-end interface paging to speed up page loading.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

[BUG]: How to we actually see the frontend of site ?

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Create a .env file and the format should be as given in .env.example.

  2. Run these commands then -
    npm run installDep (To install all the dependencies)
    npm run auditDep (Run this to audit fix all the vulnerabilities)

  3. Run databaseConfig.sql file in the mysql client
    source /data/databaseConfig.sql

  4. Run seed.sql file in the mysql client for seed data
    source /data/seed.sql

  5. Start the servers
    npm run dev

Expected behavior
trying to see the font end as shown in the demo.

Screenshots

image

Additional context
Add any other context about the problem here.

[Frontend]: Add Project Socials to the website

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

eslint error

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

"eslint": "^6.6.0"

Don't try to install it manually: your package manager does it automatically.
However, a different version of eslint was detected higher up in the tree:

C:\Users\DELL\nodeapps\stack\node_modules\eslint (version: 7.32.0)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

  1. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
    This may help because npm has known issues with package hoisting which may get resolved in future versions.

  2. Check if C:\Users\DELL\nodeapps\stack\node_modules\eslint is outside your project directory.
    For example, you might have accidentally installed something in your home folder.

  3. Try running npm ls eslint in your project folder.
    This will tell you which other package (apart from the expected react-scripts) installed eslint.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

[Frontend]: Make the app responsive

Make the client-side responsive as it is not now.

One more thing I would like to state is that while working on it, keep in mind the component wise SCSS styling and to maintain that as closely as possible.

[Frontend]: Implement pagination to the App

Add pagination in the front-end on pages:

  • HomePage
  • QuestionsPage
  • TagsPage
  • UsersPage

The pagination for the HomePage and QuestionsPage should look similar to this:

image

Don't add the counts per page thing, if possible you can go ahead or else the pagination will begin after 10 PostItem Components

And for TagsPage and UsersPage, it should look like this:

image

The pagination should begin after 12 TagPanel Components

Kindly check for all the cases file paginating like on going forward how the paginate component should look like and all.

Feel free to tag me if there's any issue ๐Ÿ˜„

[Frontend] Setup New Color Schemes

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

[Frontend]: Style Improvement

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Trouble Setting up MySQL

Hey! I'm facing issues to setup database locally cause I never use SQL database before ''m only use mongodb But I know mySQL syntax. Will you tell me step by step how do I setup db locally?

Add a MySQL seeder

Seed data for:

  • Users
  • Posts
  • Tags
  • Answers
  • Comments

Write MySQL script for this which the developer can run to get you started

Major Project Update: Frontend and backend code split ๐ŸŽ‰ ๐ŸŽ‰

The Frontend code will remain in this Github Repo, and then the backend code will be shifted to Stackoverflow-Clone-Backend. This repo will be renamed to Stackoverflow-Clone-Frontend.

This update will be done as the project is expanding and the number of contributors are increasing, problems related to the setup, code style management and code checking are also increasing.

Benefit of doing this is to allow better code management, allow more growth to the project, and open the scope of deploying the code.

[Frontend]: Add Some Basic Validations For Better UX

  1. Max length limit for Tag Name while creation: 25 Characters
  2. All Tag Names Should Be In English, So Translate it or don't allow it
  3. Users Per Page Should Be 15, not 16
  4. Validate the language users are inputting, dont allow any abuses or curses

[Backend/Frontend]: pagination request

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Currently, front-end paging is used. When there is a lot of data, the loading page will crash.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Expect to change to back-end interface paging to speed up page loading.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

[Frontend]: Add Text Localization To All The Pages

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Setup husky to the project

This is to save some time reviewing the code and then changing the linting errors. Which will be done by locally automating this process before committing the code

Husky Package

[BUG]: State not getting updated

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.