{"id":15291957,"url":"https://github.com/farnam-hs/blogging-platform-api","last_synced_at":"2026-05-11T05:56:49.167Z","repository":{"id":257390530,"uuid":"858111188","full_name":"Farnam-Hs/Blogging-Platform-API","owner":"Farnam-Hs","description":"A RESTful API built with Java, using Jersey and MySQL. It supports CRUD operations for blog posts, with a focus on clean architecture and separation of concerns.","archived":false,"fork":false,"pushed_at":"2024-10-10T07:39:31.000Z","size":53,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T15:12:22.469Z","etag":null,"topics":["database","jakarta-ee","java","jax-rs","jdbc","jersey","junit","maven","mockito","restful-api"],"latest_commit_sha":null,"homepage":"","language":"Java","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/Farnam-Hs.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-16T10:27:48.000Z","updated_at":"2024-12-29T20:19:20.000Z","dependencies_parsed_at":"2024-09-16T12:52:33.285Z","dependency_job_id":null,"html_url":"https://github.com/Farnam-Hs/Blogging-Platform-API","commit_stats":null,"previous_names":["farnam-hs/blogging-platform-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Farnam-Hs%2FBlogging-Platform-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Farnam-Hs%2FBlogging-Platform-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Farnam-Hs%2FBlogging-Platform-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Farnam-Hs%2FBlogging-Platform-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Farnam-Hs","download_url":"https://codeload.github.com/Farnam-Hs/Blogging-Platform-API/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245247362,"owners_count":20584335,"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":["database","jakarta-ee","java","jax-rs","jdbc","jersey","junit","maven","mockito","restful-api"],"created_at":"2024-09-30T16:15:17.695Z","updated_at":"2026-05-11T05:56:49.115Z","avatar_url":"https://github.com/Farnam-Hs.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\n\n\u003cdiv align=\"center\"\u003e\n\n  # Blogging Platform API\n  \n\u003c/div\u003e\n  \n---\n\n## 🎯 Overview\n\nThis project is a RESTful API for managing a blogging platform, where users can create, read, update, and delete (CRUD) blog posts, as well as search for posts. The API ensures a clean separation of concerns through layered architecture and follows industry best practices for building scalable and maintainable web service.\n\n---\n\n## ✨ Features\n\n- **CRUD Operations for Blog Posts:** Create, read, update, and delete blog posts.\n- **Search Functionality:** Search posts by title, content, or category using wildcard search.\n- **Status Code Handling:** Proper use of HTTP status codes for all operations (e.g., 201 Created, 204 No Content, 404 Not Found, 500 Internal Server Error).\n- **Exception Handling:** Custom exceptions and mappers to return meaningful error messages and responses.\n- **Immutability:**  Entities, such as Post, are immutable after creation, providing stability and clear data management\n- **Testing:** Unit and integration tests ensure reliability, covering all critical aspects of the application.\n\n---\n\n## 🛠️ Technologies Used\n\n- **Java (Jakarta EE 10):** Core language used to build the API.\n- **Jersey (JAX-RS):** Used for creating RESTful web service and managing API routes.\n- **Tomcat:** Servlet container used to deploy and run the application.\n- **MySQL:** The primary relational database for persisting blog post data.\n- **H2 Database:** In-memory database used for testing.\n- **JUnit \u0026 Mockito \u0026 JerseyTest:** For unit and integration testing of the service, DAO, and controller.\n- **JDBC:**  Manages direct database interactions without using JPA.\n- **Flyway:** Manages database versioning and migrations, ensuring smooth updates and schema changes.\n- **Jackson:** Library for JSON serialization and deserialization.\n- **Maven:** Build automation and dependency management tool.\n\n---\n\n## 🏛️ Design and Architecture\n\nThis project follows a **layered architecture** approach with a clear separation of concerns between the controller, service, and data access layers:\n\n**1. Controller Layer:**\n- Handles HTTP requests and responses, and manages interaction with the service layer.\n- Example: ``PostResource.java`` for all post-related endpoints.\n\n**2. Service Layer:**\n- Implements the core business logic of the application, such as creating or updating posts, and orchestrating between the controller and DAO layers.\n- Example: ``PostServiceImpl.java`` contains the logic for managing posts.\n\n**3. DAO Layer:**\n- Directly interacts with the database using JDBC, executing SQL queries for creating, reading, updating, and deleting records.\n- Example: ``PostDaoImpl.java`` manages the persistence of post entities.\n\n### Project Structure\n\n```\nsrc/\n│\n├── main/\n│   ├── java/com/farnamhs/blogging/\n│   │   ├── config/                # Application setup and database initializer\n│   │   ├── controller/            # API controllers (e.g., PostResource.java)\n│   │   ├── dao/                   # Data Access Objects (DAO) for interacting with the database\n│   │   ├── dto/                   # Data Transfer Objects (DTOs) for request and response models\n│   │   ├── entity/                # Entity classes (e.g., Post.java)\n│   │   ├── exception/             # Custom exceptions and mappers\n│   │   ├── mapper/                # Mappers for converting entities to DTOs and vice versa\n│   │   ├── service/               # Business logic and service implementations\n│   │   └── util/                  # Utility classes\n│   └── resources/\n│       └── db/migration/          # Flyway migration scripts\n└── test/\n├── java/                      # Unit and integration tests\n└── resources/                 # Test configuration and data\n```\n\n---\n\n## ️ 🔭 API Endpoints\n\n### POST ``/api/posts``\n- **Description:** Create a new blog post.\n- **Request:** \n    - ``POST`` body must include title, content, category, and tags.\n      ```json\n      {\n        \"title\": \"My First Blog Post\",\n        \"content\": \"This is the content of my first blog post.\",\n        \"category\": \"Technology\",\n        \"tags\": [\"PROGRAMMING\", \"TECH\"]\n      }\n      ```\n- **Response:**\n  - ``201 Created`` with the newly created post.\n    ```json\n    {\n      \"id\": 1,\n      \"title\": \"My First Blog Post\",\n      \"content\": \"This is the content of my first blog post.\",\n      \"category\": \"Technology\",\n      \"tags\": [\"PROGRAMMING\", \"TECH\"],\n      \"createdAt\": \"2024-10-09T12:00:00Z\",\n      \"updatedAt\": \"2024-10-09T12:00:00Z\"\n    }\n    ```\n  - ```400 Bad Request``` with error messages in case of validation errors.\n\n### GET ``/api/posts/{id}``\n- **Description:** Retrieve a post by its ID.\n- **Response:**\n    - ``200 OK`` with the post details.\n      - Example: ``GET /api/posts/1``\n        ```json\n        {\n          \"id\": 1,\n          \"title\": \"My First Blog Post\",\n          \"content\": \"This is the content of my first blog post.\",\n          \"category\": \"Technology\",\n          \"tags\": [\"PROGRAMMING\", \"TECH\"],\n          \"createdAt\": \"2024-10-09T12:00:00Z\",\n          \"updatedAt\": \"2024-10-09T12:00:00Z\"\n        }\n        ```\n    - ```404 Not Found```  if the blog post was not found.\n\n### GET ``/api/posts?term={term}``\n- **Description:** Search posts by title, content, or category.\n- **Response:**\n  - ``200 OK`` with a list of matching posts or all posts if no term is provided.\n    - Example: ``GET /api/posts``\n      ```json\n      [\n        {\n          \"id\": 1,\n          \"title\": \"My First Blog Post\",\n          \"content\": \"This is the content of my first blog post.\",\n          \"category\": \"Technology\",\n          \"tags\": [\"PROGRAMMING\", \"TECH\"],\n          \"createdAt\": \"2024-10-09T12:00:00Z\",\n          \"updatedAt\": \"2024-10-09T12:00:00Z\"\n        },\n        {\n          \"id\": 2,\n          \"title\": \"My Second Blog Post\",\n          \"content\": \"This is the content of my second blog post.\",\n          \"category\": \"Technology\",\n          \"tags\": [\"PROGRAMMING\", \"TECH\"],\n          \"createdAt\": \"2024-10-09T12:30:00Z\",\n          \"updatedAt\": \"2024-10-09T12:30:00Z\"\n        }\n      ]\n      ```\n\n### PUT ``/api/posts/{id}``\n- **Description:** Update an existing post.\n- **Request:**\n  - ``PUT``  body must include updated title, content, category, and tags.\n    ```json\n    {\n      \"title\": \"My Updated Blog Post\",\n      \"content\": \"This is the updated content of my first blog post.\",\n      \"category\": \"Technology\",\n      \"tags\": [\"PROGRAMMING\", \"TECH\"]\n    }\n    ```\n- **Response:**\n  - ``200 OK`` with the updated blog post.\n    ```json\n    {\n      \"id\": 1,\n      \"title\": \"My Updated Blog Post\",\n      \"content\": \"This is the updated content of my first blog post.\",\n      \"category\": \"Technology\",\n      \"tags\": [\"PROGRAMMING\", \"TECH\"],\n      \"createdAt\": \"2024-10-09T12:00:00Z\",\n      \"updatedAt\": \"2024-10-09T12:30:00Z\"\n    }\n    ```\n  - ``400 Bad Request`` with error messages in case of validation errors.\n  - ``404 Not Found`` if the blog post was not found.\n\n### DELETE ``/api/posts/{id}``\n- **Description:** Delete a post by its ID.\n- **Response:**\n  - ``204 No Content`` if the blog post was successfully deleted.\n  - ``404 Not Found`` if the blog post was not found.\n\n---\n\nSample solution for the [Blogging Platform API](https://roadmap.sh/projects/blogging-platform-api) challenge from [roadmap.sh](https://roadmap.sh/).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarnam-hs%2Fblogging-platform-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffarnam-hs%2Fblogging-platform-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarnam-hs%2Fblogging-platform-api/lists"}