Skip to content

roshhi/the-clubhouse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

The Clubhouse - Mini Message Board

A members-only message board where users can post anonymous messages. Only verified members can see who wrote each message and when. Built with Node.js, Express, EJS, and custom JWT authentication.

This project demonstrates role-based access control with three user levels:

  • Guest - Can view messages (content only)
  • Member - Can see usernames and timestamps
  • Admin - Can delete any message

Preview

1 2 3 4 5 6 7

Tech Stack

Technology Purpose
Node.js JavaScript runtime
Express.js 5 Web framework
EJS Templating engine
JWT (jsonwebtoken) Stateless authentication & authorization
bcrypt Password hashing
cookie-parser HTTP cookie parsing
Neon Serverless Postgres hosting
@neondatabase/serverless Neon's serverless driver
Render Deployment

Features

  • User Authentication - Sign up and login with secure password hashing
  • JWT Authorization - Stateless authentication using HTTP-only cookies
  • Role-Based Access - Three levels: Guest, Member, Admin
  • Become a Member - Enter a secret code to unlock member privileges
  • Become an Admin - Enter admin code to gain message deletion rights
  • Create Messages - Post new messages (logged-in users only)
  • View Message Details - Click the eye icon to see full message details
  • Delete Messages - Admins can delete any message
  • Responsive Design - Fully responsive on all devices
  • Serverless Database - Powered by Neon's serverless PostgreSQL

πŸ“ Folder Structure

the-clubhouse/
β”œβ”€β”€ app.js                 # Express application entry point
β”œβ”€β”€ .env                   # Environment variables (JWT_SECRET, MEMBER_CODE, ADMIN_CODE)
β”œβ”€β”€ .gitignore             # Git ignore file
β”œβ”€β”€ package.json           # Dependencies and scripts
β”‚
β”œβ”€β”€ db/
β”‚   └── pool.js            # Neon database connection
β”‚
β”œβ”€β”€ routes/
β”‚   └── index.js           # All route handlers with JWT middleware
β”‚
β”œβ”€β”€ views/
β”‚   β”œβ”€β”€ partials/
β”‚   β”‚   β”œβ”€β”€ head.ejs       # HTML head partial
β”‚   β”‚   └── footer.ejs     # Footer partial
β”‚   β”œβ”€β”€ index.ejs          # Main message board page
β”‚   β”œβ”€β”€ login.ejs          # Login form
β”‚   β”œβ”€β”€ signup.ejs         # Signup form
β”‚   β”œβ”€β”€ new-msg-form.ejs   # New message form
β”‚   β”œβ”€β”€ message.ejs        # Message detail page
β”‚   β”œβ”€β”€ become-member.ejs  # Member secret code form
β”‚   └── become-admin.ejs   # Admin secret code form
β”‚
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ styles.css         # All CSS styles
β”‚   β”œβ”€β”€ favicon.ico        # Favicon files
β”‚   └── ...                # Other static assets

Getting Started

Prerequisites

  • Node.js (v18+)
  • A Neon PostgreSQL database

Installation

  1. Clone the repository

    git clone https://github.com/roshhi/mini-msg-board.git
    cd mini-msg-board
  2. Install dependencies

    npm install
  3. Set up environment variables

    Create a .env file in the root directory:

    DATABASE_URL=postgresql://username:password@your-neon-host/database?sslmode=require
    JWT_SECRET=your-super-secret-jwt-key
    MEMBER_CODE=clubhouse
    ADMIN_CODE=admin123
  4. Create the database tables

    Run this SQL in your Neon console:

    CREATE TABLE users (
        id SERIAL PRIMARY KEY,
        username VARCHAR(20) UNIQUE NOT NULL,
        password VARCHAR(255) NOT NULL,
        is_member BOOLEAN DEFAULT FALSE,
        is_admin BOOLEAN DEFAULT FALSE
    );
    
    CREATE TABLE messages (
        msg_id SERIAL PRIMARY KEY,
        user_id INTEGER REFERENCES users(id),
        msg_text VARCHAR(200) NOT NULL,
        date_added TIMESTAMP DEFAULT NOW()
    );
  5. Start the server

    node app.js
  6. Open in browser

    http://localhost:3000
    

What I Learned

Through building this project, I learned:

  • Custom JWT Authentication - Implementing stateless auth with JSON Web Tokens stored in HTTP-only cookies
  • Role-Based Authorization - Protecting routes and conditionally rendering UI based on user roles
  • Password Security - Using bcrypt to hash and compare passwords securely
  • EJS Templating - Dynamic HTML rendering with embedded JavaScript
  • Neon Serverless - Using Neon's serverless driver for edge-compatible database connections
  • MVC Architecture - Separating concerns with routes, views, and database logic

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.


License

This project is open source and available under the MIT License.


Acknowledgments

About

A members-only message board where users can post anonymous messages built with custom JWT authentication.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors