All Projects → Mahamed-Belkheir → haykal

Mahamed-Belkheir / haykal

Licence: other
A Typescript MVC Framework

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to haykal

UMVC
UMVC - Model-View-Controller Generator built for Unity
Stars: ✭ 36 (+50%)
Mutual labels:  mvc-framework, mvc-architecture
node-boilerplate
Node Typescript Boilerplate for Microservices. Skeleton for Node.js Apps written in TypeScript (with Setup Instructions for ESLint, Prettier, and Husky)
Stars: ✭ 92 (+283.33%)
Mutual labels:  node-js, typescript-boilerplate
express-mvc-pattern
Example nodejs using express implementation design pattern using mvc architecture.
Stars: ✭ 52 (+116.67%)
Mutual labels:  mvc-architecture, typescript-boilerplate
SmartMvc
深入解析SpringMVC核心原理:从手写简易版MVC框架开始(SmartMvc)
Stars: ✭ 66 (+175%)
Mutual labels:  mvc-framework, mvc-architecture
php-mvc-framework
PHP MVC Framework - web application framework for modern and rapid development of web applications
Stars: ✭ 24 (+0%)
Mutual labels:  mvc-framework, mvc-architecture
flask-mvc
Flask Simple Model-View-Controller(MVC)
Stars: ✭ 21 (-12.5%)
Mutual labels:  mvc-framework, mvc-architecture
puremvc-swift-multicore-framework
PureMVC MultiCore Framework for Swift
Stars: ✭ 17 (-29.17%)
Mutual labels:  mvc-framework, mvc-architecture
Nodefony Starter
Nodefony Starter Node.js Framework
Stars: ✭ 95 (+295.83%)
Mutual labels:  mvc-framework, node-js
kites
Template-based Web Application Framework
Stars: ✭ 51 (+112.5%)
Mutual labels:  typescript-framework
incubator-flagon-useralejs
Apache Flagon UserALE.js is a comprehensive, thin-client behavioral logging tool
Stars: ✭ 21 (-12.5%)
Mutual labels:  node-js
dropbox-fs
📦 Node FS wrapper for Dropbox
Stars: ✭ 35 (+45.83%)
Mutual labels:  node-js
tough-cookie-file-store
A JSON file store implementation for tough-cookie module
Stars: ✭ 20 (-16.67%)
Mutual labels:  node-js
dhan-gaadi
A complete online bus reservation system (Node, React, Mongo, NextJS, ReactNative)
Stars: ✭ 207 (+762.5%)
Mutual labels:  node-js
eCommerce Shop
eCommerceShop renowned stylish, affordable, new and original fashion to you. our product mainly focuses on women wear’s, but it also offers men's apparel, children clothes, accessories, shoes, bags and other fashion items. BossKinds manufacture and supplier of leisurewear, workwear and school uniforms. we understood the importance of making good…
Stars: ✭ 26 (+8.33%)
Mutual labels:  mvc-framework
airports-db
Public airports database API service based on GitHub
Stars: ✭ 17 (-29.17%)
Mutual labels:  node-js
live-plugin-manager
Plugin manager and installer for Node.JS
Stars: ✭ 172 (+616.67%)
Mutual labels:  node-js
Retrofit2Samples
Retrofit2 Samples 与 Nodejs 服务端接口
Stars: ✭ 17 (-29.17%)
Mutual labels:  node-js
final-pm
Finally a good node.js process manager.
Stars: ✭ 21 (-12.5%)
Mutual labels:  node-js
keywordsextract
keywords-extract - Command line tool extract keywords from any web page.
Stars: ✭ 50 (+108.33%)
Mutual labels:  node-js
velox
The minimal PHP micro-framework.
Stars: ✭ 55 (+129.17%)
Mutual labels:  mvc-framework

Haykal


Deprecated

version 0.1.* has been deprecated due to both architectural and tooling reasons, here's a list of the current issues:

