A full-stack message board application where users can register, log in, and post messages. Built with a Node.js/Express backend and a React/Vite frontend.
- 🔐 User registration and login with JWT authentication
- 💬 View all messages (public)
- ✍️ Post new messages (authenticated users only)
- 🌗 Dark/Light theme toggle with session persistence
- ⏱️ Timestamps on messages via
date-fns - 🔒 Passwords hashed with
bcryptjs
| Technology | Purpose |
|---|---|
| Node.js + Express | Server & REST API |
| PostgreSQL | Database |
| Prisma | ORM / Database client |
| bcryptjs | Password hashing |
| JSON Web Tokens (JWT) | Authentication |
| CORS | Cross-origin requests |
| Technology | Purpose |
|---|---|
| React + Vite | UI framework & build tool |
| Tailwind CSS + shadcn/ui | Styling & UI components |
| Axios | HTTP requests with JWT interceptor |
| date-fns | Timestamp formatting |
| Lucide Icons | Icon library |
| ESLint | Linting |
mini-message-board/
├── server/
│ ├── index.js
│ ├── app.js
│ ├── prisma.js
│ ├── controllers/
│ │ ├── authController.js
│ │ └── messageController.js
│ ├── routes/
│ │ ├── authRoutes.js
│ │ └── messageRoutes.js
│ ├── middleware/
│ │ └── auth.js
│ └── prisma/
│ └── schema.prisma
│
└── client/
├── src/
│ ├── main.jsx
│ ├── App.jsx
│ ├── pages/
│ │ ├── LoginPage.jsx
│ │ ├── RegisterPage.jsx
│ │ └── BoardPage.jsx
│ ├── context/
│ │ ├── AuthContext.jsx
│ │ └── ThemeContext.jsx
│ ├── lib/
│ │ ├── axios.js
│ │ └── utils.js
│ └── components/
│ └── ui/
│ └── button.jsx
└── vite.config.js
model User {
id Int @id @default(autoincrement())
username String @unique
password String
createdAt DateTime @default(now())
messages Message[]
}
model Message {
id Int @id @default(autoincrement())
text String
createdAt DateTime @default(now())
userId Int
user User @relation(fields: [userId], references: [id])
}| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Create a new user account |
| POST | /api/auth/login |
Login and receive a JWT token |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/messages/ |
Fetch all messages with author username |
| POST | /api/messages/ |
Post a new message |
- Node.js (v18+)
- PostgreSQL database
- npm or yarn
-
Clone the repository
git clone https://github.com/huddlecap/mini-message-board.git cd mini-message-board/server -
Install dependencies
npm install
-
Set up environment variables
Create a
.envfile in theserver/directory:DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE" JWT_SECRET="your_jwt_secret_here" PORT=5000
-
Run Prisma migrations
npx prisma migrate dev --name init
-
Start the server
npm start
The server will run at
http://localhost:5000
-
Navigate to the client directory
cd ../client -
Install dependencies
npm install
-
Set up environment variables
Create a
.envfile in theclient/directory:VITE_API_URL=http://localhost:5000
-
Start the development server
npm run dev
The app will run at
http://localhost:5173
- Passwords are hashed using
bcryptjsbefore storing in the database - JWT tokens are signed with a secret key (
JWT_SECRET) and stored inlocalStorage - Protected routes use an
auth.jsmiddleware that verifies the JWT on every request - Axios interceptor automatically attaches
Authorization: Bearer {token}to all outgoing requests
Lender Shark
This project is open source and available under the MIT License.
