Created by Fabricio Braga
Last Updated: February 20th, 2025
This is a simple Forum Application built with React for the front end and Express for the back end. The application allows users to:
- Create Topics: Users can create new topics by providing a title, content, and their name.
- Reply to Topics: Users can reply to existing topics by providing their name and reply content.
- List Topics: Display all topics along with their replies.
- Create a Topic: Add a new topic with a title, content, and author name.
- Reply to a Topic: Add replies to existing topics.
- List Topics: View all topics and their replies in a clean, minimalist design.
- Modern UI: Smooth, rounded borders, soft shadows, and a blue/light-blue color scheme.
- Node.js: JavaScript runtime for building the server.
- Express: Web framework for handling HTTP requests and routing.
- CORS: Middleware for enabling cross-origin requests.
- Body-Parser: Middleware for parsing incoming request bodies.
- React: JavaScript library for building the user interface.
- Axios: Promise-based HTTP client for making API requests.
- CSS: Custom styles for a modern and minimalist design.
Before running the project, ensure you have the following installed:
Node.js is a JavaScript runtime, and npm (Node Package Manager) is used to manage dependencies.
- Install Node.js and npm:
- Download and install Node.js from https://nodejs.org/.
- Verify the installation:
node -v npm -v
Git is used for version control. You can download it from https://git-scm.com/.
Follow these steps to set up and run the project locally.
Clone both the back end and front end repositories:
# Back End
git clone https://github.com/hackthegap/course-6-forum-backend.git
cd course-6-forum-backend
# Front End
git clone https://github.com/hackthegap/course-6-forum-frontend.git
cd course-6-forum-frontend
-
Navigate to the back end folder:
cd course-6-forum-backend
-
Install dependencies:
npm install
-
Start the server:
node server.js
The back end server will run on
http://localhost:5001
.
-
Navigate to the front end folder:
cd course-6-forum-frontend
-
Install dependencies:
npm install
-
Start the React application:
npm start
The front end application will open automatically in your browser at
http://localhost:3000
.
course-6-forum-backend/
├── server.js # Main server file
├── package.json # Back end dependencies and scripts
└── node_modules/ # Installed dependencies
course-6-forum-frontend/
├── src/
│ ├── App.js # Main React component
│ ├── App.css # Styles for the application
│ ├── index.js # Entry point for the React app
├── package.json # Front end dependencies and scripts
└── node_modules/ # Installed dependencies
-
Routes:
GET /api/topics
: Fetch all topics.POST /api/topics
: Create a new topic.POST /api/topics/:id/replies
: Add a reply to a topic.
-
In-Memory Data Store:
- Topics and replies are stored in an in-memory array (no database).
-
Components:
App.js
: Main component that handles topic creation, replies, and displaying topics.App.css
: Custom styles for a modern and minimalist design.
-
State Management:
- Uses React's
useState
anduseEffect
hooks for managing state and side effects.
- Uses React's
-
API Integration:
- Uses Axios to interact with the back end API.
node server.js
: Starts the Express server.
npm start
: Runs the React app in development mode.npm test
: Launches the test runner.npm run build
: Builds the app for production.npm run eject
: Ejects the app from Create React App (advanced use only).
This project covers the following key concepts:
-
Back End Development:
- Building a RESTful API with Express.
- Handling HTTP requests and responses.
- Using middleware for CORS and body parsing.
-
Front End Development:
- Building a React application with functional components.
- Managing state with React hooks (
useState
,useEffect
). - Making API requests with Axios.
-
Asynchronous Programming:
- Using
async/await
for handling asynchronous operations.
- Using
-
Modern UI Design:
- Creating a clean and minimalist user interface with CSS.
If you'd like to contribute to this project, follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeatureName
). - Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/YourFeatureName
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- This project was created as part of a course to teach back-end and front-end development with Node.js, Express, and React.
- Special thanks to JSONPlaceholder for inspiration on API design.
If you have any questions or need further assistance, feel free to reach out to the instructor or open an issue in the repository.