Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/itscodemen/sales_analysis

This is a demo Go project demonstrating GIN, Logging, Refresh cron job and Loading data from CSV to db
https://github.com/itscodemen/sales_analysis

gin gin-gonic go golang mysql

Last synced: 2 months ago
JSON representation

This is a demo Go project demonstrating GIN, Logging, Refresh cron job and Loading data from CSV to db

Awesome Lists containing this project

README

        

# Sales Analysis API

A RESTful API for analyzing historical sales data using Go, Gin framework, and MySQL.

## Prerequisites

- **Go 1.16+**
- **MySQL**

## Setup

1. **Clone the Repository:**

```bash
git clone
cd sales-analysis
```

2. **Set Up Environment Variables:**

Create a `.env` file with:

```env
DB_USER=
DB_PASSWORD=
DB_NAME=
DB_HOST=
DB_PORT=
```

3. **Install Dependencies:**

```bash
go mod tidy
```

4. **Run the Application:**

```bash
go run main.go
```

The server will start on port `8080`.

## API Endpoints

### Get Total Revenue

- **URL:** `/revenue`
- **Method:** `GET`
- **Query Parameters:**
- `start_date`: `YYYY-MM-DD`
- `end_date`: `YYYY-MM-DD`

### Sample Request

```http
GET /revenue?start_date=2023-01-01&end_date=2023-12-31