Skip to content

Haksham/Inter-boat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚀 Inter-Boat

A full-stack platform for managing client-submitted articles, with host moderation, built using React, Express, MySQL, and Redis for server-side and client-side caching.


πŸ“ Folder Structure

Click to view folder structure
inter-boat/
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ sql_sample_data.txt
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   └── session.js
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ clientRoute.js
β”‚   β”‚   └── dataRoute.js
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”œβ”€β”€ server.js
β”‚   β”œβ”€β”€ .env
β”‚   β”œβ”€β”€ redisClient.js
β”‚   └── node_modules/
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   β”œβ”€β”€ index.css
β”‚   β”‚   β”œβ”€β”€ main.jsx
β”‚   β”‚   └── components/
β”‚   β”‚       β”œβ”€β”€ Add.jsx
β”‚   β”‚       β”œβ”€β”€ Client.jsx
β”‚   β”‚       β”œβ”€β”€ Edit.jsx
β”‚   β”‚       β”œβ”€β”€ Footer.jsx
β”‚   β”‚       β”œβ”€β”€ Header.jsx
β”‚   β”‚       β”œβ”€β”€ Home.jsx
β”‚   β”‚       β”œβ”€β”€ Host.jsx
β”‚   β”‚       β”œβ”€β”€ LoadingSpinner.jsx
β”‚   β”‚       β”œβ”€β”€ Login.jsx
β”‚   β”‚       β”œβ”€β”€ NotFoundPage.jsx
β”‚   β”‚       β”œβ”€β”€ Signup.jsx
β”‚   β”‚       └── StatusFilter.jsx
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”œβ”€β”€ vite.config.js
β”‚   β”œβ”€β”€ eslint.config.js
β”‚   β”œβ”€β”€ .env
β”‚   └── node_modules/

πŸš€ Getting Started

1. Clone the Repository

git clone https://github.com/your-username/inter-boat.git
cd inter-boat

2. Backend Setup

a. Install Dependencies

cd backend
npm install

b. Configure Environment Variables

Create a .env file in the backend/ directory:

MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USERNAME=your_mysql_user
MYSQL_PASSWORD=your_mysql_password
MYSQL_DATABASE=inter_boat
SESSION_SECRET=your_session_secret
EXPRESS_PORT=8000
FRONTEND_URL=http://localhost:5173
REDIS_URL=redis://localhost:6379

c. Set Up the Database

  • Create the database and tables using the following SQL:
CREATE DATABASE inter_boat;
USE inter_boat;

CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  username VARCHAR(50) NOT NULL UNIQUE,
  password VARCHAR(255) NOT NULL,
  role ENUM('host', 'client') NOT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE articles (
  id INT AUTO_INCREMENT PRIMARY KEY,
  title VARCHAR(255) NOT NULL,
  content TEXT NOT NULL,
  client_id INT NOT NULL,
  submitted_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (client_id) REFERENCES users(id) ON DELETE CASCADE
);

CREATE TABLE article_status (
  id INT AUTO_INCREMENT PRIMARY KEY,
  article_id INT NOT NULL,
  status ENUM('pending', 'accepted', 'rejected') DEFAULT 'pending',
  updated_by INT NOT NULL,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  FOREIGN KEY (article_id) REFERENCES articles(id) ON DELETE CASCADE,
  FOREIGN KEY (updated_by) REFERENCES users(id)
);

d. Start Redis Server

sudo apt update
sudo apt install redis-server
sudo systemctl enable redis-server
sudo systemctl start redis-server
redis-cli ping  # Should return: PONG

e. Start the Backend Server

npm run dev

or

npm start

3. Frontend Setup

a. Install Dependencies

cd ../frontend
npm install

b. Configure Environment Variables

Create a .env file in the frontend/ directory:

VITE_API_BASE_URL=http://localhost:8000

c. Start the Frontend Dev Server

npm run dev

The app will be available at http://localhost:5173.


πŸ—„οΈ Database Tables

  • users: Stores user credentials and roles (host or client)
  • articles: Stores articles submitted by clients
  • article_status: Tracks the status (pending, accepted, rejected) of each article and who updated it

βš™οΈ Environment Variables

Backend .env example:

MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USERNAME=your_mysql_user
MYSQL_PASSWORD=your_mysql_password
MYSQL_DATABASE=inter_boat
SESSION_SECRET=your_session_secret
EXPRESS_PORT=8000
FRONTEND_URL=http://localhost:5173
REDIS_URL=redis://localhost:6379

Frontend .env example:

VITE_API_BASE_URL=http://localhost:8000

πŸ“¦ Dependencies

Backend

See backend/package.json:

  • express, cors, dotenv, mysql2, express-session, express-mysql-session
  • ioredis, react-icons, nodemon (dev)

Frontend

See frontend/package.json:

  • react, react-dom, react-router-dom, axios, tailwindcss
  • @tailwindcss/vite, vite, vite-plugin-qrcode, react-icons
  • @tanstack/react-query, eslint (dev), @vitejs/plugin-react (dev)

πŸ› οΈ Features

  • Client Registration & Login
  • Host & Client Dashboards
  • Article Submission, Editing, Deletion
  • Host Moderation (Accept/Reject/Pending)
  • Status Filtering & Article Expansion
  • Session-based Authentication
  • Responsive UI with TailwindCSS
  • Role-based Access Control
  • Persistent MySQL-backed Sessions
  • Server-side caching with Redis
  • Client-side caching with React Query
  • Live QR code for dev server (via vite-plugin-qrcode)
  • 404 Not Found Page
  • Reusable Header & Footer
  • Loading Spinners for Data Fetching
  • ESLint and code quality tools

πŸ’‘ Tips

  • Make sure MySQL and Redis are running and accessible with the credentials you provide.
  • Use different browsers or incognito mode to test host and client roles simultaneously.
  • For production, use hashed passwords and secure session management.
  • Environment files (.env) are ignored by git for security.

πŸ“„ License

This project is licensed under the MIT License. See LICENSE for details.


🀝 Contributing

Pull requests and suggestions are welcome! Please open an issue first to discuss what you would like to change.


πŸ‘€ Author


Enjoy using Inter-Boat!