This project is a REST API developed as part of the Backend Development course at Iran University of Science and Technology (IUST), CESA College. The API uses PostgreSQL and MySQL as databases, Redis for caching, and is built using the Gin framework and Gorm for ORM. The entire application is Dockerized for easy deployment and scalability.
- Features
- Technologies Used
- Setup and Installation
- API Endpoints
- Dockerization
- Contributing
- License
- Acknowledgements
- Dual Database Support: The API supports both PostgreSQL and MySQL databases, allowing flexibility in database choice.
- Caching with Redis: Implements Redis for caching frequently accessed data to improve performance.
- RESTful API: Follows REST principles for clean and scalable API design.
- Dockerized: The entire application is containerized using Docker for easy deployment and testing.
- Gin Framework: Utilizes the high-performance Gin framework for building the API.
- Gorm ORM: Uses Gorm for database operations, providing a clean and efficient way to interact with databases.
- Backend Framework: Gin
- ORM: Gorm
- Databases: PostgreSQL, MySQL
- Caching: Redis
- Containerization: Docker
- Programming Language: Go (Golang)
- Other Tools: Git, GitHub, Docker Compose
- Docker and Docker Compose installed on your machine.
- Git for version control.
-
Clone the Repository:
git clone https://github.com/your-username/your-repo-name.git cd your-repo-name -
Set Up Environment Variables:
- Create a
.envfile in the root directory and add the necessary environment variables (e.g., database credentials, Redis URL, etc.). Example:
POSTGRES_USER=your_user POSTGRES_PASSWORD=your_password POSTGRES_DB=your_db REDIS_URL=redis://localhost:6379
- Create a
-
Build and Run with Docker:
docker-compose up --build
This command will build the Docker images and start the containers for the API, databases, and Redis.
-
Access the API:
- The API will be running at
http://localhost:8080.
- The API will be running at
Here are some of the key endpoints available in the API:
- GET /users: Fetch all users.
- POST /users: Create a new user.
- GET /users/{id}: Fetch a specific user by ID.
- PUT /users/{id}: Update a user by ID.
- DELETE /users/{id}: Delete a user by ID.
For a complete list of endpoints, refer to the API Documentation (if applicable).
The project is fully Dockerized, with separate containers for:
- The Go application (API)
- PostgreSQL database
- MySQL database
- Redis cache
The docker-compose.yml file defines the services and their configurations. You can easily modify it to suit your needs.
Contributions are welcome! If you'd like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes.
- Push your branch and open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Instructor: [Instructor Name] at Iran University of Science and Technology, CESA College.
- Gin Framework: https://github.com/gin-gonic/gin
- Gorm ORM: https://gorm.io/
This project demonstrates my skills in backend development, database management, caching, and containerization. It is a great addition to my resume and showcases my ability to build scalable and efficient REST APIs.
You can include this project in the Projects section of your resume with the following description:
Backend Development Project - REST API with PostgreSQL, MySQL, Redis, and Docker
- Developed a RESTful API using the Gin framework and Gorm ORM, supporting both PostgreSQL and MySQL databases.
- Implemented Redis for caching to improve API performance.
- Dockerized the application for easy deployment and scalability.
- Technologies: Go (Golang), Gin, Gorm, PostgreSQL, MySQL, Redis, Docker.
- GitHub Repository (link to your repo)
This project includes a Makefile to simplify common tasks. Here are some useful commands:
- Start the application:
make all-up ENV_FILE=.env - Stop the application:
make all-down ENV_FILE=.env - Run tests:
make test TEST_API_DIR=api TEST_SERVICE_DIR=service - Run database migrations:
make migrate-up ENV_FILE=.env - Clean up Docker resources:
make clean ENV_FILE=.env
This project uses environment variables for configuration. Create a .env file in the root directory and add the following variables:
# Database Configuration
DB_DRIVER=postgres
DB_HOST=db
DB_PORT=5432
DB_USER=library
DB_PASSWORD=pass-example
DB_NAME=example
# Redis Configuration
CACHE_HOST=redis
CACHE_PORT=6379
CACHE_PASSWORD=pass-example
CACHE_DB=0
# HTTP Server Configuration
HTTP_URL=localhost
HTTP_PORT=8080
# Docker Configuration
DOCKER_HUB_USERNAME=example
IMAGE_TAG=alpinelinux/golang
HOST_PORT=8080
CONTAINER_PORT=8080
# Application Configuration
GIN_MODE=debug
APP_ENV=development
LOG_LEVEL=debug
MIGRATION_PATH=./migrations
This README and resume description will help you showcase your project effectively to potential employers or collaborators. Good luck! 🚀