{"id":21707312,"url":"https://github.com/rsrini7/multi-api-proxy","last_synced_at":"2025-07-26T09:05:19.791Z","repository":{"id":53285475,"uuid":"201232167","full_name":"rsrini7/multi-api-proxy","owner":"rsrini7","description":"Multi Api Proxy - JSON-API and GraphQL – using Spring Boot and Elide","archived":false,"fork":false,"pushed_at":"2025-06-15T13:07:55.000Z","size":355,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-15T14:29:53.802Z","etag":null,"topics":["api","api-docs","elide","graphiql-editor","graphql","json-api","spring-boot-2","swagger"],"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/rsrini7.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}},"created_at":"2019-08-08T10:09:04.000Z","updated_at":"2025-06-15T13:07:42.000Z","dependencies_parsed_at":"2022-08-28T15:00:33.767Z","dependency_job_id":null,"html_url":"https://github.com/rsrini7/multi-api-proxy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rsrini7/multi-api-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsrini7%2Fmulti-api-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsrini7%2Fmulti-api-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsrini7%2Fmulti-api-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsrini7%2Fmulti-api-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rsrini7","download_url":"https://codeload.github.com/rsrini7/multi-api-proxy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsrini7%2Fmulti-api-proxy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267144430,"owners_count":24042633,"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","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["api","api-docs","elide","graphiql-editor","graphql","json-api","spring-boot-2","swagger"],"created_at":"2024-11-25T22:16:58.510Z","updated_at":"2025-07-26T09:05:19.782Z","avatar_url":"https://github.com/rsrini7.png","language":"Java","readme":"\u003ch1 align=\"center\"\u003eWelcome to multi-api-proxy 👋\u003c/h1\u003e\n\u003cp\u003e\n  This project serves as a template and proof-of-concept (POC) for exposing data models (JPA entities) via multiple API styles – specifically JSON-API and GraphQL – using Spring Boot and Elide. It demonstrates how to provide a unified API interface for underlying data sources.\n\u003c/p\u003e\n\u003cp\u003e\n  In its current configuration, the project exposes a single example entity called \"Test\", which has `id` and `name` attributes. This data is stored in an in-memory H2 database, which is re-initialized every time the application starts.\n\u003c/p\u003e\n\u003cp\u003e\n  The name \"multi-api-proxy\" refers to its capability to act as a proxy to your data layer, presenting it through multiple API formats (JSON-API, GraphQL), rather than proxying external third-party APIs.\n\u003c/p\u003e\n\n## Core Technologies Used\n\nThis project leverages several key technologies:\n\n*   **Spring Boot:** Provides the core application framework, simplifying setup and development of web applications.\n*   **Elide:** Enables the rapid creation of JSON-API and GraphQL compliant web services from JPA entities.\n*   **Spring Data JPA:** Simplifies data access layers by providing an abstraction over JPA (Java Persistence API).\n*   **H2 Database Engine:** An in-memory SQL database used for storing the application's data during development and testing.\n*   **Swagger/OpenAPI:** Used for designing, building, and documenting RESTful APIs. Provides the `/swdocs` UI.\n*   **Lombok:** A Java library used to reduce boilerplate code (e.g., getters, setters, constructors) via annotations.\n*   **Java 8:** The programming language and runtime environment.\n*   **Maven:** Used for project build management and dependencies.\n\n## Features\n\nThis project exposes its data (\"Test\" entity) through multiple API styles and includes several helpful features:\n\n*   **JSON-API Compliant API:**\n    *   **Endpoint:** `/api/test` (for the \"Test\" entity).\n    *   **Supported Operations:**\n        *   `GET /api/test`: Fetches a collection of \"Test\" entities.\n        *   `GET /api/test/{id}`: Fetches a single \"Test\" entity by its ID.\n        *   `POST /api/test`: Creates a new \"Test\" entity.\n    *   **Note:** `PATCH` (update) and `DELETE` operations are currently disabled by default in the configuration (`application.yml`).\n    *   The older `/json-api/\u003centity\u003e` path may still work depending on Elide's version and configuration but `/api/\u003centity\u003e` is the configured prefix.\n\n*   **GraphQL API:**\n    *   **Endpoint:** `/api/graphql`\n    *   **Capabilities:** Allows querying the \"Test\" entity. Based on Elide's behavior and the enabled POST operation for JSON-API, mutations (e.g., for creating \"Test\" entities) should also be available.\n    *   **GraphQL UI:** A user interface for interacting with the GraphQL API is available at `/graphql-ui.html`.\n\n*   **Swagger API Documentation:**\n    *   **Endpoint:** `/swdocs`\n    *   Provides interactive documentation for the JSON-API.\n\n*   **Basic Web UI:**\n    *   **Endpoint:** `/index.html`\n    *   A simple landing page for the application.\n\n## Configuration\n\nThe primary application configuration is managed in the `src/main/resources/config/application.yml` file.\n\nKey configurable aspects include:\n\n*   **API Settings (Elide):**\n    *   `elide.prefix`: The base path for all Elide APIs (default: `/api`).\n    *   `elide.default-page-size` / `elide.max-page-size`: Controls pagination in API responses.\n    *   `elide.mvc.get`, `elide.mvc.post`, `elide.mvc.patch`, `elide.mvc.delete`: Booleans to enable or disable these HTTP methods for entity manipulation via JSON-API. (Currently, PATCH and DELETE are `false`).\n    *   `elide.mvc.graphql`: Enables the GraphQL endpoint (default: `true`).\n\n*   **Database (Spring Datasource):**\n    *   `spring.datasource.url`: JDBC URL for the database connection (default: H2 in-memory `jdbc:h2:mem:localhost;DB_CLOSE_ON_EXIT=FALSE`).\n    *   `spring.datasource.driver-class-name`, `username`, `password`: Standard datasource properties.\n\n*   **Logging:**\n    *   `logging.level.com.github.rsrini7`: Sets the log level for the application's packages (default: `debug`).\n    *   `logging.pattern.console`: Defines the log output format.\n\n*   **Application Specific Properties:**\n    *   Properties prefixed with `app` can be defined in `application.yml` and accessed via the `com.github.rsrini7.api.config.AppProperties` class. Currently, this is mainly used to determine the `app.version`.\n\nTo modify the application's behavior, such as connecting to a different database or changing API settings, you would typically edit this `application.yml` file.\n\n## Building and Running the Project\n\nThis project uses Apache Maven for building and managing dependencies.\n\n**Prerequisites:**\n*   Java JDK 8 or higher\n*   Apache Maven\n\n**Building the Project:**\n\n1.  **Clone the repository:**\n    ```bash\n    git clone \u003crepository-url\u003e\n    cd multi-api-proxy\n    ```\n2.  **Build the project using Maven:**\n    This command will compile the code, run tests, and package the application into a `.war` file in the `target/` directory.\n    ```bash\n    mvn clean package\n    ```\n\n**Running the Project:**\n\nThere are a couple of ways to run the application:\n\n1.  **Using the Spring Boot Maven Plugin (Recommended for development):**\n    This command starts the application directly using Maven.\n    ```bash\n    mvn spring-boot:run\n    ```\n\n2.  **Running the packaged .war file:**\n    After building the project, you can run the generated WAR file.\n    ```bash\n    java -jar target/multi-api-proxy-0.0.1-alpha.war\n    ```\n\nOnce the application starts, it will typically be accessible at `http://localhost:8080` by default, unless a different port is configured in `application.yml` (e.g., via `server.port`).\n\n## API Usage Examples\n\nOnce the application is running, you can interact with the APIs using tools like `curl` or Postman. The base URL for the APIs is `http://localhost:8080/api` by default.\n\n### JSON-API Examples (`/api/test`)\n\n**1. Fetch all \"Test\" entities:**\n```bash\ncurl -H \"Accept: application/vnd.api+json\" http://localhost:8080/api/test\n```\n*Expected Response (example if one entity exists):*\n```json\n{\n  \"data\": [\n    {\n      \"type\": \"test\",\n      \"id\": \"1\",\n      \"attributes\": {\n        \"name\": \"First Test Item\"\n      },\n      \"relationships\": {},\n      \"links\": {\n        \"self\": \"http://localhost:8080/api/test/1\"\n      }\n    }\n  ],\n  \"included\": [],\n  \"meta\": {\n    \"page\": {\n      \"number\": 1,\n      \"size\": 20,\n      \"totalElements\": 1,\n      \"totalPages\": 1\n    }\n  },\n  \"links\": {\n    \"self\": \"http://localhost:8080/api/test?page[size]=20\u0026page[number]=1\"\n  }\n}\n```\n\n**2. Fetch a single \"Test\" entity by ID (e.g., ID 1):**\n```bash\ncurl -H \"Accept: application/vnd.api+json\" http://localhost:8080/api/test/1\n```\n*Expected Response:*\n```json\n{\n  \"data\": {\n    \"type\": \"test\",\n    \"id\": \"1\",\n    \"attributes\": {\n      \"name\": \"First Test Item\"\n    },\n    \"relationships\": {},\n    \"links\": {\n      \"self\": \"http://localhost:8080/api/test/1\"\n    }\n  },\n  \"included\": []\n}\n```\n\n**3. Create a new \"Test\" entity:**\n```bash\ncurl -X POST -H \"Content-Type: application/vnd.api+json\" -H \"Accept: application/vnd.api+json\" -d '{\n  \"data\": {\n    \"type\": \"test\",\n    \"attributes\": {\n      \"name\": \"My New Test Item\"\n    }\n  }\n}' http://localhost:8080/api/test\n```\n*Expected Response (example):*\n```json\n{\n  \"data\": {\n    \"type\": \"test\",\n    \"id\": \"2\",  // ID will be auto-generated\n    \"attributes\": {\n      \"name\": \"My New Test Item\"\n    },\n    \"relationships\": {},\n    \"links\": {\n      \"self\": \"http://localhost:8080/api/test/2\"\n    }\n  },\n  \"included\": []\n}\n```\n\n### GraphQL Example (`/api/graphql`)\n\nYou can use the GraphQL UI at `/graphql-ui.html` or send POST requests to `/api/graphql`.\n\n**1. Query to fetch all \"Test\" entities (ID and name):**\n```graphql\nquery {\n  test {\n    edges {\n      node {\n        id\n        name\n      }\n    }\n  }\n}\n```\n*Send as a JSON payload in a POST request:*\n```bash\ncurl -X POST -H \"Content-Type: application/json\" -d '{ \"query\": \"query { test { edges { node { id name } } } }\" }' http://localhost:8080/api/graphql\n```\n*Expected Response (example):*\n```json\n{\n  \"data\": {\n    \"test\": {\n      \"edges\": [\n        {\n          \"node\": {\n            \"id\": \"1\",\n            \"name\": \"First Test Item\"\n          }\n        },\n        {\n          \"node\": {\n            \"id\": \"2\",\n            \"name\": \"My New Test Item\"\n          }\n        }\n      ]\n    }\n  }\n}\n```\n(Note: The exact structure of the GraphQL response might vary slightly based on Elide's GraphQL dialect and pagination settings.)\n\n## Show your support\n\nGive a ⭐️ if this project helped you!\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsrini7%2Fmulti-api-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frsrini7%2Fmulti-api-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsrini7%2Fmulti-api-proxy/lists"}