{"id":17572341,"url":"https://github.com/letsmakecakes/blogging-platform-api","last_synced_at":"2026-01-30T05:03:36.138Z","repository":{"id":258267181,"uuid":"873117965","full_name":"letsmakecakes/blogging-platform-api","owner":"letsmakecakes","description":"A RESTful API for a blogging platform built using Go and Gin","archived":false,"fork":false,"pushed_at":"2024-10-18T16:02:26.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-19T10:56:04.672Z","etag":null,"topics":["api","api-rest","gin","gin-gonic","go","golang","postgres","postgresql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/letsmakecakes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-15T16:20:56.000Z","updated_at":"2024-10-18T16:02:30.000Z","dependencies_parsed_at":"2024-10-21T23:13:39.910Z","dependency_job_id":null,"html_url":"https://github.com/letsmakecakes/blogging-platform-api","commit_stats":null,"previous_names":["letsmakecakes/blogging-platform-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsmakecakes%2Fblogging-platform-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsmakecakes%2Fblogging-platform-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsmakecakes%2Fblogging-platform-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsmakecakes%2Fblogging-platform-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/letsmakecakes","download_url":"https://codeload.github.com/letsmakecakes/blogging-platform-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618262,"owners_count":21134200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-rest","gin","gin-gonic","go","golang","postgres","postgresql"],"created_at":"2024-10-21T19:03:53.589Z","updated_at":"2026-01-30T05:03:31.078Z","avatar_url":"https://github.com/letsmakecakes.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blogging Platform API\n\nA RESTful API for a blogging platform built using the [Gin Web Framework](https://github.com/gin-gonic/gin) in Golang. The API supports CRUD operations for blog posts, including optional filtering based on search terms.\n\n## Table of Contents\n\n- [Features](#features)\n- [Project Structure](#project-structure)\n- [Installation](#installation)\n- [Environment Variables](#environment-variables)\n- [Running the Project](#running-the-project)\n- [API Endpoints](#api-endpoints)\n- [Database Migrations](#database-migrations)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n- Create, read, update, and delete (CRUD) blog posts\n- Filter blog posts based on title, content, or category\n- API built with [Gin](https://github.com/gin-gonic/gin) framework\n- PostgreSQL integration\n- Struct-based validation\n- Easily extendable and customizable architecture\n- Structured logging\n- Environment-based configuration\n\n## Project Structure\n\n```\nblogging-platform-api/\n├── cmd/\n│   └── server/\n│       └── main.go         # Entry point for the application\n├── internal/\n│   ├── config/\n│   │   └── config.go       # Configuration loader\n│   ├── controllers/\n│   │   └── blog_controller.go # API Handlers for blog posts\n│   ├── models/\n│   │   └── blog.go         # Blog post model\n│   ├── repository/\n│   │   └── blog_repository.go # Database operations for blog posts\n│   ├── routes/\n│   │   └── routes.go       # Route definitions\n│   ├── services/\n│   │   └── blog_service.go # Business logic for blog posts\n│   └── utils/\n│       ├── response.go     # Utility functions for API responses\n│       └── validation.go   # Validation utilities\n├── pkg/\n│   └── db/\n│       └── db.go           # Database connection and initialization\n├── migrations/\n│   └── 001_create_blogs_table.sql # SQL migration for blogs table\n├── .env                     # Environment variables\n├── .gitignore                # Git ignore file\n├── go.mod                    # Go module definition\n├── go.sum                    # Go module dependencies\n└── README.md                 # Project documentation\n```\n\n## Installation\n\n1. Clone this repository:\n\n   ```bash\n   git clone https://github.com/your-username/blogging-platform-api.git\n   cd blogging-platform-api\n   ```\n\n2. Install dependencies:\n\n   ```bash\n   go mod tidy\n   ```\n\n3. Create and configure your `.env` file. (See [Environment Variables](#environment-variables) below.)\n\n4. Run database migrations (PostgreSQL) to create the necessary tables:\n\n   ```bash\n   psql -h \u003chost\u003e -d \u003cdatabase\u003e -U \u003cuser\u003e -f migrations/001_create_blogs_table.sql\n   ```\n\n## Environment Variables\n\nTo run this project, you'll need to set up the following environment variables in your `.env` file:\n\n```bash\n# Application\nPORT=8080\nENVIRONMENT=development  # or 'production'\n\n# Database (PostgreSQL)\nDATABASE_URL=postgres://\u003cusername\u003e:\u003cpassword\u003e@\u003chost\u003e:\u003cport\u003e/\u003cdatabase\u003e?sslmode=disable\n```\n\n## Running the Project\n\nTo run the application locally, use the following command:\n\n```bash\ngo run cmd/server/main.go\n```\n\nThe API will be accessible at `http://localhost:8080`.\n\n## API Endpoints\n\n### Blog Posts\n\n- **GET** `/blogs/`: Fetch all blog posts. Supports filtering via query parameters (e.g., `term`).\n- **GET** `/blogs/:id`: Fetch a single blog post by ID.\n- **POST** `/blogs`: Create a new blog post. Requires JSON payload.\n- **PUT** `/blogs/:id`: Update an existing blog post by ID.\n- **DELETE** `/blogs/:id`: Delete a blog post by ID.\n\n#### Example Request and Response\n\n##### Create a New Post\n\n**Request:**\n\n```bash\nPOST /blogs\nContent-Type: application/json\n```\n\n```json\n{\n  \"title\": \"My First Blog Post\",\n  \"content\": \"This is the content of my first post!\",\n  \"category\": \"Tech\",\n  \"tags\": [\"Go\", \"Programming\", \"Backend\"]\n}\n```\n\n**Response:**\n\n```json\n{\n  \"id\": 1,\n  \"title\": \"My First Blog Post\",\n  \"content\": \"This is the content of my first post!\",\n  \"category\": \"Tech\",\n  \"tags\": [\"Go\", \"Programming\", \"Backend\"],\n  \"createdAt\": \"2024-10-16T14:45:00Z\",\n  \"updatedAt\": \"2024-10-16T14:45:00Z\"\n}\n```\n\n##### Get All Posts\n\n**Request:**\n\n```bash\nGET /blogs?term=Tech\n```\n\n**Response:**\n\n```json\n[\n  {\n    \"id\": 1,\n    \"title\": \"My First Blog Post\",\n    \"content\": \"This is the content of my first post!\",\n    \"category\": \"Tech\",\n    \"tags\": [\"Go\", \"Programming\", \"Backend\"],\n    \"createdAt\": \"2024-10-16T14:45:00Z\",\n    \"updatedAt\": \"2024-10-16T14:45:00Z\"\n  }\n]\n```\n\n## Database Migrations\n\nEnsure you run the SQL migration file located in the `migrations/` directory to create the `posts` table.\n\nRun the migration file with:\n\n```bash\npsql -h \u003chost\u003e -d \u003cdatabase\u003e -U \u003cuser\u003e -f migrations/001_create_posts_table.sql\n```\n\nThe migration file `001_create_posts_table.sql` contains the SQL necessary to create the `posts` table:\n\n```sql\nCREATE TABLE posts (\n    id SERIAL PRIMARY KEY,\n    title VARCHAR(255) NOT NULL,\n    content TEXT NOT NULL,\n    category VARCHAR(100) NOT NULL,\n    tags TEXT,\n    created_at TIMESTAMP NOT NULL DEFAULT NOW(),\n    updated_at TIMESTAMP NOT NULL DEFAULT NOW()\n);\n```\n\n## Contributing\n\nIf you'd like to contribute to this project, please fork the repository and submit a pull request. Any improvements and suggestions are welcome!\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/new-feature`)\n3. Commit your changes (`git commit -m 'Add some feature'`)\n4. Push to the branch (`git push origin feature/new-feature`)\n5. Open a pull request\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletsmakecakes%2Fblogging-platform-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fletsmakecakes%2Fblogging-platform-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletsmakecakes%2Fblogging-platform-api/lists"}