π₯ eRestourant
A simple restaurant backend service built with Go and the Gin web framework. It supports environment-based configuration and PostgreSQL integration.
π Project Structure
.
βββ build/ # Compiled binary output
βββ cmd/
β βββ api/ # Main application entry point
β βββ main.go
βββ config/ # Configuration-related code
βββ internal/ # Application logic (handlers, services, etc.)
βββ sqlc.yaml # SQLC config for database interaction
βββ go.mod / go.sum # Go module definitions
βββ .env # Environment variables
βββ makefile # Build/run automation
βββ README.md # Project documentation
π Getting Started
Prerequisites
βοΈ Configuration
Create a .env file in the root directory:
PORT=5000
ENV="DEVELOPMENT"
DB_CONN_URI="postgres://postgres:postgres@localhost:5432/erestourant"
π οΈ Build & Run
You can build and run the project using the makefile:
Build
make build
Run
make run
This will compile the code and run the server at:
http://localhost:5000
π§Ή Clean Build Artifacts
make clear
ποΈ Database
The project expects a PostgreSQL database running with the following default config (can be changed in .env):
- User:
postgres
- Password:
postgres
- Database:
erestourant
- Host:
localhost
- Port:
5432
π¦ Dependencies
Install dependencies via:
go mod tidy
π Routes Overview
The API is organized into modular route groups:
π Auth Routes
Handles user authentication
| Method |
Endpoint |
Description |
| POST |
/auth/login |
Log in a user |
| POST |
/auth/register |
Register a new user |
Manages menu items in the restaurant
| Method |
Endpoint |
Description |
| GET |
/menu/ |
Get all menu items |
| GET |
/menu/:id |
Get details of a menu item by ID |
| POST |
/menu/ |
Create a new menu item |
| PUT |
/menu/:id |
Update a menu item by ID |
| DELETE |
/menu/:id |
Delete a menu item by ID |
π Order Routes
Manages customer orders
| Method |
Endpoint |
Description |
| GET |
/order/ |
Get all orders |
| GET |
/order/:id |
Get order details by ID |
| GET |
/checkout/order/:id |
Marks an order a complete |
| POST |
/order/ |
Create a new order |
| PUT |
/order/:id |
Update an existing order |
| DELETE |
/order/:id |
Delete an order by ID |
π€ User Routes
Handles user management
| Method |
Endpoint |
Description |
| GET |
/user/ |
Get all users |
| GET |
/user/:id |
Get user details by ID |
| DELETE |
/user/:id |
Delete a user by ID |
π TODO
- Implement authentication middeware
- Implement some admin features