Vixel API is a Go-based REST API for image management and processing. It allows users to register, authenticate, upload images, manage their image collections, and apply transformations to images.
This project is an application on the Image Processing Service
- User registration and authentication with JWT tokens
- Image upload and storage using MinIO object storage
- Image retrieval and management
- Image transformation capabilities
- PostgreSQL database for data persistence
- Go - Programming language
- Gin - Web framework
- PostgreSQL - Database
- MinIO - Object storage
- JWT - Authentication
- GORM - ORM for database operations
POST /api/v1/users- Register a new userPOST /api/v1/users/login- Login user
POST /api/v1/images- Upload an image (requires authentication)GET /api/v1/images/:id- Get image details (requires authentication)GET /api/v1/users/:user_id/images- List user's images (requires authentication)DELETE /api/v1/images/:id- Delete an image (requires authentication)
POST /api/v1/images/:id/transform- Transform an image
- Go 1.24 or later
- Docker and Docker Compose
- PostgreSQL (or use Docker)
-
Clone the repository:
git clone <repository-url> cd vixel-api
-
Install dependencies:
go mod download
-
Set up environment variables. Create a
.envfile in the root directory with the following variables:PORT=:8080 DATABASE_URL=postgres://user:password@localhost:5432/vixel?sslmode=disable JWT_SECRET=your-jwt-secret MINIO_ENDPOINT=localhost:9000 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_BUCKET=vixel-bucket -
Start MinIO using Docker Compose:
docker-compose up -d
-
Run the application:
go run app/main.go
The API will be available at http://localhost:8080.
First, register a new user:
curl -X POST http://localhost:8080/api/v1/users \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "password123"}'Login to get a JWT token:
curl -X POST http://localhost:8080/api/v1/users/login \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "password123"}'Use the returned token in subsequent requests by including it in the Authorization header:
Authorization: Bearer <your-jwt-token>
Upload an image file:
curl -X POST http://localhost:8080/api/v1/images \
-H "Authorization: Bearer <your-jwt-token>" \
-F "file=@/path/to/your/image.jpg" \
-F "alt_text=Description of the image"Apply transformations to an uploaded image:
curl -X POST http://localhost:8080/api/v1/images/1/transform \
-H "Content-Type: application/json" \
-d '{"transformations": ["resize", "grayscale"]}'- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.