a-box31 / ABlog

Creating a blogging website using mySQL, Expess.js, React.js, and Node.js.
https://ablog-xi3j.onrender.com/
1 stars 4 forks source link

ABlog

Overview

This is a blogging platform where users can create blogs, follow other users, and manage their profiles.

Front-End Documentation

Features:

  1. User Authentication: Users can register, log in, and log out using forms on the website.
  2. Blog Search: A search bar allows users to search for blog posts.
  3. Blog Post Creation: Users can create, view, and update blog posts.
  4. Responsive Design: The app is fully responsive and adapts to different screen sizes.
  5. Follower System: Users can follow each other, and their followers are displayed on their profiles.

Front-End Stack:

Back-End API Documentation

1. User API

2. Blog API

3. Follower API

4. Session API

MySQL Database Structure

1. Users Table

Column Name Data Type Description
id INT Primary key, auto-increment
username VARCHAR(255) User's username
password VARCHAR(255) User's password (hashed)
email VARCHAR(255) User's email (unique)
avatar VARCHAR(255) Path to avatar image
bio TEXT User bio

2. Sessions Table

Column Name Data Type Description
id INT Primary key, auto-increment
user_id INT Foreign key to users.id
token VARCHAR(255) Unique session token

3. Blogs Table

Column Name Data Type Description
id INT Primary key, auto-increment
owner_id INT Foreign key to users.id
title VARCHAR(255) Title of the blog
media VARCHAR(255) Media associated with blog
content TEXT Blog content
updated_at TIMESTAMP Last updated time

4. Followers Table

Column Name Data Type Description
id INT Primary key, auto-increment
user_id INT Foreign key to users.id
followed_id INT Foreign key to users.id

Installation and Setup

To get the project up and running locally, follow these steps:

Backend Setup

  1. Clone the repository:

    git clone https://github.com/a-box31/ABlog.git
  2. Navigate to the backend directory:

    cd backend
  3. Install the required dependencies:

    npm install
  4. Set up the MySQL database:

    • Create a new MySQL database.
    • Run the SQL script (ABlogDB.session.sql) to set up the database tables.

    Example of setting up the tables:

    CREATE DATABASE blogApp;
    USE blogApp;
    
    -- Create users table
    CREATE TABLE users (
        id INT AUTO_INCREMENT PRIMARY KEY,
        username VARCHAR(255) NOT NULL,
        password VARCHAR(255) NOT NULL,
        email VARCHAR(255) NOT NULL UNIQUE,
        avatar VARCHAR(255) DEFAULT 'default.png',
        bio TEXT
    );
    
    -- Create other tables as needed...
  5. Set up environment variables:

    • Create a .env file in the backend root directory.
    • Add the following environment variables:
      
      MYSQL_HOST=localhost
      MYSQL_USER=root
      MYSQL_PASSWORD=your_password
      MYSQL_DATABASE=blogApp

    COOKIE_EXPIRY=86400000 PORT=3000 CLIENT_URL='http://client_domain_name' SERVER_DOMAIN='http://server_domain_name'

  6. Run the backend server:

    npm run dev
  7. The backend server will be running on http://localhost:3000.

Frontend Setup

  1. Navigate to the frontend directory:

    cd frontend
  2. Install the required dependencies:

    npm install
  3. Start the frontend server:

    npm run dev
  4. The frontend server will be running on http://localhost:5173.

Now, the app should be fully functional with both the backend and frontend running locally.