{"id":20882074,"url":"https://github.com/gitkashish/ecommerce-api-go","last_synced_at":"2026-05-15T11:35:07.390Z","repository":{"id":243941819,"uuid":"811552948","full_name":"gitKashish/ecommerce-api-go","owner":"gitKashish","description":"A Go-based e-commerce API providing user authentication, product listing, and cart checkout functionalities. Features include JWT authentication and MySQL database migrations. ","archived":false,"fork":false,"pushed_at":"2024-06-11T21:35:22.000Z","size":3959,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-09T13:09:10.490Z","etag":null,"topics":["golang","jwt-authentication","mysql","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gitKashish.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-06T20:25:42.000Z","updated_at":"2024-06-11T21:35:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"eb511377-6629-4286-af63-06605d34873c","html_url":"https://github.com/gitKashish/ecommerce-api-go","commit_stats":null,"previous_names":["gitkashish/ecommerce-api-go"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gitKashish/ecommerce-api-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitKashish%2Fecommerce-api-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitKashish%2Fecommerce-api-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitKashish%2Fecommerce-api-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitKashish%2Fecommerce-api-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gitKashish","download_url":"https://codeload.github.com/gitKashish/ecommerce-api-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitKashish%2Fecommerce-api-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33065593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-15T02:00:06.351Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","jwt-authentication","mysql","rest-api"],"created_at":"2024-11-18T07:28:54.906Z","updated_at":"2026-05-15T11:35:07.364Z","avatar_url":"https://github.com/gitKashish.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# E-commerce API in Go\n\nThis project provides a RESTful API for an e-commerce application, developed in Go. The API supports user authentication, product listing, and cart checkout functionalities.\n\n## Features\n\n- **User Login**\n- **User Registration**\n- **Product Listing**\n- **Cart Checkout**\n- **JWT Authentication**\n- **MySQL Database Migrations**\n\n## Getting Started\n\n### Prerequisites\n\n- Go 1.22 (utilizes new `net/http` enhancements)\n- MySQL\n- GNU Make\n\n### Installation\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/gitKashish/ecommerce-api-go.git\n   ```\n   \n3. Navigate to the project directory:\n\n   ```bash\n   cd ecommerce-api-go\n   ```\n   \n4. Install dependencies:\n\n   ```bash\n   go mod tidy\n   ```\n\n### Database Setup\n\n1. Create a MySQL database:\n\n   ```sql\n   CREATE DATABASE ecom;\n   ```\n   \n3. Run the `UP` database migrations:\n\n   ```bash\n   make migrate-up\n   ```\n   \n4. Run the `DOWN` database migrations: (Drops tables)\n\n   ```bash\n   make migrate-down\n   ```\n   \n\n### Running the API\n\n1. Set up your environment variables:\n  Create a `.env` file in the project's root directory.\n\n    ```env\n    PublicHost = dbPublicHost\n    Port = portNumber\n    DBUser = dbUserName\n    DBPassword = dbPassword\n    DBAdress = dbPublicHost:portNumber\n    DBName = ecom\n    JWTExpirationInSeconds = 3600*24*7\n    JWTSecret = notSoSecret\n    ```\n    \n3. Build the executable:\n\n   ```bash\n   make build\n   ```\n   \n5. Start the server: (Builds \u0026 runs)\n\n   ```bash\n   make run\n   ```\n   \n7. The API will be available at `http://localhost:8080`.\n\n## API Endpoints\n\n### User Authentication\n\n#### Register a New User\n\n- **Endpoint:** `POST /v1/register`\n- **Description:** Register a new user.\n- **Request Body:**\n  \n  ```json\n  {\n    \"firstName\": \"exampleFirstName\",\n    \"lastName\": \"exampleLastName\",\n    \"email\": \"user@example.com\",\n    \"password\": \"examplePassword\"\n  }\n  ```\n  \n- **Response:**\n\n  ```json\n  {\n    \"message\": \"User registered successfully\"\n  }\n  ```\n\n#### User Login\n\n- **Endpoint:** `POST /v1/login`\n- **Description:** Log in an existing user.\n- **Request Body:**\n\n  ```json\n  {\n    \"username\": \"exampleUser\",\n    \"password\": \"examplePassword\"\n  }\n  ```\n  \n- **Response:**\n\n  ```json\n  {\n    \"token\": \"jwt-token\"\n  }\n  ```\n\n### Products\n\n#### Get Products List\n\n- **Endpoint:** `GET /v1/products`\n- **Description:** Retrieve a list of available products.\n- **Response:**\n\n  ```json\n  [\n    {\n      \"id\": 1,\n      \"name\": \"Product 1\",\n      \"description\": \"Description of product 1\",\n      \"image\": \"path/to/image1\",\n      \"price\": 200.0,\n      \"quantity\" : 6,\n      \"createdAt\" : \"2024-06-10T19:18:24Z\"\n    },\n    {\n      \"id\": 2,\n      \"name\": \"Product 2\",\n      \"description\": \"Description of product 2\",\n      \"image\": \"path/to/image2\",\n      \"price\": 150.0,\n      \"quantity\" : 10,\n      \"createdAt\" : \"2024-06-08T19:18:24Z\"\n    }\n  ]\n  ```\n\n### Cart\n\n#### Checkout\n\n- **Endpoint:** `POST /v1/cart/checkout`\n- **Description:** Checkout the cart and create an order.\n- **Request Body:**\n\n  ```json\n  {\n    \"cartItems\": [\n      {\n        \"productId\": 1,\n        \"quantity\": 2\n      },\n      {\n        \"productId\": 2,\n        \"quantity\": 1\n      }\n    ]\n  }\n  ```\n  \n- **Response:**\n\n  ```json\n  {\n    \"order_id\": 14,\n    \"total_price\": 550.0\n  }\n  ```\n\n## Contributing\n\nContributions are most welcome! Please fork the repository and create a pull request with your changes.\n\nHappy coding! 🎉\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitkashish%2Fecommerce-api-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgitkashish%2Fecommerce-api-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitkashish%2Fecommerce-api-go/lists"}