This repository contains the code for the Tech Blog Back End application. This project follows the Model-View-Controller (MVC) architecture and allows users to create accounts, write blog posts, and comment on other developers' posts. It provides a RESTful API for managing user accounts, blog posts, and comments. The application is built using Node.js, Express, Sequelize, and PostgreSQL.
- User Authentication: Secure user signup and login with hashed passwords.
- Blog Post Management: Users can create, edit, and delete their blog posts.
- Commenting System: Users can comment on blog posts and view comments from other users.
- Seamless Associations: Each blog post is associated with a user, and comments are associated with both users and posts.
You can view website here
To run this application, follow these steps:
-
Ensure Node.js is Installed:
You will need Node.js installed on your computer. Check if you have Node.js by typing
node -v
in your command line. You should see a version number. If Node.js is not installed, visit the Node.js website to install it. -
Clone the Repository:
Clone this project repository to your computer:
git clone https://github.com/leontran44/tech-blog.git cd tech-blog
-
Install Dependencies:
Use the following command to install the required dependencies:
npm install
-
Set Up the Database:
Create a PostgreSQL database named
blog_db
. Run the provided SQL schema located in thedb/schema.sql
file to create the necessary tables. Optionally, seed the database using thenpm run seed
command to populate the database with initial data. -
Set Up Environment Variables:
Create a
.env
file in the root directory of the project. Add the following environment variables to the file:DB_HOST=localhost DB_NAME=blog_db DB_USER=postgres DB_PASSWORD=your_password
Replace
your_password
with your PostgreSQL password. -
Start the Server:
Start the Express server using the following command:
npm start
The server will start running on
http://localhost:3001
.
- Node.js: JavaScript runtime environment.
- Express.js: Web framework for Node.js.
- Sequelize: Promise-based Node.js ORM for PostgreSQL.
- PostgreSQL: Relational database management system.
- dotenv: Environment variable management.
- Insomnia Core: API testing tool.
- GitHub: leontran44
- Email: Leon Tran
- LinkedIn: Leon Tran