# Go Server

A scalable backend boilerplate built with **Go**, **Gin**, **GORM**, **PostgreSQL**, and **Redis**.

---

## Technologies Used

- **Go** - Core language
- **Gin** - HTTP framework
- **GORM** - ORM for PostgreSQL
- **Redis** - In-memory caching
- **Docker** - Containerization (optional)

## Features

- **RESTful API** using Gin
- **PostgreSQL + Redis** integration
- **Modular service-based architecture**
- **Middleware support** (CORS, Logging)
- **Graceful shutdown handling**
- **Environment variable configuration**

---

## Getting Started

### Installation

1. Create a `.env` file and configure database credentials:

   ```bash
   cp .env.example .env
   ```

2. Install dependencies:

   ```bash
   go mod tidy
   ```

3. Run the database migrations (if applicable):

   ```bash
   go run scripts/migrate.go
   ```

4. Generate templates

   ```bash
   go get -tool github.com/a-h/templ/cmd/templ@latest
   go tool templ generate
   ```

5. Start the server:

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

   The server should be running at **http://localhost:8080**

---

## 📂 Project Structure

```
├── config/          # Configuration files
├── controllers/     # API Controllers
├── models/         # Database Models
├── routes/         # Route Handlers
├── services/       # Business Logic Layer
├── database/       # DB Connection & Migrations
├── middleware/     # Middleware (CORS, Auth, Logging)
├── main.go         # Entry Point
└── .env.example    # Environment Config Sample
```
