A high-performance, production-ready dictionary service with blazing-fast lookups, autocomplete, and a beautiful web interface.
Dictionary Service is a complete dictionary application built with Go and React, designed for high performance and easy deployment. It features instant word lookups, intelligent autocomplete suggestions, and a modern web interface.
- β‘ Lightning Fast: 5-10x faster loading than JSON with compressed gob format
- π O(1) Lookups: Map-based structure for instant word lookups
- π― Smart Autocomplete: Efficient prefix-based word suggestions
- π¨ Beautiful UI: Modern React frontend with Tailwind CSS and Heroicons
- π³ Docker Ready: Single container deployment with frontend + backend
- π¦ Compressed Storage: 60-80% smaller file size with gzip compression
- ποΈ SOLID Architecture: Clean, maintainable, and extensible codebase
- π RESTful API: Clean HTTP API with OpenAPI documentation
- π Production Ready: Health checks, logging, and monitoring support
- Go 1.25+ (for building from source)
- Docker (for containerized deployment)
- Node.js 18+ (for frontend development, optional)
-
Convert your dictionary JSON to gob format:
go run cmd/convert/main.go dictionary.json dictionary.gob
-
Run with Docker:
docker build -t dictionary-service . docker run -d -p 8080:8080 --name dictionary dictionary-service -
Access the application:
- Frontend: http://localhost:8080
- API: http://localhost:8080/api/v1/stats
That's it! π
For more detailed instructions, see QUICKSTART.md.
- Installation
- Usage
- API Documentation
- Deployment
- Architecture
- Performance
- Development
- Contributing
- License
# Clone the repository
git clone https://github.com/yourusername/dictionary-service.git
cd dictionary-service
# Convert your dictionary (if needed)
go run cmd/convert/main.go dictionary.json dictionary.gob
# Build and run
docker-compose up -d# Clone the repository
git clone https://github.com/yourusername/dictionary-service.git
cd dictionary-service
# Build backend
go build ./cmd/server
# Build frontend
cd frontend
npm install
npm run build
cd ..
# Run server
./server -dict dictionary.gob -addr :8080 -static frontend/dist# Lookup a word
go run main.go -dict dictionary.gob hello
# Output:
# Word: hello
# Meanings: ["Ψ³ΩΨ§Ω
", "Ψ―Ψ±ΩΨ―"]# Start the server
go run cmd/server/main.go -dict dictionary.gob -addr :8080
# Or use the binary
./server -dict dictionary.gob -addr :8080The React frontend provides a beautiful, interactive interface:
- Real-time search with autocomplete
- Instant word lookups
- Responsive design
- Dark mode support
Access at: http://localhost:8080
# Start services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/api/v1/words/{word} |
GET | Lookup word meanings |
/api/v1/suggest/{prefix} |
GET | Get autocomplete suggestions |
/api/v1/stats |
GET | Get dictionary statistics |
# Health check
curl http://localhost:8080/health
# Lookup word
curl http://localhost:8080/api/v1/words/hello
# Autocomplete
curl http://localhost:8080/api/v1/suggest/hel?limit=10
# Statistics
curl http://localhost:8080/api/v1/stats- API.md - Complete API reference with examples
- openapi.yaml - OpenAPI 3.0 specification
- API Documentation - Documentation index
# Build image
docker build -t dictionary-service:latest .
# Run container
docker run -d \
-p 8080:8080 \
--name dictionary \
--restart unless-stopped \
dictionary-service:latestFor comprehensive production deployment guide, see PRODUCTION.md.
Includes:
- Building dictionary files
- Docker image creation
- Kubernetes deployment
- Nginx reverse proxy setup
- Monitoring and maintenance
- Troubleshooting
If deploying behind a gateway with path prefix (e.g., /dictionary/), see:
- NGINX_GATEWAY.md - Complete gateway configuration
- GATEWAY_FIX.md - Quick fix guide
version: '3.8'
services:
dictionary:
build: .
ports:
- "8080:8080"
volumes:
- ./dictionary.gob:/app/dictionary.gob:ro
restart: unless-stoppeddictionary-service/
βββ cmd/
β βββ convert/ # JSON to gob conversion utility
β βββ server/ # HTTP server application
βββ internal/
β βββ dictionary/ # Core dictionary logic
β β βββ dictionary.go # Service and loader
β β βββ converter.go # JSON converter
β βββ server/ # HTTP server components
β βββ handlers.go # Request handlers
β βββ middleware.go # CORS, logging
β βββ router.go # Route configuration
βββ frontend/ # React web application
β βββ src/
β β βββ App.jsx # Main component
β β βββ ...
β βββ package.json
βββ docs/ # Documentation
β βββ API.md
β βββ openapi.yaml
βββ Dockerfile # Multi-stage build
βββ docker-compose.yml # Docker Compose config
βββ README.md
The codebase follows SOLID principles:
- Single Responsibility: Each package has one clear purpose
- Open/Closed: Extensible through interfaces (e.g.,
Loader) - Liskov Substitution: Implementations are swappable
- Interface Segregation: Small, focused interfaces
- Dependency Inversion: Depend on abstractions
- Dictionary Service: Core lookup and suggestion logic
- HTTP Handlers: RESTful API endpoints
- Static File Server: Serves React frontend
- Middleware: CORS, logging, health checks
| Metric | Performance |
|---|---|
| Dictionary Loading | ~0.3-0.8s for 910K words |
| Word Lookup | O(1) - < 1ms |
| Autocomplete | O(log n) + O(k) - < 10ms |
| File Size | 60-80% smaller than JSON |
| Memory Usage | ~200-400MB for 910K words |
- Compressed Storage: Gzip-compressed gob format
- Map-based Lookups: O(1) constant time
- Binary Search: Efficient prefix matching
- Single Container: Reduced network overhead
- Go 1.25+
- Node.js 18+
- Docker (optional)
# Clone repository
git clone https://github.com/yourusername/dictionary-service.git
cd dictionary-service
# Install Go dependencies
go mod download
# Install frontend dependencies
cd frontend
npm install
cd ..# Build backend
go build ./cmd/server
# Build frontend
cd frontend
npm run build
cd ..
# Build everything
go build ./...# Run Go tests
go test ./...
# Run frontend tests (when added)
cd frontend
npm test# Terminal 1: Run backend
go run cmd/server/main.go -dict dictionary.gob -addr :8080
# Terminal 2: Run frontend dev server
cd frontend
npm run dev- Backend: Go with standard project layout
- Frontend: React with Vite
- API: RESTful with OpenAPI spec
- Testing: Go testing framework
Contributions are welcome! Please feel free to submit a Pull Request.
We have a detailed Contributing Guide that covers:
- Code of conduct
- Development setup
- Code style guidelines
- Pull request process
- Reporting bugs and suggesting features
Quick Start:
- 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
See CONTRIBUTING.md for complete guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Go and React
- UI components from Headless UI
- Icons from Heroicons
- Styling with Tailwind CSS
- QUICKSTART.md - Get started in 5 minutes
- PRODUCTION.md - Production deployment guide
- DOCKER.md - Docker-specific documentation
- NGINX_GATEWAY.md - Gateway configuration
- docs/API.md - Complete API reference
- frontend/README.md - Frontend documentation
If you find this project useful, please consider giving it a star! β
- Documentation: Check the docs directory
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with β€οΈ by the Mahdi Mazaheri