Skip to content

This project is a web application that allows users to publish content, rate posts, search, comment, upvote/downvote, and includes an admin panel for user management and post deletion. The application utilizes a microservices architecture and can be deployed locally using Docker.

License

Notifications You must be signed in to change notification settings

Slipum/PostReact

Repository files navigation

Project "PostReact"

Project Description

This project is a web application that allows users to publish content, rate posts, search, comment, upvote/downvote, and includes an admin panel for user management and post deletion. The application utilizes a microservices architecture and can be deployed locally using Docker.


Preview


Functionality

  • Publishing Content: Users can create and edit posts.
  • Rating System: Users can like and dislike posts.
  • Search: Ability to search posts by keywords and users by username.
  • Comments: Users can leave comments on posts.
  • Upvote/Downvote System: Users can vote for or against posts.
  • Admin Panel: Administrators can manage users and delete posts.

Technologies

  • React Frontend library for building user interfaces.
  • Express.js Backend framework for building web applications and APIs.
  • SQLite Lightweight relational database.
  • Docker Platform for developing, shipping, and running applications in containers.
  • Nginx Web server for proper request redirection.
  • JWT Standard for creating access tokens.
  • bcrypt Library for hashing passwords.
  • Node.js JavaScript runtime environment outside the browser.
  • Axios Library for making HTTP requests.

Installation and Running the Project

  1. Setup Environment

    Edit the .env file in the project's root directory and replace the following environment variables:

    SECRET_KEY=your_secret_key
    ADMIN_USERNAME=admin
    ADMIN_EMAIL=admin@example.com
    ADMIN_PASSWORD=123098
    
  2. Run the server and client simultaneously

    You can start both the server and client with one command:

    npm run start:all
    
  3. Open the Application

    Open your browser and go to http://localhost:3000.


If u need Run Docker Containers

Make sure you have Docker and Docker Compose installed. Then run the following command:

docker-compose up --build

Project Structure

  • frontend: Directory containing frontend code in React.
  • services: Directory containing microservices code (comments, ratings, etc.).
  • docker-compose.yml: Docker Compose configuration file.
  • Dockerfile: Dockerfile for creating containers.

Endpoints

Auth Service (port 3005)

  • POST /register: Register a new user.
  • POST /login: Authenticate a user.
  • GET /profile: Get profile information.

Posts (port 3001)

  • GET /posts/:id: Get post information by ID.
  • GET /posts/search: Search posts by title.
  • GET /posts/search/user: Search posts by username.

Ratings (port 3002)

  • GET /posts/:postId/rating: Get rating of a post.
  • POST /posts/:postId/like: Like a post.
  • POST /posts/:postId/dislike: Dislike a post.

Comments (port 3003)

  • GET /posts/:postId/comments: Get comments for a post.
  • POST /posts/:postId/comments: Add a new comment to a post.

Admin (port 3004)

  • GET /users: Get all users.
  • DELETE /posts/:id: Delete post by ID.

Search Functionality

The search functionality allows users to search for posts by title and for posts by username.

  • Search by Title: Users can search for posts by entering keywords in the search bar. The search will return posts whose titles contain the entered keywords.

  • Search by Username: Users can search for posts by entering a username preceded by an "@" symbol in the search bar. The search will return posts created by users whose usernames contain the entered substring.

Authentication and Roles

To perform administrative actions, users need to be authenticated and have an "admin" role. To set up the "admin" user, edit the .env file and replace the following variables:

ADMIN_USERNAME=admin
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=123098

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

This project is a web application that allows users to publish content, rate posts, search, comment, upvote/downvote, and includes an admin panel for user management and post deletion. The application utilizes a microservices architecture and can be deployed locally using Docker.

Resources

License

Stars

Watchers

Forks