Skip to content

gram-data/pattern-edit

Repository files navigation

Pattern Edit - Project Initialization Plan

Project: pattern-edit
Location: ../pattern-edit (peer directory to gram-rs)
Language: Rust
Framework: Leptos
Created: 2026-01-08

Overview

This document describes how to initialize the pattern-edit proof-of-concept application. It covers only the setup steps needed to create a working project structure—not implementation details or feature development.

Documentation

Comprehensive technical documentation is available in the docs/ directory:

See docs/README.md for documentation index and quick reference.

Prerequisites

  • Rust toolchain (stable) with cargo
  • wasm32-unknown-unknown target installed
  • trunk (for building and serving Leptos applications)
  • gram-rs project available in peer directory

Project Structure

Create the following directory structure:

pattern-edit/
├── Cargo.toml
├── index.html
├── src/
│   ├── main.rs
│   ├── lib.rs
│   └── app.rs
└── README.md

Initialization Steps

1. Create Project Directory

cd /Users/akollegger/Developer/gram-data
cargo new pattern-edit --bin
cd pattern-edit

2. Configure Cargo.toml

Add the following dependencies:

[package]
name = "pattern-edit"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
# Leptos and web dependencies
leptos = { version = "0.7", features = ["csr"] }
leptos_meta = { version = "0.7", features = ["csr"] }
leptos_router = { version = "0.7", features = ["csr"] }

# WASM and browser APIs
wasm-bindgen = "0.2"
web-sys = { version = "0.3", features = ["Storage"] }
console_error_panic_hook = "0.1"

# gram-rs dependency (local path)
gram-codec = { path = "../gram-rs/crates/gram-codec" }
pattern-core = { path = "../gram-rs/crates/pattern-core" }

# Serialization
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

3. Configure WASM Target

Ensure the WASM target is installed:

rustup target add wasm32-unknown-unknown

4. Install Trunk

If not already installed:

cargo install trunk

5. Create index.html

Create a minimal HTML file for Trunk to use as entry point:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Pattern Edit</title>
</head>
<body>
</body>
</html>

6. Create Initial Source Files

src/main.rs: Entry point for CSR (Client-Side Rendering)

pub fn main() {
    // Entry point for client-side rendering
}

src/lib.rs: Library exports

pub mod app;

src/app.rs: Root application component

use leptos::*;

#[component]
pub fn App() -> impl IntoView {
    view! {
        <div>
            <h1>"Pattern Edit"</h1>
        </div>
    }
}

7. Create README.md

Document basic project information:

# Pattern Edit

A proof-of-concept application for editing graph patterns using gram notation.

## Features

- Read/write gram files
- Import CSV data
- Edit, create, and delete patterns
- Pattern navigation

## Development

```bash
trunk serve

Opens development server at http://localhost:8080

Build

trunk build --release

Outputs to dist/ directory.


### 8. Verify Setup

Run the development server to verify initialization:

```bash
trunk serve

The application should compile and be accessible at http://localhost:8080.

Next Steps

After successful initialization:

  1. Verify gram-rs dependency resolution
  2. Create basic component structure for pattern operations
  3. Implement pattern storage using browser LocalStorage
  4. Design pattern navigation UI/UX

Dependencies on gram-rs

The project depends on the following gram-rs crates:

  • gram-codec: For parsing and encoding gram notation
  • pattern-core: For pattern data structures and operations

Ensure gram-rs is built before developing pattern-edit:

cd ../gram-rs
cargo build

Configuration Notes

  • Uses Leptos CSR (Client-Side Rendering) mode for simplicity
  • WASM compilation target for browser execution
  • Local path dependencies to gram-rs (requires peer directory structure)
  • No server-side components in initial setup
  • Browser LocalStorage for persistence (no backend)

Validation

The project is correctly initialized when:

  • cargo check completes without errors
  • trunk serve starts development server successfully
  • Browser displays "Pattern Edit" heading at localhost:8080
  • gram-rs crates resolve from peer directory

About

Very simple pattern editor supporting gram notation files for storage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published