/ai-cam-assistent-api

Golang API for GenAI integration.

Primary LanguageDockerfileMIT LicenseMIT

AI Cam Assistant

This repository contains the AI Cam Assistant API, built with Golang using the Gin framework. The API follows the MVC (Model-View-Controller) design pattern and is containerized using Docker. The primary functionality of the API is to receive an image via a POST method and return a text description of the image using generative AI.

Project Structure

The project is organized according to the MVC pattern, with all source code contained within the ./src directory:

  • Model: Handles the data structure and any interactions with the data layer. This includes struct definitions for the image data and the AI-generated descriptions.

  • View: In the context of an API, the "view" is the response sent back to the client. This will be JSON-formatted data containing the text description generated by the AI.

  • Controller: Manages the logic of handling incoming requests, processing them with the model, and returning the appropriate view. The controller will handle the image upload, send it to the AI model for processing, and then return the generated description.

Directory Layout

├── src
│   ├── controllers         # Contains the business logic for processing requests
│   │   
│   ├── models              # Contains data structures and interaction with data storage
│   │   
│   ├── views               # Handles formatting of the responses
│   │   
│   ├── main.go             # Entry point of the application
│   ├── go.mod              # Module file for dependency management
│   └── go.sum              # Module checksums file

API Endpoints

POST /api/v1/describe-image

This endpoint accepts an image file and returns a text description generated by a generative AI model.

Request:

  • Method: POST
  • URL: /api/v1/describe-image

Response:

  • 200 OK: Returns a JSON object with the text description.
  • Content-Type: application/json
  • Body:
    {
      "description": "A description of the image generated by AI."
    }

Running the Project

Prerequisites

  • Docker: Ensure Docker is installed and running on your system.

Steps to Run

  1. Clone the repository:

    git clone https://github.com/Antonini877/ai-cam-assistent-api.git
    cd ai-cam-assistent
  2. Build the Docker image:

    docker-compose build --no-cache
  3. Run the Docker container:

    docker-compose up
  4. Test the API: Use a tool like Postman or cURL to send a POST request to http://localhost:8080/api/v1/describe-image with an image file.

About the Gin Framework

The Gin framework is a high-performance web framework for Go (Golang). It provides a lightweight and efficient API for building web applications and microservices. Key features include fast routing, middleware support, and JSON handling, making it an ideal choice for building scalable APIs like the AI Cam Assistant.

Future Improvements

  • Add authentication for API endpoints.
  • Implement more advanced image analysis features.
  • Optimize the AI model for faster and more accurate descriptions.

License

This project is licensed under the MIT License.