This is a RESTful API built with Go, Gin, and MySQL, providing core e-commerce functionalities like user management, product management, and order processing.
Features
User Management:
User registration with secure password hashing (bcrypt).
User login with JWT (JSON Web Token) authentication.
Docker and Docker Compose (recommended for local development).
A MySQL server (if not using Docker).
Local Development
Clone the repository:
git clone https://github.com/geekygeeky/basic-ecommerce-api.git
cd basic-ecommerce-api
Set up MySQL: Create a MySQL database and user with appropriate permissions.
Set environment variables: Create a .env file in the project root with the following content, replacing the placeholders with your actual values:
DB_USER=<your_db_user>
DB_PASSWORD=<your_db_password>
DB_NAME=<your_db_name>
DB_HOST=localhost # Or the address of your MySQL server
JWT_SECRET=<your_very_strong_secret>
Run the application:
go run cmd/api/main.go
Access the API:
The API will be available at http://localhost:8080.
Running Migrations
The project includes database migrations. To run them (you will need migrate CLI):