Architecture
  • The non-standard MVC terminology confuses newcomers
  • The MVC structure did not scale well, business logic in the controller made it hard to reuse code between other controllers
  • Repositories did not support transactions out of the box, hacking them in was not convenient
  • A lot of repeated code, between interfaces, repositories and repository interfaces
  • Having models be interfaces and only define domain method types made for a lot of code repetition
  • Having both an implementation and interface for repositories proved to have little value, as long as the implementation repository did not leak the DB layer
  • Lack of colocation made making changes to one component have you jumping between routes, controllers, model interfaces, repository interfaces, and the repository implementations, each in its own directory
  • manual DI did not scale well, files got larger, introducing new repositories meant more imports and editing of controller initialization.
Tooling

The CLI code is badly structured, and the template strings have no typesafety and the generated code had bad formatting.

Moving forward

version 0.2 is in development, I've been experimenting with multiple new structures, and after 4 drafts and a few months of use in development, I think I've picked a lay out for 0.2 that I believe addresses all the pain points mentioned earlier, inspired by DDD in decoupling the domain models, unit of work for decoupled transactions, and angular in colocation of files, and making use of tsyringe for handling DI, among other improvements.

Work will also be put into making the CLI project structure cleaner, and I'll be experimenting with using ts-morph for code generation.

And documentation, this has been severly lacking 😓


Haykal is a typescript MVC framework, originally designed for generating web application backends, it is flexible enough to work with any project. Haykal generates a loosely coupled project, and is able to generate component templates.

Haykal uses Express and Objection/Knex by default, but it's decoupled and can be replaced by other equivalent libraries and frameworks. Support for other libraries will come after.

How to use

haykal is a cli tool, install it through

npm i -g haykal current available commands are:

  • initialize a new project: haykal init <project-name> creates a new folder in the current directory, installs dependencies and generates the folders and files and creates the project boilerplate

  • generate components: haykal gen [options] <component> type of resource can chosen through these options: - -a: resource // generates all components with CRUD methods for the controller and routes - -c: controller - -r: router - -i: model interface - -m: model implementation - -mi: migration

    and optionally attributes options --attributes (e.g : --attributes id:primary name:string age:number) currently supported types: string, number, date, boolean and primary (incremental id) if you do not enter the attributes option you're able to add them after running the command. if you're generating a component without attributes (e.g a router or controller), just hit enter after the command.

Project Structure:

 /src
    - /controllers
        - <controller classes>
    - /dependency
        - index.ts
        - config.ts
    - /models
        - /interface
            - base.ts
            - <model interfaces>
        - /<implementation> (e.g objection)
            - base.ts
            - <model implementation classes>
    - /tests
        - <test files>
    - /services
        - <service classes>
    - /application
        - /<implementation> (e.g express)
            - index.ts
            - error.ts
            - /api
                - /v1
                    - index.ts
                    - <routes>
                - index.ts
    - /db
        - /<implementation> (e.g objection)
            - index.ts
    - /exceptions
        - index.ts
- Controllers:
    Unlike other MVC frameworks, controllers are not the HTTP route handlers, those are inside route files.
    Controllers are the logic side of Models in the usual MVC pattern, and they handle only business rules.
- Models:
    In practice, repositories, they define a standard way to interface with your chosen data store.
    interfaces hold the standard method definitions, while implementation folders contain the ORM/SQL/HttpRequests required to fulfill the implementation.
    - interface:
        defines a common interface to be implemented by model repositories.
    - implementation:
        the repository implementation classes, if using an ORM, defines the ORM Model here and a repository class that implements the interface methods using said ORM.
- Dependency:
    - index.ts:
        initializes dependency injection and exports instances of classes and models.
    - config.ts:
        defines a central place to read environment variable and define default values for them.
- Tests:
    includes all test files.
- Application:
    handles all application's access implementations, could be a HTTP server, a CLI tool, etc the following example is of the Express implementation.
    - express:
        - index.ts:
            bootstraps the entire application.
        - error.ts:
            generic express error handler.
        - api:
            index.ts:
                handles registering all api routes, reads every folder and imports it as router for use(e.g "/v1").
            v1:
                the default api version.
                - index.ts:
                    handles registering all routers within its directory.
- DB:
    defines DB access configuration files.
    - databaseImplementation:
        the config for the chosen implementation.
- Exceptions:
    - index.ts:
        Holds exception and error classes.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].