Metadata-Version: 2.4
Name: modulith
Version: 0.1.8
Author-email: Panuthep Tasawong <panutheptasawong@gmail.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/modulith-labs/modulith
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi
Requires-Dist: uvicorn
Requires-Dist: requests
Requires-Dist: pydantic
Requires-Dist: keyring
Requires-Dist: typer
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: tqdm; extra == "dev"
Dynamic: license-file

# Modulith  
> Build once. Deploy effortlessly. Run everywhere

**Modulith** lets you focus on your application logic, not deployment infrastructure. Structure your code as modules with defined capabilities, then serve or deploy them on any machine without worrying about the underlying infrastructure. Whether you're running locally for development or scaling across the cloud, your interface stays consistent and your modules remain reusable.

## 🚀 What You Get

- 🧱 **Scalable by design** — move from local → distributed seamlessly
- 🔗 **Composable** — build systems by combining modules, local or remote
- 🌐 **Shareable** — publish and reuse modules across projects
- 🔐 **Built-in access control** — rate limits, burst limits, auth tokens

## 📦 Install
```bash
pip install modulith
```

## 🚀 Quick Start
Define a module and run it locally:

```python
# calculator/module.py
from modulith import Modulith

module = Modulith("calculator")

@module.capability("add")
def add(a: float, b: float) -> float:
    return a + b

result = module.add(a=1, b=2) # → 3
```

## 🐳 Deploy effortlessly
Modulith abstracts away deployment complexity. With a single command, you can deploy your module with built-in access controls, monitoring, automatic scaling. Let's you fully focus on your application logic, not the underlying infrastructure:

```bash
modulith deploy 
--source calculator.module \    
--public \                     
--rate-limit 100 \             
--burst-limit 20 
```

You'll see:

```
🔑 Your authentication token: ...

🌐 Module 'calculator' is live:
- Repository: <your_username>/calculator
- Public URL: ...

⚙️ Capabilities:
- add(a: float, b: float) → float

⚡ Public access limits:
- Rate limit: 100 requests/minute
- Burst limit: 20 requests
```

## 🌐 Run Everywhere
Now you can access your module from any machine:

```python
calculator = Modulith.remote(
    "<your_username>/calculator",
    access_token="..."
)
result = calculator.add(a=1, b=2) # → 3 (executed remotely)
```
> **Same interface. Local or remote, no difference.**

## 🔗 Composing Modules
Build new modules on top of existing modules:

```python
new_module = Modulith()
calculator = Modulith.remote("<your_username>/calculator", access_token="...")

@new_module.capability("double_sum")
def double_sum(a: float, b: float) -> float:
    sum1 = calculator.add(a, b)
    sum2 = calculator.add(a, b)
    return sum1 + sum2

result = new_module.double_sum(a=1, b=2) #  → 6
```

Execution flow:

```
double_sum(1, 2)
  → add(1, 2)   [remote]  → 3
  → add(1, 2)   [remote]  → 3
  → 3 + 3                 → 6
```

## 👤 Account (Optional)
Skip manual token management by linking modules to your account:

```bash
modulith signup # Create an account
modulith login
```

Once logged in, your module is automatically registered under your username:

```
🌐 Module 'calculator' is live:
- Repository: <your_username>/calculator
...
```

## CLI Reference

| Command | Description |
|---|---|
| `modulith signup` | Create a new account and get an authentication token |
| `modulith login` | Log in to your account and store the authentication token securely |
| `modulith deploy` | Deploy module |
| `modulith monitor` | Monitor module usage |
| `modulith stop` | Stop a running module |
| `modulith start` | Start a stopped module |
| `modulith rm` | Remove a module |
