A comprehensive REST API for managing restaurant operations including table sessions, menu items, orders, and more. Built with Go and Gin framework, containerized with Docker for easy deployment.
- Session Management: Handle customer table sessions with start/end times
- Table Management: Manage restaurant tables and availability
- Menu Management: Create and manage menu items with categories
- Order Management: Process customer orders with menu items
- Category Management: Organize menu items by categories
- Pagination & Filtering: Efficient data retrieval with pagination support
- Input Validation: Robust validation using struct tags and custom validators
- Error Handling: Comprehensive error handling with custom middleware
- API Documentation: Auto-generated Swagger documentation
- Database Migrations: PostgreSQL migrations for schema management
- Microservice-Ready Architecture: Modular design with clear separation of concerns
The application follows a clean, modular architecture designed for easy transition to microservices:
internal/
├── menu/ # Menu domain module
│ ├── handler.go # HTTP handlers
│ ├── service.go # Business logic
│ ├── repository.go # Data access
│ ├── models.go # Domain models
│ ├── validation.go # Request validation
│ └── validator.go # Validation utilities
├── order/ # Order domain module
│ ├── handler.go
│ ├── service.go
│ ├── repository.go
│ ├── models.go
│ ├── validation.go
│ └── validator.go
└── session/ # Session domain module
├── handler.go
├── service.go
├── repository.go
├── models.go
├── validation.go
└── validator.go
Each module is self-contained with:
- Handler: HTTP request handling and routing
- Service: Business logic and orchestration
- Repository: Database operations
- Models: Domain entities
- Validation: Input validation and request DTOs
This structure allows each module to be extracted into a separate microservice with minimal changes.
- Backend: Go 1.25.5
- Framework: Gin Web Framework
- Database: PostgreSQL
- Validation: go-playground/validator
- Containerization: Docker & Docker Compose
- API Documentation: Swagger/OpenAPI
- Docker Desktop (latest version)
- Docker Compose (included with Docker Desktop)
- Git
git clone <repository-url>
cd restaurant# Build and start all containers (PostgreSQL + API)
docker compose up -d
# View logs
docker compose logs -f
# View application logs only
docker compose logs -f app# Check running containers
docker compose ps
# Test API health
curl http://localhost:8080/docsdocker compose downOnce the application is running, visit:
- Swagger UI: http://localhost:8080/docs
- API Base URL: http://localhost:8080
- Import the Postman collection:
Restaurant_API.postman_collection.json - Import the environment:
Restaurant_API.postman_environment.json - Update environment variables if needed (default: localhost:8080)
- Run the collection to test all endpoints
restaurant/
├── cmd/app/ # Application entry point
├── internal/
│ ├── cache/ # Caching layer
│ ├── middleware/ # HTTP middleware
│ ├── optimization/ # Query optimization
│ ├── pool/ # Connection pooling
│ ├── response/ # Response formatting
│ ├── session/ # Session management module
│ │ ├── handler/ # HTTP handlers
│ │ ├── models/ # Data models
│ │ ├── repository/ # Data access layer
│ │ ├── service/ # Business logic
│ │ └── validation/ # Input validation
│ └── shutdown/ # Graceful shutdown
├── migrations/ # Database migrations
├── docs/ # Generated API docs
├── documentation/ # Project documentation
├── docker-compose.yml # Docker services
├── Dockerfile # Application container
└── go.mod # Go dependencies
- Install Go 1.25.5+
- Set up PostgreSQL (or use Docker)
- Install dependencies:
go mod download
- Run migrations:
# Using migrate tool or custom script - Start the application:
go run ./cmd/app
Migrations are located in the migrations/ directory. Use your preferred migration tool to apply them.
# Run unit tests
go test ./...
# Run with coverage
go test -cover ./...GET /sessions- List all sessionsPOST /sessions- Create new sessionGET /sessions/{id}- Get session by IDPUT /sessions/{id}- Update sessionDELETE /sessions/{id}- Delete session
GET /tables- List all tablesPOST /tables- Create new tableGET /tables/{id}- Get table by IDDELETE /tables/{id}- Delete table
GET /menu- List menu items (with pagination)POST /menu- Create menu itemGET /menu/{id}- Get menu item by IDPUT /menu/{id}- Update menu itemDELETE /menu/{id}- Delete menu item
GET /categories- List all categoriesPOST /categories- Create new categoryGET /categories/{id}- Get category by IDPUT /categories/{id}- Update categoryDELETE /categories/{id}- Delete category
GET /orders- List all ordersPOST /orders- Create new orderGET /orders/{id}- Get order by IDPUT /orders/{id}- Update orderDELETE /orders/{id}- Delete order
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This backend code for the Intellidine Restaurant App is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
You may not use this work for commercial purposes.
See the LICENSE file for full details: https://creativecommons.org/licenses/by-nc/4.0/.