211 lines
7.0 KiB
Markdown
211 lines
7.0 KiB
Markdown
# 🎭 GoMeme - Concurrent Meme Generator & Server
|
|
|
|
[](https://golang.org)
|
|
[](LICENSE)
|
|
[](#)
|
|
|
|
## Overview
|
|
|
|
Welcome to **GoMeme** - a blazingly fast, concurrent meme generator built in Go that proves you don't need a fucking PhD in Computer Science to create something both useful and entertaining. This project showcases Go's concurrency model through a practical, scalable web application that generates memes faster than your brain can process dad jokes.
|
|
|
|
> *"Because manual meme creation is for peasants, and automation is the future."* - Someone who definitely doesn't work in manual labor
|
|
|
|
## 🚀 Features
|
|
|
|
### Core Functionality
|
|
- **Concurrent Processing**: Utilizes Go's goroutines and channels for lightning-fast meme generation
|
|
- **RESTful API**: Clean, documented endpoints for programmatic meme creation
|
|
- **Web Interface**: User-friendly HTML interface for those who prefer clicking to coding
|
|
- **Template System**: Extensible meme template architecture
|
|
- **Real-time Generation**: Live meme creation with shareable URLs
|
|
- **Graceful Shutdown**: Because crashing servers are so 2010
|
|
|
|
### Technical Highlights
|
|
- **5 Concurrent Workers**: Because multitasking is better than sitting around waiting
|
|
- **Gorilla Mux Router**: Professional-grade HTTP routing (no, not the animal)
|
|
- **Image Processing**: Dynamic text overlay with outline support
|
|
- **Template Management**: Modular template system for easy expansion
|
|
- **Health Monitoring**: Built-in health checks and status reporting
|
|
|
|
## 🛠️ Technical Architecture
|
|
|
|
### Project Structure
|
|
```
|
|
gomeme/
|
|
├── cmd/server/ # Application entry point
|
|
├── internal/
|
|
│ ├── meme/ # Core meme generation logic
|
|
│ ├── server/ # HTTP server and routing
|
|
│ └── templates/ # Template management
|
|
├── web/
|
|
│ ├── static/ # Static assets and generated memes
|
|
│ └── templates/ # HTML templates
|
|
├── assets/ # Meme template assets
|
|
└── bin/ # Compiled binaries
|
|
```
|
|
|
|
### Concurrency Model
|
|
- **Worker Pool**: 5 background goroutines handle meme generation jobs
|
|
- **Job Queue**: Buffered channel (100 capacity) manages generation requests
|
|
- **Mutex Protection**: Thread-safe access to shared meme storage
|
|
- **Graceful Shutdown**: Context-based cleanup for clean exits
|
|
|
|
## 📦 Installation & Setup
|
|
|
|
### Prerequisites
|
|
- **Go 1.21+**: Because we're not living in the stone age
|
|
- **Git**: For cloning, obviously
|
|
- **Basic Understanding of Humor**: Optional but recommended
|
|
|
|
### Quick Start
|
|
|
|
```bash
|
|
# Clone the repository
|
|
git clone https://github.com/iwasforcedtobehere/gomeme.git
|
|
cd gomeme
|
|
|
|
# Install dependencies
|
|
go mod tidy
|
|
|
|
# Build the application
|
|
go build -o bin/gomeme ./cmd/server
|
|
|
|
# Run the server
|
|
./bin/gomeme
|
|
```
|
|
|
|
Or if you prefer the development approach:
|
|
|
|
```bash
|
|
# Run directly with Go
|
|
go run ./cmd/server
|
|
```
|
|
|
|
The server will start on `http://localhost:8080` and immediately begin accepting requests for your meme generation needs.
|
|
|
|
## 🎯 API Documentation
|
|
|
|
### Endpoints
|
|
|
|
#### `GET /`
|
|
The main web interface. Perfect for humans who haven't yet embraced full automation.
|
|
|
|
#### `POST /generate`
|
|
Web form submission endpoint. Accepts form data and returns HTML with your freshly minted meme.
|
|
|
|
#### `POST /api/v1/memes`
|
|
**Request Body:**
|
|
```json
|
|
{
|
|
"template": "drake",
|
|
"top_text": "Manual meme creation",
|
|
"bottom_text": "Using GoMeme's automated system"
|
|
}
|
|
```
|
|
|
|
**Response:**
|
|
```json
|
|
{
|
|
"id": 42,
|
|
"filename": "meme_42_drake_1694534400.png",
|
|
"share_url": "/api/v1/memes/42",
|
|
"template": "drake"
|
|
}
|
|
```
|
|
|
|
#### `GET /api/v1/memes/{id}`
|
|
Retrieve a specific meme by ID. Because sometimes you need to admire your past work.
|
|
|
|
#### `GET /api/v1/templates`
|
|
List all available meme templates. Currently includes classics like:
|
|
- **Drake Pointing**: The OG approval/disapproval format
|
|
- **Distracted Boyfriend**: Relationship dynamics in image form
|
|
- **Woman Yelling at Cat**: Peak internet culture representation
|
|
- **Change My Mind**: For when you want to be controversial
|
|
- **This is Fine**: Perfect for depicting your current life situation
|
|
|
|
#### `GET /api/v1/health`
|
|
Health check endpoint. Returns status and a reassuring message that everything is fucking fantastic.
|
|
|
|
## 🎨 Available Templates
|
|
|
|
Currently supported meme templates (with more coming because the internet never stops creating):
|
|
|
|
1. **Drake** - The classic approval/disapproval format
|
|
2. **Distracted Boyfriend** - That guy looking at another option
|
|
3. **Woman Yelling at Cat** - Peak domestic drama
|
|
4. **Change My Mind** - Steven Crowder's debate setup
|
|
5. **This is Fine** - Dog in burning room (mood)
|
|
|
|
## 🧪 Testing & Development
|
|
|
|
### Running Tests
|
|
```bash
|
|
# Run all tests
|
|
go test ./...
|
|
|
|
# Run with coverage
|
|
go test -cover ./...
|
|
|
|
# Run specific package tests
|
|
go test ./internal/meme/
|
|
```
|
|
|
|
### Development Mode
|
|
The project includes VS Code tasks for streamlined development:
|
|
- **Run GoMeme Server**: Starts the server in development mode
|
|
- **Build**: Compiles the application
|
|
- **Test**: Runs the test suite
|
|
|
|
## 🚀 Deployment
|
|
|
|
### Docker Support
|
|
*Coming soon - because containerization is the future, and the future is now-ish*
|
|
|
|
### Binary Deployment
|
|
```bash
|
|
# Build for production
|
|
go build -ldflags="-w -s" -o gomeme ./cmd/server
|
|
|
|
# Run in production
|
|
./gomeme
|
|
```
|
|
|
|
## 🤝 Contributing
|
|
|
|
Contributions are welcome! Whether you want to add new templates, improve the concurrency model, or just fix my questionable commenting style, feel free to submit a PR.
|
|
|
|
### Development Guidelines
|
|
- Follow Go conventions (gofmt is your friend)
|
|
- Add tests for new features (testing is not optional)
|
|
- Document public APIs (future you will thank present you)
|
|
- Keep the humor level appropriate for professional settings (mostly)
|
|
|
|
## 📊 Performance
|
|
|
|
- **Generation Speed**: Sub-second meme creation
|
|
- **Concurrent Capacity**: 100 queued jobs, 5 parallel workers
|
|
- **Memory Usage**: Minimal footprint with efficient image processing
|
|
- **Scalability**: Horizontal scaling ready (add more goroutines, add more power)
|
|
|
|
## 🎭 Philosophy
|
|
|
|
This project embodies the principle that professional software development doesn't have to be boring as fuck. It demonstrates:
|
|
|
|
- **Practical Concurrency**: Real-world application of Go's concurrency primitives
|
|
- **Clean Architecture**: Separation of concerns without over-engineering
|
|
- **User Experience**: Both programmatic and human-friendly interfaces
|
|
- **Scalable Design**: Built to handle growth (because viral memes are a thing)
|
|
- **Code Quality**: Professional standards with a sense of humor
|
|
|
|
## 📝 License
|
|
|
|
MIT License - Because sharing is caring, and lawyers are expensive.
|
|
|
|
## 🙏 Acknowledgments
|
|
|
|
- **The Go Team**: For creating a language that doesn't make you want to throw your computer out the window
|
|
- **The Internet**: For providing endless meme inspiration
|
|
- **Coffee**: The real MVP behind this project
|
|
- **Stack Overflow**: For answering questions I didn't even know I had
|