Restdude
Full stack, high level framework for horizontal, model-driven application hackers
Currently v2.1.2-SNAPSHOT
Full stack, high level framework for horizontal, model-driven application hackers
Currently v2.1.2-SNAPSHOT
Contrary to other frameworks that squeeze everything within two (i.e. Controller, Repository) or even a single tier, restdude provides effortless SCRUD services by generating controller, service and repository components for you classes during application startup.
This provides an extensible 3-tier architecture without any need for boilerplate code and allows to replace and extend the generated components with your own at any time when custom or otherwise additional functionality is needed.
Besides automating SCRUD, restdude provides other conveniences with a focus on hypermedia, like dynamic generation of HATEOAS/JSON-API links and controller request mappings based on entity model relationships.
Usecases in Restdude are typically modeled while broken down to four major tiers:
Model-based RESTful services for SCRUD, uploads, metadata, JSONSchema etc. are generated automatically. Models are just POJOs and can be JPA entities, ElasticSearch documents etc. Any Spring Data module can be easily plugged-in to support other NoSQL datastores.
Models also include annotations and other metadata used to declaratively compose usecase implementation details like HTTP mappings, authorization rules, tier components, validation rules, model-to-model-mappings, applications events handlers etc.
Consider the following sample model
Based on the above model, restdude will generate any missing components like a `Controller`, `Service` and `Repository` to give you the following architecture without the need for boilerplate code. You can replace or extend those with your custom components at any time.
+-------------------------+ +---------------------+ +------------------+ Browser, App, | RESTful SCRUD | | Content negotiation | | Websockets | or other Client +-------------+-----------+ +-----------+---------+ +-------+----------+ | | | --------------------------------- | ------------------------- | ------------------- | ----------- | | | JSON+HATEOAS or JSON-API 1.x | | Network with RSQL/FIQL or URL params | STOMP | | | | | | --------------------------------- | ------------------------- | ------------------- | ----------- | | | +-------------+---------------------------+----------+ +-------+----------+ | HostController +--+ Message Broker | +--------------------------+-------------------------+ +-------+----------+ | | Restdude | | +--------------------------+------------------------------------+----------+ | HostService | +--------+--------------------+---------------------+---------------+------+ | | | | | | | | +--------+-------+ +----------+-----------+ +-------+-------+ +-----+------+ | HostRepository | | FileService (FS, S3) | | EmailService | | Misc Util | +----------------+ +----------------------+ +---------------+ +------------+
Some of the RESTful services provided out of the box for the above model:
Method | Path | Description |
---|---|---|
GET | /api/rest/hosts/{id} | Fetch the host matching the id |
GET | /api/rest/hosts/{id}/relationships/country | Fetch the country of the host matching the id |
GET | /api/rest/hosts/{id}/relationships/sites | Search the sites of the host matching the id, see search endpoints bellow for filtering and other options (paged) |
GET | /api/rest/hosts?country.code=GR&name=%25startsWith | Search based on model properties (paged) |
GET | /api/rest/hosts?filter=country.code=in=(GR,UK);name==%25startsWith | Search based on model properties using RSQL or FIQL (paged) |
POST | /api/rest/hosts | Create a new host |
PUT | /api/rest/hosts/{id} | Update the host matching the id |
PATCH | /api/rest/hosts/{id} | Partially update the host matching the id |
DELETE | /api/rest/hosts/{id} | Delete the host matching the id |
GET | /api/rest/hosts/jsonschema | Get the JSONSchema for hosts |
The endpoints support the following content types:
application/json
and application/hal+json
for HATEOAS Resource response and plain JSON request bodies, with both being based on model structureapplication/vnd.api+json
for JSON-API-compliant request/response bodiesContrary to other frameworks like spring-data-rest and jhipster, restdude provides effortless SCRUD services by generating controller, service and repository classes during application startup.
This provides an extensible 3-tier architecture without any need for boilerplate code and allows to replace and extend the generated components with your own at any time when custom or otherwise additional functionality is needed. Restdude will simply not generate components that overlap with those already available.
A modern SPA wbapp that automatically adopts to the above and can be manageably customized and extended further is also provided.
Backend is based on Spring 4.x. Support classes include controllers, converters, (de)serializers, services, repositories, base models and much more.
JPA repositories work with practically any relational database and support entity graphs. Popular NoSQL data stores can be easily setup thanks to spring-data modules.
Standard Java message property resources are used in the backend by default. Those are placed in the classpath root and include properties for build-in functionality like registration, confirmation and password-reset emails. JSON labels are used on the client-side by default and similarly include standard Web UI messages for build-in models etc. Client i18n is based on requirejs.
Very flexible, based on Spring Security. Integrates with practically anything.
Social network support includes transparent registration and sign-in via any major social network. Spring social provides an API for implementing other integrations.
Basic entity-based auditing is supported via using Spring Data/Hibernate Envers annotations or interfaces in your models. Complex auditing is supported via Javers
All exceptions occurring as a result of REST processing will generate a SystemError instance, persist it and serialize as the JSON HTTP response. Stacktrace hashes, excluding line numbers, are used to group and efficiently manage and store records. Client applications can utilize the same infrastructure to persist ClientErrors.
Errors can be managed via the REST API or through the web UI.
Indexing uses ElasticSearch by default.
Controller message mappings provide access to request-response access and topic subscriptions via the “app” and “topic” destination prefixes respectively. Any service can easily message topics and collection or individual user queues. Websocket sessions and subscriptions are handled via application events
Frontend is based on backbone.marionette and similarly provides base models, model-driven UI components views and layouts (forms, menus etc.), converters, formatters, routes and more.
The webapp provides automatically-generated API documentation based on Swagger and created by Springfox. To access the documentation run the app and point your browser to http://localhost:8080/restdude/apidoc.
Restdude Hub DVD Rental is distributed under the GNU Affero General Public License