Collaborative sticky notes board with role-based access control
A modern web application for managing sticky notes with user authentication, admin panel, public sharing, and activity tracking.
live-coding-3/
βββ docker-compose.yml β Docker Compose configuration
βββ DOCKER.md β Docker documentation
βββ .gitignore β Git ignore file
βββ backend/
β βββ app.js β Express server entry point
β βββ db.js β SQLite database setup and queries
β βββ package.json β Node.js dependencies
β βββ Dockerfile β Backend Docker configuration
β βββ .dockerignore β Docker ignore file
β βββ .env.example β Environment variables template
β βββ middleware/
β β βββ auth.js β JWT authentication middleware
β βββ routes/
β βββ auth.js β Authentication routes
β βββ notes.js β Notes CRUD operations
β βββ shared.js β Public sharing features
β βββ admin.js β Admin panel routes
β βββ activity.js β Activity logging
βββ frontend/
βββ Dockerfile β Frontend Docker configuration
βββ nginx.conf β Nginx server configuration
βββ .dockerignore β Docker ignore file
βββ index.html β Landing page
βββ registro/
β βββ registro.html β Registration page
βββ dashboard/
β βββ dashboard.html β User dashboard
βββ admin/
β βββ admin.html β Admin panel
βββ public/
β βββ public.html β Public notes view
βββ css/
β βββ style.css β Global styles
βββ js/
βββ config.js β API configuration
βββ main.js β Login logic
βββ registro.js β Registration logic
βββ dashboard.js β Dashboard logic
βββ admin.js β Admin panel logic
βββ share.js β Sharing functionality
The easiest way to run the entire application with a single command:
docker compose up --buildThat's it! The application will be available at:
- Frontend: http://localhost:8080
- Backend API: http://localhost:3000/api
Additional Commands:
# Run in background (detached mode)
docker compose up -d
# View logs
docker compose logs -f
# Stop all services
docker compose down
# Stop and remove database (fresh start)
docker compose down -vFeatures:
- β Automatic setup of backend and frontend
- β Persistent SQLite database
- β Health checks for both services
- β Auto-restart on failure
- β Isolated network for services
π See DOCKER.md for advanced Docker usage, troubleshooting, and production deployment.
If you prefer to run the services manually without Docker:
- Node.js 16+ or higher
- npm (comes with Node.js)
- A modern web browser
- Navigate to the backend directory:
cd backend- Install Node.js dependencies:
npm install- Start the development server:
npm run devOr for production:
npm startThe backend API will be available at http://localhost:3000
- Navigate to the frontend directory:
cd frontend- Serve the static files using one of these methods:
Option A: Using Python's built-in server
python -m http.server 8080Option B: Using Live Server (VS Code extension)
- Right-click on
index.htmland select "Open with Live Server"
Option C: Using Node.js http-server
npx http-server . -p 8080The frontend will be available at http://localhost:8080
- Main page:
http://localhost:8080/index.html - Public notes:
http://localhost:8080/public/public.html
- User registration with email validation
- Secure login with JWT authentication
- Password hashing with bcrypt (12 rounds)
- Rate limiting on login/register (10 attempts per 15 minutes)
- Role-based access control (user/admin)
- Create, edit, and delete personal notes
- Color-coded notes for visual organization
- Title and content fields
- Timestamp tracking (created/updated)
- Search and filter capabilities
- Share notes publicly via unique links
- Enable/disable public access per note
- Public gallery view of shared notes
- No authentication required for viewing shared notes
- View all users and their notes
- User management (view, delete users)
- System-wide statistics
- Activity monitoring
- Admin-only access with role verification
- Log all user actions (create, edit, delete notes)
- Admin activity dashboard
- Timestamp and action type recording
- JWT-based authentication with expiration
- Password hashing with bcrypt
- Rate limiting on authentication endpoints
- Input validation and sanitization
- SQL injection prevention (prepared statements)
- XSS protection (textContent usage)
- CORS configuration
- Role-based authorization
- Request size limiting (50kb max)
POST /api/auth/register- Register new userPOST /api/auth/login- Login and receive JWT token
GET /api/notes- List user's notesPOST /api/notes- Create new noteGET /api/notes/:id- Get specific notePUT /api/notes/:id- Update noteDELETE /api/notes/:id- Delete notePUT /api/notes/:id/share- Toggle public sharing
GET /api/shared- List all public notesGET /api/shared/:id- View specific public note
GET /api/admin/users- List all usersGET /api/admin/stats- System statisticsDELETE /api/admin/users/:id- Delete user
GET /api/activity- Get user activity logGET /api/activity/admin- Get all activity (admin only)
GET /api/health- Server status
All authenticated requests must include:
Authorization: Bearer <your_jwt_token>
express- Web frameworkbetter-sqlite3- SQLite databasebcryptjs- Password hashingjsonwebtoken- JWT authenticationcors- CORS middlewarevalidator- Input validationuuid- Unique ID generationdotenv- Environment variablesexpress-rate-limit- Rate limiting
SQLite database with the following tables:
- id (TEXT, PRIMARY KEY)
- email (TEXT, UNIQUE)
- password (TEXT) -- bcrypt hashed
- role (TEXT) -- 'user' or 'admin'
- created_at (TEXT)- id (TEXT, PRIMARY KEY)
- user_id (TEXT, FOREIGN KEY)
- title (TEXT)
- content (TEXT)
- color (TEXT)
- is_public (INTEGER) -- 0 or 1
- created_at (TEXT)
- updated_at (TEXT)- id (TEXT, PRIMARY KEY)
- user_id (TEXT, FOREIGN KEY)
- action (TEXT) -- 'create', 'edit', 'delete'
- note_id (TEXT)
- timestamp (TEXT)- Open
http://localhost:8080in your browser - Register a new account (valid email format required)
- Login with your credentials
- Create sticky notes with titles, content, and colors
- Share notes publicly using the share toggle
- View your activity history
- Login with an admin account
- Navigate to the admin panel
- View system statistics and all users
- Monitor user activity
- Manage users and notes
- Bcrypt password hashing (12 rounds)
- JWT authentication with expiration
- Rate limiting on auth endpoints (10 req/15min)
- Input validation and sanitization
- SQL injection prevention (prepared statements)
- XSS protection (textContent usage)
- CORS whitelist
- Role-based authorization
- Request size limiting (50kb)
- Authorization checks on all protected endpoints
- β JWT_SECRET via environment variable (already implemented in Docker)
- Implement HTTPS/SSL (use reverse proxy like Traefik or Caddy)
- Add refresh token mechanism
- Implement email verification
- Add password reset functionality
- Set up proper logging system
- Implement audit logging
- β Add backup strategy for SQLite database (Docker volumes)
- Consider migration to PostgreSQL for production
- Add brute force protection
- Implement session management
- Add content security policy headers
This project includes full Docker Compose support for easy deployment.
# Clone the repository
git clone <your-repo-url>
cd live-coding-3
# Start with Docker Compose
docker compose up -d-
Configure Environment Variables:
# Edit docker-compose.yml or create a .env file JWT_SECRET=your_production_secret_here_change_this -
Start Services:
docker compose up -d
-
Check Status:
docker compose ps docker compose logs -f
-
Database Backup:
docker compose exec backend cat /app/data/stickyboard.db > backup-$(date +%Y%m%d).db
- Backend Container: Node.js 20 Alpine, Express API, SQLite database
- Frontend Container: Nginx Alpine, serves static files
- Network: Isolated Docker network for service communication
- Volumes: Persistent storage for SQLite database
For detailed Docker documentation, see DOCKER.md
The application uses environment variables for configuration:
Backend (.env or docker-compose.yml):
PORT=3000
JWT_SECRET=your_secure_secret_key_change_in_production
FRONTEND_URL=http://localhost:8080
NODE_ENV=productionDocker Compose (recommended for production):
- Edit
docker-compose.ymlenvironment section - Or use
docker compose upwith environment variables:JWT_SECRET=mysecret docker compose up -d
A .env.example file is provided in the backend directory.
For testing purposes, you may want to manually create an admin user. Run this SQL after the database is initialized:
UPDATE users SET role = 'admin' WHERE email = 'your-email@example.com';Or modify the registration logic to create the first user as admin.