/layr

Dramatically simplify full‑stack development

Primary LanguageTypeScriptMIT LicenseMIT

Layr

Dramatically simplify full‑stack development.

Overview

Layr is a set of JavaScript/TypeScript libraries to dramatically simplify the development of full-stack applications.

Typically, a full-stack application is composed of a frontend and a backend running in two different environments that are connected through a web API (REST, GraphQL, etc.)

Separating the frontend and the backend is a good thing, but the problem is that building a web API usually leads to a lot of code scattering, duplication of knowledge, boilerplate, and accidental complexity.

Layr removes the need of building a web API and reunites the frontend and the backend in a way that you can experience them as a single entity.

On the frontend side, Layr gives you routing capabilities and object observability so that in most cases you don't need to add an external router or a state manager.

Last but not least, Layr offers an ORM to make data storage as easy as possible.

Core Features

Layr provides everything you need to build a full-stack application from start to finish:

  • Cross-layer inheritance: a frontend class can "inherit" from a backend class so that some attributes can be automatically transported between the frontend and the backend, and some backend's methods can be easily called from the frontend.
  • Controlled attributes: an attribute can be type-checked at runtime, validated, serialized, and observed.
  • Remote method invocation: a backend's method can be exposed so that the frontend can call it without the need to build a web API.
  • Storage: a class instance can be persisted in a database. Currently, only MongoDB is supported, but more databases will be added soon.
  • Routing: a method can be associated with an URL and controlled by a router so that this method is automatically called when the user navigates.
  • Authorization: role-based authorizations can be set to restrict an attribute or a method for some users.
  • Interoperability: the backend is exposed through a Deepr API so that you can consume it from any frontend even though it's not built with Layr. And if you want to bring a more traditional API (e.g., REST) to your backend, it's very easy to build such an API on top of your Layr backend.
  • Integrations: integration helpers are provided to facilitate the integration of the most popular libraries or services. Currently, only two integration helpers are available: react-integration and aws-integration. But more should come shortly.

Core Principles

Here's a quick taste of the core principles upon which Layr is built:

  • Object-oriented: Layr embraces the object-oriented approach in all aspects of an application and allows you to organize your code in a way that is as cohesive as possible.
  • Low-level: Layr is designed to be as closest as possible to the language and in many ways, it can be seen as a language extension.
  • Unopinionated: Layr has strong opinions about itself but doesn't force you to use any external libraries, services, or tools.

Documentation

Check out the documentation for some "getting started" guides and a comprehensive description of the API.

Compatibility

Layr is implemented in TypeScript but you can use either JavaScript or TypeScript to build your application.

If you are using JavaScript, you'll need to compile your code with Babel to take advantage of some novel JavaScript features such as "decorators".

If you are using TypeScript, all you need is the TypeScript compiler.

To run your application, you'll need a JavaScript runtime for both the frontend and the backend.

Frontend

Any modern browser should work fine, and here are the minimum versions with which Layr is tested:

  • Chrome v51
  • Safari v10
  • Firefox v54
  • Edge Chromium

Backend

Any environment running Node.js v10 or later is supported.

Examples

All the examples provided in the documentation are available in the Layr repository.

Also, here are some more advanced examples that you can check out:

Roadmap

Components

  • Basic components
  • Controlled attributes
  • Component provision
  • Cross-layer inheritance
  • Remote method invocation
  • Optimized serialization
  • Weak Identity Map
  • Component subscriptions (realtime updates)

Storage

  • Basic storage (MongoDB)
  • Transactions
  • Ability to query attribute of referenced components (LEFT JOIN)
  • Sugar to query reverse relationships
  • Support for more databases (PostgreSQL, MySQL, DynamoDB,...)
  • Query subscriptions (realtime updates)

Routing

  • Basic routing
  • Nested routing

Authorizations

  • Basic authorizations
  • Role-based authorizations

CLI

  • Scaffolding
  • Deployment

Integrations

  • React integration
  • Basic AWS integration

Contributing

Contributions are welcome.

Before contributing please read the code of conduct and search the issue tracker to find out if your issue has already been discussed before.

To contribute, fork this repository, commit your changes, and send a pull request.

License

MIT