Dependencies
moon update
make serve| Method | Path | Description |
|---|---|---|
| GET | /api/contacts | List all contacts |
| POST | /api/contacts | Create a contact ({"name": "...", "email": "...", "phone": "..."}) |
| POST | /api/contacts/:id/favorite | Toggle favorite status |
| DELETE | /api/contacts/:id | Delete a contact |
shared/ # Isomorphic code (both js and native)
types.mbt # Contact struct with ToJson/FromJson
routes.mbt # API path constants and builders
validation.mbt # Name, email, phone validation rules
logic.mbt # Search, sort, phone formatting, initials
backend/main.mbt # Mocket HTTP server + SQLite3 CRUD
frontend/main.mbt # Rabbita MVU app (model, update, view)
public/ # Build output for frontend JS
moon.mod.json # Module config and dependencies
Makefile # Build and run commandsgraph LR
Browser["Browser"]
Frontend["Frontend (JS)<br/>main.mbt<br/>app/{types,update,view,styles}.mbt"]
API["REST API"]
Backend["Backend (Native)<br/>main.mbt, db.mbt"]
DB["SQLite<br/>contacts.db"]
Shared["Shared Code<br/>types.mbt, routes.mbt<br/>validation.mbt, logic.mbt"]
Browser <-->|HTML / Events| Frontend
Frontend <-->|JSON| API
API <-->|Handlers| Backend
Backend <-->|SQL| DB
Shared -.->|compiled to JS| Frontend
Shared -.->|compiled to native| Backendgraph TD
User["User Interaction"]
Msg["Msg"]
Update["Model.update()"]
ModelCmd["(Model, Cmd)"]
View["Model.view()"]
Html["Html"]
HTTP["HTTP Cmd<br/>GET/POST/DELETE"]
API["REST API<br/>/api/contacts"]
Result["Result Msg<br/>ContactsLoaded / Error"]
User -->|click, input, submit| Msg
Msg --> Update
Update --> ModelCmd
ModelCmd -->|new Model| View
View --> Html
Html -->|rendered in browser| User
ModelCmd -->|Cmd| HTTP
HTTP -->|request| API
API -->|response| Result
Result --> MsgerDiagram
CONTACT {
Int id PK
String name
String email
String phone
Bool favorite
}Install
Download zipDependencies