A modern web application that serves as a joke management system with a terminal-style interface. Built with React, Go, and PostgreSQL.
- React 18+ with TypeScript
- Vite build tool
- Tailwind CSS for styling
- Lucide React for icons
- Go (Gin web framework)
- PostgreSQL database
- RESTful API architecture
- Node.js 16+
- Go 1.19+
- PostgreSQL 14+
- npm or yarn
- Clone the repository:
git clone https://github.com/andebugulin/hahasaas.git
cd hahasaas
- Set up the database:
-- Create the database
CREATE DATABASE hahasaas;
-- Create caetgories table
CREATE TABLE categories (
id SERIAL PRIMARY KEY,
name VARCHAR(100) UNIQUE NOT NULL
);
-- Create jokes table
CREATE TABLE jokes (
id SERIAL PRIMARY KEY,
content TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Create jokes_categories table (many-to-many relationship)
CREATE TABLE jokes_categories (
joke_id INT REFERENCES jokes(id),
category_id INT REFERENCES categories(id),
PRIMARY KEY (joke_id, category_id)
);
-- Create joke_reactions table
CREATE TABLE joke_reactions (
joke_id INT REFERENCES jokes(id),
likes INT DEFAULT 0,
dislikes INT DEFAULT 0,
PRIMARY KEY (joke_id)
);
- Configure environment variables; put it where go files are located
# Create .env file in the root directory
cp .env.example .env
# Update the following variables
DB_HOST=localhost
DB_PORT=5432
DB_USER=your_username
DB_PASSWORD=your_password
DB_NAME=hahasaas
- Install frontend dependencies:
npm install
- Install backend dependencies:
cd backend
go mod download
- Start the backend server:
cd backend/cmd/server
go run .
- Start the frontend development server:
npm run dev
- Access the application at
http://localhost:5173
The terminal interface supports the following commands:
help
: Display available commandsclear
: Clear the terminal screenrndj
: Get a random jokerndj --category|-c CATEGORY
: Get a random joke from a specific categorylsc
: List all categorieslsj
: List all jokeslsj --category|-c CATEGORY
: List jokes in a specific categorycatj --id ID
: Get a specific joke by IDaddc CATEGORY
: Add a new categoryaddj --category|-c CATEGORY JOKE
: Add a new joke to a categoryaddj --category|-c CATEGORY --id ID
: Add an existing joke to another categorygood --id ID
: Like a jokebad --id ID
: Dislike a joke
GET /api/joke/random
: Get a random jokeGET /api/joke/random/:category
: Get a random joke from a categoryGET /api/joke/categories
: Get all categoriesGET /api/joke/all
: Get all jokesGET /api/joke/category/:category
: Get jokes by categoryGET /api/joke/:id
: Get a specific jokePOST /api/joke/category
: Add a new categoryPOST /api/joke
: Add a new jokePOST /api/joke/category/:category/:id
: Add joke to categoryPOST /api/joke/:id/like
: Like a jokePOST /api/joke/:id/dislike
: Dislike a joke
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Powered by jokes lol