{"id":15132497,"url":"https://github.com/haileamlak/blog-api","last_synced_at":"2026-02-06T20:02:30.070Z","repository":{"id":256946240,"uuid":"856836017","full_name":"Haileamlak/blog-api","owner":"Haileamlak","description":"Scalable and secure RESTful API for blog management with user authentication, role-based access control, and content generation and suggestion using generative AI.","archived":false,"fork":false,"pushed_at":"2024-10-30T15:13:29.000Z","size":56,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-26T16:23:21.549Z","etag":null,"topics":["gemini-api","go","golang","jwt","mongodb","redis","smtp","testify"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Haileamlak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-09-13T09:48:10.000Z","updated_at":"2024-10-31T09:29:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"66d3c306-44bb-4de7-b825-4d5744605eb2","html_url":"https://github.com/Haileamlak/blog-api","commit_stats":null,"previous_names":["haileamlak/blog-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Haileamlak/blog-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haileamlak%2Fblog-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haileamlak%2Fblog-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haileamlak%2Fblog-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haileamlak%2Fblog-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Haileamlak","download_url":"https://codeload.github.com/Haileamlak/blog-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haileamlak%2Fblog-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29174334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T19:56:27.068Z","status":"ssl_error","status_checked_at":"2026-02-06T19:56:18.934Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["gemini-api","go","golang","jwt","mongodb","redis","smtp","testify"],"created_at":"2024-09-26T04:20:18.994Z","updated_at":"2026-02-06T20:02:30.036Z","avatar_url":"https://github.com/Haileamlak.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blog API\r\n\r\nA scalable RESTful API for a blog platform that supports user authentication and authorization, CRUD operations for blog posts, advanced search and filtering, and role-based access control. It also includes AI integration for content generation, suggestion, and enhancement. The API is built using Go and designed for high performance, scalability, and maintainability using clean architecture.\r\n\r\n## Table of Contents\r\n- [Features](#features)\r\n- [Tech Stack](#tech-stack)\r\n- [Getting Started](#getting-started)\r\n- [Project Structure](#project-structure)\r\n- [Environment Variables](#environment-variables)\r\n- [Running the Application](#running-the-application)\r\n- [Running Tests](#running-tests)\r\n- [API Endpoints](#api-endpoints)\r\n\r\n## Features\r\n- **User Authentication**: JWT-based authentication and role management (Admin and User roles).\r\n- **Blog Management**: Create, update, delete, and retrieve blog posts with advanced search and filtering capabilities.\r\n- **AI Content Suggestions**: Integrated AI for generating blog content ideas based on user input.\r\n- **User Management**: Registration, login, password reset, and profile updates.\r\n- **Role-Based Access Control**: Admin and User roles with different permissions for managing content.\r\n- **Popularity Metrics**: Track blog post views, likes, and comments.\r\n- **Secure Password Handling**: Use bcrypt for password storage and validation.\r\n- **Database Integration**: MongoDB for storing user and blog data.\r\n- **Unit Testing**: Comprehensive test suite for ensuring code quality and reliability.\r\n\r\n## Tech Stack\r\n- **Language**: Go (Golang)\r\n- **Framework**: Gin for HTTP routing and middleware\r\n- **Database**: MongoDB, Redis\r\n- **Authentication**: JWT (JSON Web Tokens), SMTP\r\n- **AI Integration**: Gemini for content generation\r\n- **Environment Management**: godotenv\r\n- **Testing**: Testify, httptest\r\n\r\n## Getting Started\r\n\r\n### Prerequisites\r\nBefore starting, ensure you have the following installed:\r\n- **Go** (1.18 or higher)\r\n- **MongoDB** (local or cloud instance)\r\n- **Git**\r\n\r\n### Installation\r\n1. Clone the repository:\r\n   ```bash\r\n   git clone https://github.com/haileamlak/blog-api.git\r\n   cd blog-starter-api\r\n   ```\r\n\r\n2. Install dependencies:\r\n   ```bash\r\n   go mod tidy\r\n   ```\r\n\r\n3. Set up the environment variables by creating a `.env` file in the root directory with the following contents:\r\n   ```bash\r\n    VERIFY_PATH = http://localhost:8080/user/verify/%s\r\n    RESET_PASSWORD_PATH = http://localhost:8080/user/reset/%s\r\n    CLOUDINARY_URL = cloudinary://\r\n    CLOUDINARY_NAME = \u003cyour cloudinary\u003e\r\n    CLOUDINARY_API_KEY = \u003cyour cloudinary api key\r\n    CLOUDINARY_API_SECRET = \u003cyour cloudinary api secret\u003e\r\n    GEMINI_API_KEY = \u003cyour gemini api key\u003e\r\n    CACHE_DB_URI=\u003cyour cache db uri\u003e\r\n    CACHE_DB_NAME=\u003cyour cache db name\u003e\r\n    CACHE_DB_PASSWORD=\u003cyour cache db password\u003e\r\n     \r\n    DATABASE_URI=\u003cyour db uri\u003e\r\n    DATABASE_NAME=blog-api \r\n     \r\n    PORT=8080 \r\n     \r\n    ACCESS_SECRET=\u003cyour access secret\u003e\r\n    REFRESH_SECRET=\u003cyour refresh secret\u003e\r\n    VERIFY_SECRET=\u003cyour verify secret\u003e\r\n    RESET_SECRET=\u003cyour reset secret\u003e\r\n     \r\n    CONTEXT_TIMEOUT=2\r\n    \r\n    SMTP_PASSWORD = \u003cyour smtp password\u003e\r\n    SMTP_EMAIL = \u003cyour smtp email\u003e\r\n   ```\r\n\r\n## Project Structure\r\n\r\n```\r\nblog-starter-api/\r\n├── Delivery/           # HTTP handlers, request/response structures, main.go file (entry point)\r\n├── Domain/             # Core business logic and entities\r\n├── Infrastructure/     # External services (database, JWT, password hashing)\r\n├── Repositories/       # Data persistence and retrieval logic\r\n├── Usecases/           # Application-specific business rules\r\n├── Tests               # Testing files for critical components\r\n├── .env                # Environment variables file\r\n├── go.mod              # Go module dependencies\r\n├── README.md           # Project documentation\r\n```\r\n\r\n## Running the Application\r\nTo start the server, run:\r\n```bash\r\ngo run main.go\r\n```\r\nThe server will start at [http://localhost:8080](http://localhost:8080).\r\n\r\n## Running Tests\r\nThis project includes a suite of unit tests to ensure code quality. To run the tests:\r\n```bash\r\ngo test ./...\r\n```\r\n### Testing Considerations\r\n- **Test Coverage**: Critical components are covered, including user management, blog CRUD operations, and authentication.\r\n- **Issues**: Ensure that MongoDB is running locally, or mock database interactions for tests.\r\n\r\n## API Endpoints\r\n\r\n### User Authentication\r\n- **POST** `/auth/register`: Register a new user\r\n- **POST** `/auth/login`: User login\r\n- **POST** `/auth/logout`: Logout and invalidate tokens\r\n- **POST** `/auth/forgot-password`: Request a password reset\r\n- **POST** `/auth/reset-password`: Reset user password\r\n\r\n### Blog Management\r\n- **GET** `/blogs`: Retrieve all blog posts with pagination and filtering\r\n- **GET** `/blogs/:id`: Retrieve a single blog post by ID\r\n- **POST** `/blogs`: Create a new blog post (requires authentication)\r\n- **PUT** `/blogs/:id`: Update a blog post (requires authentication)\r\n- **DELETE** `/blogs/:id`: Delete a blog post (requires authentication)\r\n\r\n### AI Content Suggestions\r\n- **POST** `/blogs/generate`: Get generated blog content by AI (requires authentication)\r\n- **POST** `/blogs/enhance`: Get AI-generated content enhancement for a blog post (requires authentication)\r\n- **GET** `/blogs/enhance`: Get AI-generated content suggestions for writing a blog post (requires authentication)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaileamlak%2Fblog-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaileamlak%2Fblog-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaileamlak%2Fblog-api/lists"}