A comprehensive backend API built with Go and the Gin framework. This application provides CRUD operations for books, user authentication, logging, rate limiting, and more.
- User Authentication: Secure user registration and login using JWT.
- CRUD for Books: Create, read, update, and delete operations for books.
- Logging: Logs user activities and system events.
- Rate Limiting: Prevents abuse by limiting the number of API requests.
- Email Utilities: Send emails for notifications or password resets.
- Password Utilities: Securely hash and verify passwords.
- Go (version 1.16 or newer)
- PostgreSQL
- SMTP server (for email utilities)
-
Clone the repository:
git clone https://github.com/astergginete/golang-backend-api.git cd golang-backend-api
-
Install the required Go packages:
go mod download
-
Set up your PostgreSQL database and update the connection string in the configuration.
-
Run the database migrations:
# Assuming you have a migration tool set up migration_tool run internal/migrations/
-
(Optional) Set up your SMTP server details in the configuration for email utilities.
-
Start the server:
go run cmd/server/main.go
-
The server will start on the default port (e.g.,
8080
). You can access the API athttp://localhost:8080
.
- Register:
POST /users/register
- Login:
POST /users/login
- Get User Profile:
GET /users/profile
- Update User Profile:
PUT /users/profile
- Delete User:
DELETE /users/delete
- List All Books:
GET /books
- Get Single Book:
GET /books/:id
- Create Book:
POST /books
- Update Book:
PUT /books/:id
- Delete Book:
DELETE /books/:id
- Get All Logs:
GET /logs
- Get Log by ID:
GET /logs/:id
(Add more endpoints as necessary)
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes.
- Push to your fork.
- Submit a pull request.
This project is licensed under the MIT License. See the LICENSE
file for details.