HiveMind is a social network that allows users to share ideas, vote on them and comment, all within an environment built with a modern technology stack: Node.JS, Express.JS, Angular, Tailwind CSS, PostgreSQL.
This repository contains the entire project divided into two main folders:
- backend: contains the Node/Express server with CRUD for ideas, users, JWT authentication, comments, and votes.
- frontend: contains the Angular Single Page Application.
- Main Features
- Technologies
- Requirements
- Project Structure
- Environment Setup
- Installation and Startup Instructions
- Main Backend Routes
- Main Frontend Features
- Notes and Contacts
- Registration and login with JWT tokens.
- Ability to post formatted ideas using markdown.
- Ability to leave votes on ideas.
- Ability to leave comments on ideas.
- Rankings of ideas (most popular, most controversial, etc.).
- Action logging to file, with customizable detail levels.
- Responsive frontend interface developed with Angular and Tailwind CSS.
- Node.js and Express.js
- PostgreSQL as the relational database.
- Sequelize as the ORM for PostgreSQL.
- bcrypt for password hashing.
- jsonwebtoken for JWT authentication.
- dotenv / dotenvx for environment variable management.
- cors for cross-origin requests.
- swagger-ui-express and swagger-jsdoc for API documentation (configurable in
/api-docs).
- Angular as the SPA framework.
- Tailwind CSS for styling.
- ngx-markdown for rendering Markdown.
- rxjs for reactive programming.
- jwt-decode for decoding tokens on the frontend.
- ngx-toastr for toast notifications.
- Node.js
- npm as package manager.
- Angular CLI (optional, but recommended if running the frontend manually).
- A local installation of PostgreSQL (if not using Docker) or Docker installed (if using container mode).
The main structure is as follows:
backend/
│
├── src/
│ ├── controllers/
│ │ ├── AuthController.js
│ │ ├── IdeaController.js
│ │ ├── VoteController.js
│ │ ├── CommentController.js
│ │ └── UserController.js
│ ├── models/
│ │ ├── User.js
│ │ ├── Idea.js
│ │ ├── Comment.js
│ │ ├── Vote.js
│ │ └── associations.js
│ ├── utils/
│ │ ├── Logger.js
│ │ ├── AuthValidator.js
│ │ └── hashing.js
│ ├── data/
│ │ └── db.js (connection to PostgreSQL)
│ └── routes/
│ ├── authRoutes.js
│ ├── ideaRoutes.js
│ ├── voteRoutes.js
│ └── commentRoutes.js
├── index.js (main Express entry point)
├── cleanDatabase.js (script to clean the database)
├── docker-compose.yml (configuration for the Postgres service and the backend)
└── package.json
frontend/
│
├── src/
│ └── app/
│ ├── landing-page/
│ ├── login/
│ ├── register/
│ ├── home/
│ ├── navbar/
│ └── footer/
└── package.json
HiveMind.pdf (compiled PDF document)
In the backend, the following environment variables are used (managed via dotenv/dotenvx):
PORT: Port on which the Express app listens (e.g., 3000).DB_HOST: Host of the PostgreSQL DB (e.g., localhost or the service name in Docker).DB_USER: Database user (e.g., postgres).DB_PASSWORD: Database password.DB_NAME: Name of the database.DB_PORT: Port of the database (e.g., 5432).SECRET_KEY: Secret key for signing JWT tokens.
You can place these variables in a
.envfile inside the “backend” folder, or set them directly in your environment.
- Make sure Docker is installed and running.
- In the root folder, run the following command to start the backend and the PostgreSQL database:
docker-compose up --build
This will start the backend on port 3000, thePostgreSQL database on port 5432 and the frontend on port 4200.
- Ensure that PostgreSQL is running locally (or on another configured host).
- Properly configure the
.envfile (see Environment Setup) or export the environment variables. - Start the backend:
By default, this will start Express on port 3000.
npm install npm start
- In another terminal, start the frontend:
cd frontend npm install ng start - Open your browser and navigate to http://localhost:4200 to view the user interface.
- POST
/api/auth/register– Registers a new user. - POST
/api/auth/login– Logs in and provides a JWT.
- GET
/api/ideas/get– Retrieves ideas (filterable by popularity, controversy, etc.). - GET
/api/ideas/get/:id– Retrieves the details of a single idea (including comments and vote counts). - POST
/api/ideas/new– Creates a new idea (authentication required).
- PUT
/api/votes/upvote/:id– Upvotes an idea. - PUT
/api/votes/downvote/:id– Downvotes an idea.
- PUT
/api/comments/:id– Adds a comment to an idea.
Note: To access protected routes, you must send the header
Authorization: Bearer <token>.
- Landing Page with a brief description of the application, "Register Now" and "Login" buttons.
- Authentication forms (page
/register) and login form (page/login). - Protected Home Page (page
/home) to view the stream of ideas and filter them (Mainstream, Controversial, Unpopular). - Idea Detail Page that displays comments, votes, and offers buttons to vote and comment.
- Sidebar Navbar with links to the main pages and a logout button.
- Responsive layout built with Tailwind CSS.
- The project was developed as part of a university Web Technologies course and includes basic logic for managing votes, comments, and authentication.
- To clean the database (in a development environment), run the
cleanDatabase.jsscript in the backend (for example, using the command:npm run cleanif specified inpackage.json). - API documentation is configured using Swagger at
/api-docs. - For questions or issues, please contact the author at parentesimone.01@gmail.com.
Have fun with HiveMind!