<div align="center">

<img height="128px" width="128px" src="https://raw.githubusercontent.com/HapticX/happyx/master/examples/website/src/happyx/public/icon.webp">

### Macro-oriented asynchronous full-stack web-framework written in Nim with ♥

![Nim language](https://img.shields.io/badge/>=1.6.14-1b1e2b?style=for-the-badge&logo=nim&logoColor=f1fa8c&label=Nim&labelColor=2b2e3b)
![Python language](https://img.shields.io/badge/>=3.7.x-1b1e2b?style=for-the-badge&logo=python&logoColor=f1fa8c&label=Python&labelColor=2b2e3b)

![JavaScript language](https://img.shields.io/badge/ES6-1b1e2b?style=for-the-badge&logo=javascript&logoColor=f1fa8c&label=JavaScript&labelColor=2b2e3b)
![TypeScript language](https://img.shields.io/badge/>=5.2.2-1b1e2b?style=for-the-badge&logo=typescript&logoColor=f1fa8c&label=TypeScript&labelColor=2b2e3b)

[![wakatime](https://wakatime.com/badge/user/eaf11f95-5e2a-4b60-ae6a-38cd01ed317b/project/bbd13748-36e6-4383-ac40-9c4e72c060d1.svg?style=for-the-badge)](https://wakatime.com/badge/user/eaf11f95-5e2a-4b60-ae6a-38cd01ed317b/project/bbd13748-36e6-4383-ac40-9c4e72c060d1)
[![Testing](https://img.shields.io/github/actions/workflow/status/HapticX/HappyX/tests.yml?label=Testing&logo=github&style=for-the-badge)](https://github.com/HapticX/happyx/actions/workflows/tests.yml)


[![Documentation](https://img.shields.io/badge/Documentation-2b2e3b?style=for-the-badge&logo=data:image/svg%2bxml;base64, &label=HappyX&labelColor=3b3e4b)](https://hapticx.github.io/happyx/#/guide/)
[![Tutorials](https://img.shields.io/badge/Tutorials-2b2e3b?style=for-the-badge&logo=data:image/svg%2bxml;base64, &label=HappyX&labelColor=3b3e4b)](https://github.com/HapticX/happyx-tutorial-series)

[![VS Code Plugin](https://img.shields.io/badge/Plugin-1b1e2b?style=for-the-badge&logo=visualstudiocode&logoColor=f1fa8c&label=VS%20Code&labelColor=2b2e3b)](https://github.com/HapticX/hpx-vs-code)

[![Python Bindings](https://img.shields.io/badge/Bindings-1b1e2b?style=for-the-badge&logo=python&logoColor=f1fa8c&label=Python&labelColor=2b2e3b)](https://pypi.org/project/happyx/)
[![NodeJS Bindings](https://img.shields.io/badge/Bindings-1b1e2b?style=for-the-badge&logo=npm&logoColor=f1fa8c&label=NodeJS&labelColor=2b2e3b)](https://www.npmjs.com/package/happyx)

</div>


# Why HappyX? 💁‍♀️
> HappyX is a web framework with asynchronous, macro-oriented, full stack support.

In HappyX you can write `single page`, `static site generation` and `server side rendering` applications 💡

You can write Rest API with HappyX also 🔌

HappyX is very simple to use. Keep your peace of mind 🙂

## Why Not Jester/Karax? 🤔
Jester and Karax have many features, but Jester is a `backend web framework`, and Karax is a `frontend web framework`. HappyX  is a `full-stack web framework` that combines the features of Jester and Karax and slightly improves them 🛠

With HappyX you mustn't learn new libraries/frameworks to switch between `frontend` and `backend`. You can switch between them easily using HappyX ✌

HappyX is macro-oriented web framework so you mustn't write a lot of code ✨

## Features ⚡
- Multiple options for HTTP server! Happyx use `asynchttpserver` as default HTTP server (`httpx` via `-d:happyxHttpx`, `httpbeast` via `-d:happyxBeast` and `microhttpserver` via `-d:happyxMicro` as alternative HTTP servers).
- Support `SPA` on `JS` backend and `SSR` on other backends.
- Build HTML, CSS and pure JS with `buildHtml`, `buildStyle` and `buildJs` macros.
- Request models that supports `JSON`/`XML`/`Form-Data`/`x-www-form-urlencoded` with `model` macro.
- Routing and powerful path params.
- Assignment path params with `pathParams` macro.
- Powerful mounting sub-applications with `mount` macro. 
- Logging with `-d:debug`.
- Automatic translate with `-d:hpxTranslate` or `-d:translate` flags.
- CLI tool for `creating`, `serving` and `building` your projects.
- Hot code reloading (only for `SPA` projects as of now).
- [Python bindings](https://pypi.org/project/happyx/)
- [NodeJS bindings](https://www.npmjs.com/package/happyx)

## Minimal Example 👩‍💻

<table height="180px">
  <thead>
    <tr>
      <td align="center">SPA</td>
      <td align="center">SSR</td>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>
        <pre lang="nim"><code>import happyx

    appRoutes "app":
      "/":
        "Hello, world!"
</code></pre>
      </td><td>
      <pre lang="nim"><code>import happyx
      
    serve "127.0.0.1", 5000:
      "/":
        "Hello, world!"
</code></pre>
      </td>
    <tr>
  </tbody>
</table>

# Get Started 👨‍🔬

## Installing 📥
### Nimble
```shell
nimble install happyx@#head
```

### Nimble via Git
```shell
nimble install https://github.com/HapticX/happyx
```

### PyPI
```shell
pip install happyx
```

## Usage ▶
### SSR
```bash
hpx create --name ssr_project --kind SSR
cd ssr_project/src
```

Main script will be able in `/ssr_project/src/main.nim`

#### Run 💻


| HTTP Server          | Flag       |
| -------------------- | ---------- |
| Default              | no flags   |
| Httpx                | `-d:httpx` |
| MicroAsyncHttpServer | `-d:micro` |
| HttpBeast            | `-d:beast` |

### SPA
```bash
hpx create --name spa_project --kind SPA --path-params
cd spa_project
```

Main script will be able in `/spa_project/src/main.nim`

#### Run 💻
Just run this command and see magic ✨
```bash
hpx dev --reload
```

## Have A Question? 👀

[![StackOverflow](https://img.shields.io/badge/Overflow-1b1e2b?style=for-the-badge&logo=stackoverflow&logoColor=f1fa8c&label=Stack&labelColor=2b2e3b)](https://stackoverflow.com/search?q=%5Bnim-lang%5D+HappyX)

## Have A Nice Idea? 🍍

[Open issue](https://github.com/HapticX/happyx/issues/new/choose) or contact us hapticx.company@gmail.com


## Contributing 🌀
See [Contributing.md](https://github.com/HapticX/happyx/blob/master/.github/CONTRIBUTING.md) for more information

## Donate 💰
[![Tinkoff](https://img.shields.io/badge/Tinkoff-ffdd2d?style=for-the-badge&logo=tinkoff&logoColor=f1fa8c&label=Сбор%20Средств&labelColor=2b2e3b)](https://www.tinkoff.ru/cf/9HWYxcPF4pS)


## Star History ✨

<a href="https://star-history.com/#HapticX/happyx&Date">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=HapticX/happyx&type=Date&theme=dark" />
    <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=HapticX/happyx&type=Date" />
    <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=HapticX/happyx&type=Date" />
  </picture>
</a>

