meta_oxide 0.1.1

Universal metadata extraction library supporting 13 formats (HTML Meta, Open Graph, Twitter Cards, JSON-LD, Microdata, Microformats, RDFa, Dublin Core, Web App Manifest, oEmbed, rel-links, Images, SEO) with 7 language bindings
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
# MetaOxide Multi-Language Expansion Strategy

## Executive Summary

MetaOxide is positioned to become the universal standard library for metadata extraction across all major programming languages. With a mature Rust core (16,500+ LOC, 700+ tests, 13 metadata formats), the library is ready for strategic expansion beyond Python.

**Recommended Approach: Hybrid Architecture (Approach E)**

After thorough analysis, we recommend a hybrid approach combining:
1. **C-ABI Layer**: Create a stable C API wrapper around the Rust core
2. **Native Bindings**: High-performance bindings for Go, Node.js, Java, C#
3. **gRPC/REST Fallback**: For secondary languages (PHP, Ruby, etc.)
4. **WASM Distribution**: Browser/edge deployment option

**Key Strategic Decisions:**
- Invest in a stable C-ABI layer as the foundation for all bindings
- Prioritize Go and Node.js (largest adoption potential, lowest maintenance)
- Use gRPC service for enterprise/secondary languages
- Target 12-18 month timeline for Phase 1-3
- Estimated total effort: 180-240 developer days

**Expected Outcomes:**
- 20M+ potential developer reach across all supported languages
- Industry-leading performance (10-100x faster than pure-language alternatives)
- Unified API surface with consistent behavior
- Sustainable maintenance burden (one core, thin language bindings)

---

## Table of Contents

1. [Current State Analysis]#1-current-state-analysis
2. [Approach Comparison Matrix]#2-approach-comparison-matrix
3. [Recommended Strategy]#3-recommended-strategy
4. [Language Priority Matrix]#4-language-priority-matrix
5. [Architecture Design]#5-architecture-design
6. [Implementation Roadmap]#6-implementation-roadmap
7. [Technical Specifications]#7-technical-specifications
8. [Effort Estimates]#8-effort-estimates
9. [Risk Assessment]#9-risk-assessment
10. [Success Metrics]#10-success-metrics
11. [Competitive Analysis]#11-competitive-analysis
12. [Detailed Todo List]#12-detailed-todo-list

---

## 1. Current State Analysis

### 1.1 MetaOxide Core Statistics

| Metric | Value |
|--------|-------|
| Total Rust LOC | ~16,500 |
| Test Count | 700+ |
| Metadata Formats | 13 |
| Performance | ~60us/10KB, ~6ms/1MB |
| Dependencies | scraper, url, serde, thiserror |
| Current Bindings | Python (PyO3) |

### 1.2 Architecture Strengths

1. **Clean Separation**: Types, extractors, and bindings are well-separated
2. **Trait-Based Design**: `Extractor` trait provides extension points
3. **Macro Infrastructure**: `py_extractor_binding!` pattern is extensible
4. **Comprehensive Types**: Full type definitions for all 13 formats
5. **Error Handling**: Domain-specific `MicroformatError` with thiserror

### 1.3 Architecture Considerations for Multi-Language

**Current Challenges:**
- Python bindings tightly coupled to PyO3 in `lib.rs`
- No C-ABI layer for FFI consumption
- String handling assumes Rust ownership model
- Memory lifecycle managed by Rust

**Required Changes:**
- Abstract extraction logic from binding layer
- Create C-compatible data structures
- Implement explicit memory management for C-ABI
- Design language-agnostic error codes

---

## 2. Approach Comparison Matrix

| Criteria | A: Individual Bindings | B: gRPC Service | C: WASM | D: REST API | E: Hybrid |
|----------|------------------------|-----------------|---------|-------------|-----------|
| **Performance** | Excellent (native) | Good (network) | Good (sandboxed) | Fair (HTTP) | Excellent |
| **Maintenance** | High (N bindings) | Low (1 service) | Medium (1 target) | Low (1 service) | Medium |
| **Deployment** | Library | Service | Library | Service | Mixed |
| **Developer UX** | Excellent | Good | Good | Good | Excellent |
| **Offline Use** | Yes | No | Yes | No | Yes |
| **Cross-Platform** | Complex | Easy | Universal | Easy | Balanced |
| **Initial Effort** | Very High | Medium | Medium | Low | High |
| **Scalability** | Per-process | Shared | Per-process | Shared | Flexible |
| **Enterprise Fit** | Mixed | Excellent | Limited | Good | Excellent |

### 2.1 Approach A: Individual Language Bindings

**Go (cgo)**
- Pros: Direct memory sharing, zero-copy potential
- Cons: CGO overhead on each call, complex build

**Node.js (N-API)**
- Pros: Native addon ecosystem mature, good tooling (neon-rs)
- Cons: Async model mismatch, build complexity

**Java (JNI)**
- Pros: Direct integration, enterprise standard
- Cons: Complex, JNI boilerplate, crash risk

**C# (P/Invoke)**
- Pros: Works well with C-ABI, .NET standard
- Cons: Platform-specific native libs

### 2.2 Approach B: gRPC Service

```
+-------------+     gRPC      +------------------+
| Go Client   |-------------->|                  |
+-------------+               |   MetaOxide      |
+-------------+     gRPC      |   gRPC Server    |
| Java Client |-------------->|   (Rust/Tonic)   |
+-------------+               |                  |
+-------------+     gRPC      +------------------+
| C# Client   |-------------->|
+-------------+
```

**Pros:**
- Single server implementation
- Language-agnostic proto definitions
- Built-in streaming for large documents
- Easy horizontal scaling

**Cons:**
- Network latency per request
- Deployment complexity
- Not suitable for offline/embedded use

### 2.3 Approach C: WebAssembly

**Pros:**
- Universal runtime (browsers, Node, Deno, WASI)
- Single compilation target
- Sandboxed execution

**Cons:**
- 2-5x performance overhead vs native
- Limited system access
- Large binary size (~2-5MB)
- Complex async handling

### 2.4 Approach E: Hybrid (Recommended)

```
                    +-------------------+
                    |   Rust Core       |
                    |   (meta_oxide)    |
                    +-------------------+
                            |
                    +-------------------+
                    |   C-ABI Layer     |
                    |   (libmeta_oxide) |
                    +-------------------+
                            |
        +-------------------+-------------------+
        |           |           |               |
   +---------+ +---------+ +---------+    +-----------+
   |  Go     | | Node.js | |  Java   |    |  gRPC     |
   | (cgo)   | | (N-API) | |  (JNI)  |    |  Service  |
   +---------+ +---------+ +---------+    +-----------+
                                               |
                                    +----------+----------+
                                    |          |          |
                               +-------+ +-------+ +-------+
                               | PHP   | | Ruby  | | Other |
                               +-------+ +-------+ +-------+
```

---

## 3. Recommended Strategy

### 3.1 Core Architectural Changes

#### Phase 0: C-ABI Foundation (Critical Path)

Create a C-compatible wrapper library (`libmeta_oxide`) that:

1. **Defines C-compatible structures:**
```c
// meta_oxide.h
typedef struct {
    char* title;
    char* description;
    char* canonical;
    // ... other fields
} meta_oxide_meta_t;

typedef struct {
    char* type;
    char* url;
    char* title;
    char* description;
    char* image;
} meta_oxide_opengraph_t;

typedef struct {
    int code;
    char* message;
} meta_oxide_error_t;
```

2. **Exports stable C functions:**
```c
// Core extraction functions
meta_oxide_error_t* meta_oxide_extract_all(
    const char* html,
    const char* base_url,
    meta_oxide_result_t** result
);

// Memory management
void meta_oxide_free_result(meta_oxide_result_t* result);
void meta_oxide_free_error(meta_oxide_error_t* error);

// Version info
const char* meta_oxide_version(void);
```

3. **Memory safety guarantees:**
- All returned pointers owned by library
- Explicit free functions for each type
- Thread-safe extraction (stateless)
- No callbacks across FFI boundary

### 3.2 Binding Strategy Per Language

| Language | Binding Method | Priority | Rationale |
|----------|---------------|----------|-----------|
| Go | cgo via C-ABI | P1 | Large backend ecosystem, straightforward cgo |
| Node.js | N-API via neon-rs | P1 | Largest ecosystem, good tooling |
| Java | JNI via C-ABI | P2 | Enterprise demand, Android |
| C# | P/Invoke via C-ABI | P2 | .NET/Azure ecosystem |
| Python | PyO3 (existing) | Done | Already implemented |
| PHP | FFI via C-ABI | P3 | Via gRPC or FFI extension |
| Ruby | FFI via C-ABI | P3 | Via gRPC or fiddle |
| Others | gRPC/REST | P3 | Universal fallback |

---

## 4. Language Priority Matrix

### 4.1 Scoring Criteria

| Criterion | Weight | Description |
|-----------|--------|-------------|
| Market Size | 30% | Number of potential users |
| Strategic Value | 25% | Enterprise/ecosystem importance |
| Implementation Effort | 20% | Developer days required |
| Maintenance Burden | 15% | Ongoing support cost |
| Performance Need | 10% | Criticality of native speed |

### 4.2 Priority Scores

| Language | Market (30%) | Strategic (25%) | Effort (20%) | Maintenance (15%) | Performance (10%) | **Total** |
|----------|--------------|-----------------|--------------|-------------------|-------------------|-----------|
| **Node.js** | 9 (2.7) | 8 (2.0) | 7 (1.4) | 7 (1.05) | 8 (0.8) | **7.95** |
| **Go** | 8 (2.4) | 9 (2.25) | 8 (1.6) | 8 (1.2) | 9 (0.9) | **8.35** |
| **Java** | 9 (2.7) | 8 (2.0) | 5 (1.0) | 5 (0.75) | 7 (0.7) | **7.15** |
| **C#** | 7 (2.1) | 7 (1.75) | 6 (1.2) | 6 (0.9) | 7 (0.7) | **6.65** |
| **PHP** | 6 (1.8) | 4 (1.0) | 6 (1.2) | 6 (0.9) | 5 (0.5) | **5.40** |
| **Ruby** | 4 (1.2) | 4 (1.0) | 7 (1.4) | 7 (1.05) | 5 (0.5) | **5.15** |

### 4.3 Final Priority Order

1. **Go** (Score: 8.35) - Backend/DevOps, cloud-native, microservices
2. **Node.js** (Score: 7.95) - Web ecosystem, serverless, tooling
3. **Java** (Score: 7.15) - Enterprise, Android, big data
4. **C#** (Score: 6.65) - .NET, Azure, Windows enterprise
5. **PHP** (Score: 5.40) - WordPress, legacy web (via gRPC)
6. **Ruby** (Score: 5.15) - Rails ecosystem (via gRPC)

---

## 5. Architecture Design

### 5.1 Layered Architecture

```
+------------------------------------------------------------------+
|                         Language Bindings                         |
|  +----------+  +----------+  +--------+  +--------+  +----------+ |
|  |   Go     |  | Node.js  |  |  Java  |  |  C#    |  |  Python  | |
|  | (cgo)    |  | (N-API)  |  | (JNI)  |  |(PInvoke)|  | (PyO3)  | |
|  +----------+  +----------+  +--------+  +--------+  +----------+ |
+------------------------------------------------------------------+
                              |
+------------------------------------------------------------------+
|                         C-ABI Layer                               |
|  +------------------------------------------------------------+  |
|  |  libmeta_oxide.so / meta_oxide.dll / libmeta_oxide.dylib   |  |
|  |  - Stable C function signatures                             |  |
|  |  - C-compatible data structures                             |  |
|  |  - Explicit memory management                               |  |
|  |  - Thread-safe, stateless extraction                        |  |
|  +------------------------------------------------------------+  |
+------------------------------------------------------------------+
                              |
+------------------------------------------------------------------+
|                         Rust Core                                 |
|  +------------------------------------------------------------+  |
|  |  meta_oxide crate                                           |  |
|  |  - extractors/ (13 format extractors)                       |  |
|  |  - types/ (strongly-typed output structures)                |  |
|  |  - errors/ (domain-specific error handling)                 |  |
|  |  - parser.rs (HTML parsing utilities)                       |  |
|  +------------------------------------------------------------+  |
+------------------------------------------------------------------+
```

### 5.2 C-ABI Design Principles

1. **Opaque Pointers**: Hide internal structure, expose handles
2. **Error-First Returns**: All functions return error, out-param for result
3. **Explicit Ownership**: Clear documentation on who owns memory
4. **ABI Stability**: Semantic versioning for C API
5. **Platform Agnostic**: Works on Windows, macOS, Linux

### 5.3 Data Structure Design

```rust
// Rust side (src/ffi/types.rs)
#[repr(C)]
pub struct MetaOxideString {
    ptr: *mut c_char,
    len: usize,
    capacity: usize,
}

#[repr(C)]
pub struct MetaOxideStringArray {
    ptr: *mut MetaOxideString,
    len: usize,
    capacity: usize,
}

#[repr(C)]
pub struct MetaOxideMeta {
    title: MetaOxideString,
    description: MetaOxideString,
    canonical: MetaOxideString,
    keywords: MetaOxideStringArray,
    // ... other fields
}

#[repr(C)]
pub struct MetaOxideResult {
    meta: *mut MetaOxideMeta,
    opengraph: *mut MetaOxideOpenGraph,
    twitter: *mut MetaOxideTwitterCard,
    jsonld: *mut MetaOxideJsonLdArray,
    // ... other formats
}
```

### 5.4 gRPC Service Design

```protobuf
// proto/meta_oxide.proto
syntax = "proto3";
package meta_oxide.v1;

service MetaOxideService {
  rpc ExtractAll(ExtractRequest) returns (ExtractResponse);
  rpc ExtractMeta(ExtractRequest) returns (MetaResponse);
  rpc ExtractOpenGraph(ExtractRequest) returns (OpenGraphResponse);
  rpc ExtractJsonLd(ExtractRequest) returns (JsonLdResponse);
  // Streaming for large documents
  rpc ExtractAllStream(stream ExtractChunk) returns (ExtractResponse);
}

message ExtractRequest {
  string html = 1;
  string base_url = 2;
}

message ExtractResponse {
  Meta meta = 1;
  OpenGraph opengraph = 2;
  TwitterCard twitter = 3;
  repeated JsonLdObject jsonld = 4;
  repeated MicrodataItem microdata = 5;
  // ... other formats
}
```

---

## 6. Implementation Roadmap

### 6.1 Timeline Overview

```
2024-Q1  |  2024-Q2  |  2024-Q3  |  2024-Q4  |  2025-Q1  |  2025-Q2
   |         |         |         |         |         |
   |---------|---------|---------|---------|---------|
   Phase 0   Phase 1   Phase 2   Phase 3   Phase 4   Phase 5
   C-ABI     Go+Node   Java+C#   gRPC      WASM      Polish
```

### 6.2 Phase Details

#### Phase 0: C-ABI Foundation (Weeks 1-6)

**Deliverables:**
- [ ] C header file (meta_oxide.h)
- [ ] Rust FFI module (src/ffi/)
- [ ] Memory management functions
- [ ] Platform-specific build (Windows/macOS/Linux)
- [ ] C-ABI test suite
- [ ] cbindgen integration

**Acceptance Criteria:**
- All 13 extractors accessible via C-ABI
- Zero memory leaks (verified by valgrind)
- Thread-safe (verified by concurrent tests)
- ABI stable (semantic versioning)

#### Phase 1: Go & Node.js Bindings (Weeks 7-14)

**Go Package Deliverables:**
- [ ] Go module (github.com/yfedoseev/meta-oxide-go)
- [ ] Idiomatic Go API (error handling, context)
- [ ] Comprehensive test suite
- [ ] Documentation and examples
- [ ] CI/CD for releases

**Node.js Package Deliverables:**
- [ ] npm package (@yfedoseev/meta-oxide)
- [ ] N-API bindings via neon-rs
- [ ] TypeScript type definitions
- [ ] Promise-based async API
- [ ] Documentation and examples

**Acceptance Criteria:**
- API parity with Python bindings
- Performance within 10% of raw Rust
- 100% test coverage of public API
- Published to respective registries

#### Phase 2: Java & C# Bindings (Weeks 15-22)

**Java Package Deliverables:**
- [ ] Maven artifact (io.github.yfedoseev:meta-oxide)
- [ ] JNI bindings
- [ ] Javadoc documentation
- [ ] Android support (AAR)
- [ ] Examples and tutorials

**C# Package Deliverables:**
- [ ] NuGet package (MetaOxide)
- [ ] P/Invoke bindings
- [ ] .NET Standard 2.0 compatibility
- [ ] XML documentation
- [ ] Examples and tutorials

**Acceptance Criteria:**
- Works on JDK 11+ / .NET 6+
- No native crashes
- Published to Maven Central / NuGet

#### Phase 3: gRPC Service (Weeks 23-28)

**Deliverables:**
- [ ] Tonic-based gRPC server
- [ ] Proto definitions
- [ ] Auto-generated clients (Go, Python, Java, C#)
- [ ] Docker image
- [ ] Kubernetes deployment manifests
- [ ] Health checks and metrics

**Acceptance Criteria:**
- <10ms latency for typical requests
- Horizontal scaling support
- gRPC reflection for tooling

#### Phase 4: WASM Target (Weeks 29-34)

**Deliverables:**
- [ ] wasm32-unknown-unknown target
- [ ] wasm-bindgen integration
- [ ] npm package (wasm)
- [ ] Browser demo
- [ ] Deno compatibility

**Acceptance Criteria:**
- Works in major browsers
- <5MB bundle size
- Performance acceptable for interactive use

#### Phase 5: Polish & Ecosystem (Weeks 35-40)

**Deliverables:**
- [ ] Unified documentation site
- [ ] Performance benchmark suite
- [ ] Integration examples (frameworks)
- [ ] Community contribution guide
- [ ] Long-term support plan

---

## 7. Technical Specifications

### 7.1 C-ABI Specification

#### Function Signatures

```c
// Version and info
const char* meta_oxide_version(void);
const char* meta_oxide_supported_formats(void);

// Core extraction (returns error code)
int meta_oxide_extract_all(
    const char* html,
    size_t html_len,
    const char* base_url,
    meta_oxide_result_t** out_result,
    meta_oxide_error_t** out_error
);

// Individual extractors
int meta_oxide_extract_meta(const char* html, size_t len, const char* base_url,
                            meta_oxide_meta_t** out, meta_oxide_error_t** err);
int meta_oxide_extract_opengraph(const char* html, size_t len, const char* base_url,
                                  meta_oxide_opengraph_t** out, meta_oxide_error_t** err);
// ... (one for each format)

// Memory management
void meta_oxide_free_result(meta_oxide_result_t* result);
void meta_oxide_free_meta(meta_oxide_meta_t* meta);
void meta_oxide_free_opengraph(meta_oxide_opengraph_t* og);
void meta_oxide_free_error(meta_oxide_error_t* error);

// Error codes
#define META_OXIDE_OK 0
#define META_OXIDE_ERR_NULL_INPUT 1
#define META_OXIDE_ERR_INVALID_HTML 2
#define META_OXIDE_ERR_INVALID_URL 3
#define META_OXIDE_ERR_ALLOCATION 4
#define META_OXIDE_ERR_INTERNAL 5
```

### 7.2 Go API Design

```go
package metaoxide

import "context"

type Client struct {
    // internal fields
}

type ExtractResult struct {
    Meta        *Meta
    OpenGraph   *OpenGraph
    Twitter     *TwitterCard
    JsonLD      []JsonLDObject
    Microdata   []MicrodataItem
    RDFa        []RDFaItem
    Microformats *Microformats
    OEmbed      *OEmbed
    DublinCore  *DublinCore
    RelLinks    map[string][]string
    Manifest    *ManifestDiscovery
}

func New() *Client
func (c *Client) ExtractAll(ctx context.Context, html string, baseURL string) (*ExtractResult, error)
func (c *Client) ExtractMeta(ctx context.Context, html string, baseURL string) (*Meta, error)
func (c *Client) ExtractOpenGraph(ctx context.Context, html string, baseURL string) (*OpenGraph, error)
// ... other extractors

func (c *Client) Close() error
```

### 7.3 Node.js API Design

```typescript
// index.d.ts
declare module '@yfedoseev/meta-oxide' {
  interface ExtractResult {
    meta?: Meta;
    opengraph?: OpenGraph;
    twitter?: TwitterCard;
    jsonld?: JsonLDObject[];
    microdata?: MicrodataItem[];
    rdfa?: RDFaItem[];
    microformats?: Microformats;
    oembed?: OEmbed;
    dublinCore?: DublinCore;
    relLinks?: Record<string, string[]>;
    manifest?: ManifestDiscovery;
  }

  export function extractAll(html: string, baseUrl?: string): Promise<ExtractResult>;
  export function extractMeta(html: string, baseUrl?: string): Promise<Meta>;
  export function extractOpenGraph(html: string, baseUrl?: string): Promise<OpenGraph>;
  // ... other extractors

  export const version: string;
}
```

---

## 8. Effort Estimates

### 8.1 Summary by Phase

| Phase | Description | Duration | Effort (Dev Days) |
|-------|-------------|----------|-------------------|
| Phase 0 | C-ABI Foundation | 6 weeks | 30 |
| Phase 1 | Go + Node.js | 8 weeks | 50 |
| Phase 2 | Java + C# | 8 weeks | 50 |
| Phase 3 | gRPC Service | 6 weeks | 30 |
| Phase 4 | WASM Target | 6 weeks | 25 |
| Phase 5 | Polish | 6 weeks | 15 |
| **Total** | | **40 weeks** | **200** |

### 8.2 Detailed Breakdown by Component

#### Phase 0: C-ABI Foundation (30 days)

| Task | Days | Notes |
|------|------|-------|
| Design C API | 3 | Header design, conventions |
| Implement FFI module | 8 | src/ffi/*.rs |
| Memory management | 5 | Free functions, testing |
| Build system | 4 | Cross-platform builds |
| cbindgen setup | 2 | Auto-generate headers |
| Testing | 5 | Valgrind, thread safety |
| Documentation | 3 | C API docs |

#### Phase 1: Go + Node.js (50 days)

**Go (25 days):**
| Task | Days |
|------|------|
| cgo bindings | 8 |
| Go types | 4 |
| Error handling | 3 |
| Tests | 5 |
| Documentation | 3 |
| CI/CD | 2 |

**Node.js (25 days):**
| Task | Days |
|------|------|
| neon-rs setup | 5 |
| N-API bindings | 8 |
| TypeScript types | 3 |
| Async wrappers | 3 |
| Tests | 4 |
| npm packaging | 2 |

#### Phase 2: Java + C# (50 days)

**Java (25 days):**
| Task | Days |
|------|------|
| JNI bindings | 10 |
| Java types | 4 |
| Android support | 5 |
| Tests | 4 |
| Maven setup | 2 |

**C# (25 days):**
| Task | Days |
|------|------|
| P/Invoke bindings | 8 |
| .NET types | 4 |
| SafeHandle impl | 4 |
| Tests | 5 |
| NuGet setup | 2 |
| Documentation | 2 |

### 8.3 Ongoing Maintenance Estimate

| Language | Monthly Hours | Annual Days |
|----------|--------------|-------------|
| C-ABI | 4 | 6 |
| Go | 8 | 12 |
| Node.js | 10 | 15 |
| Java | 8 | 12 |
| C# | 6 | 9 |
| gRPC | 4 | 6 |
| **Total** | **40** | **60** |

---

## 9. Risk Assessment

### 9.1 Risk Matrix

| Risk | Probability | Impact | Mitigation |
|------|-------------|--------|------------|
| C-ABI instability | Medium | High | Semantic versioning, thorough testing |
| Memory leaks in bindings | Medium | High | Valgrind, AddressSanitizer, code review |
| Build complexity | High | Medium | CI/CD automation, Docker builds |
| Version fragmentation | Medium | Medium | Unified release process |
| Performance regression | Low | High | Benchmark suite, performance CI |
| JNI crashes | Medium | High | Defensive coding, extensive testing |
| Maintenance burnout | Medium | High | Clear scope, community engagement |
| Platform-specific bugs | High | Medium | Multi-platform CI, beta testing |

### 9.2 Risk Mitigation Strategies

#### R1: C-ABI Instability
- Commit to semantic versioning (ABI version separate from feature version)
- Comprehensive ABI test suite
- Breaking change documentation and migration guides

#### R2: Memory Safety
- All bindings must pass memory sanitizer tests
- Document ownership clearly in all APIs
- Provide debugging symbols for crash analysis

#### R3: Build Complexity
- Docker-based build environments
- Pre-built binaries for all platforms
- Clear build documentation

#### R4: Maintenance Burden
- Limit initial scope to P1 languages
- Use gRPC for P3 languages instead of native bindings
- Community contribution model for secondary languages

---

## 10. Success Metrics

### 10.1 Technical Metrics

| Metric | Target | Measurement |
|--------|--------|-------------|
| API Parity | 100% | All Python functions available in all languages |
| Performance | <10% overhead | Benchmark vs raw Rust |
| Memory Safety | 0 leaks | Valgrind clean |
| Test Coverage | >90% | Per-language coverage |
| Build Success | >99% | CI pass rate |

### 10.2 Adoption Metrics

| Metric | 6 Month | 12 Month | 24 Month |
|--------|---------|----------|----------|
| npm weekly downloads | 500 | 5,000 | 25,000 |
| Go module imports | 100 | 1,000 | 5,000 |
| Maven downloads | 200 | 2,000 | 10,000 |
| NuGet downloads | 100 | 1,000 | 5,000 |
| GitHub stars (all repos) | 500 | 2,000 | 10,000 |
| Contributors | 5 | 20 | 50 |

### 10.3 Quality Metrics

| Metric | Target |
|--------|--------|
| Issue response time | <48 hours |
| Breaking changes per year | <2 |
| Documentation coverage | 100% public API |
| Example coverage | All major use cases |

---

## 11. Competitive Analysis

### 11.1 Current Landscape by Language

#### Python
| Library | Performance | Formats | Notes |
|---------|-------------|---------|-------|
| **MetaOxide** | Excellent | 13 | **Current leader** |
| extruct | Poor | 5 | Pure Python, slow |
| mf2py | Poor | 1 | Microformats only |
| BeautifulSoup | N/A | 0 | Manual parsing |

#### JavaScript/Node.js
| Library | Performance | Formats | Notes |
|---------|-------------|---------|-------|
| **MetaOxide (planned)** | Excellent | 13 | **Target** |
| metascraper | Fair | 5 | Pure JS, extensible |
| html-metadata | Fair | 4 | Pure JS |
| microformat-node | Poor | 1 | Microformats only |

#### Go
| Library | Performance | Formats | Notes |
|---------|-------------|---------|-------|
| **MetaOxide (planned)** | Excellent | 13 | **Target** |
| goquery | N/A | 0 | DOM parsing only |
| colly | N/A | 0 | Scraping framework |
| *No comprehensive option* | - | - | **Gap in market** |

#### Java
| Library | Performance | Formats | Notes |
|---------|-------------|---------|-------|
| **MetaOxide (planned)** | Excellent | 13 | **Target** |
| Any23 | Fair | 6 | Apache project, heavy |
| jsoup | N/A | 0 | DOM parsing only |
| *No lightweight option* | - | - | **Gap in market** |

#### C#/.NET
| Library | Performance | Formats | Notes |
|---------|-------------|---------|-------|
| **MetaOxide (planned)** | Excellent | 13 | **Target** |
| HtmlAgilityPack | N/A | 0 | DOM parsing only |
| *No comprehensive option* | - | - | **Gap in market** |

### 11.2 MetaOxide Differentiators

1. **Performance**: 10-100x faster than pure-language alternatives
2. **Comprehensiveness**: 13 formats vs typical 3-5
3. **Consistency**: Same behavior across all languages
4. **Quality**: 700+ tests, production-proven
5. **Modern**: Actively maintained, recent standards support
6. **Lightweight**: No heavy dependencies

### 11.3 Competitive Positioning Statement

> MetaOxide is the only metadata extraction library that delivers native Rust performance across all major programming languages while supporting 13 metadata formats. For teams that need fast, accurate, and comprehensive metadata extraction without per-language implementation costs, MetaOxide is the universal solution.

---

## 12. Detailed Todo List

### Phase 0: C-ABI Foundation

#### 0.1 Architecture Design (5 days)
- [ ] Design C-compatible data structures for all 13 formats (2d)
- [ ] Define error codes and error handling strategy (0.5d)
- [ ] Design memory ownership model (0.5d)
- [ ] Write C header file specification (1d)
- [ ] Document ABI stability guarantees (0.5d)
- [ ] Review and finalize design (0.5d)

#### 0.2 Core FFI Implementation (8 days)
- [ ] Create `src/ffi/mod.rs` module structure (0.5d)
- [ ] Implement `MetaOxideString` C-compatible string (1d)
- [ ] Implement `MetaOxideStringArray` for string lists (0.5d)
- [ ] Implement `MetaOxideMeta` FFI struct (1d)
- [ ] Implement `MetaOxideOpenGraph` FFI struct (0.5d)
- [ ] Implement `MetaOxideTwitterCard` FFI struct (0.5d)
- [ ] Implement `MetaOxideJsonLd` FFI struct (1d)
- [ ] Implement `MetaOxideMicrodata` FFI struct (0.5d)
- [ ] Implement `MetaOxideResult` aggregate struct (1d)
- [ ] Implement type conversion from Rust types to FFI types (1.5d)

#### 0.3 FFI Functions (5 days)
- [ ] Implement `meta_oxide_extract_all` (1d)
- [ ] Implement individual extractor functions (2d)
- [ ] Implement memory free functions (1d)
- [ ] Implement version and info functions (0.5d)
- [ ] Error handling implementation (0.5d)

#### 0.4 Build System (4 days)
- [ ] Configure `cdylib` output in Cargo.toml (0.5d)
- [ ] Setup cbindgen for header generation (1d)
- [ ] Create cross-platform build scripts (1d)
- [ ] Setup CI for Linux/macOS/Windows builds (1d)
- [ ] Create release packaging scripts (0.5d)

#### 0.5 Testing (5 days)
- [ ] Write C-ABI unit tests (2d)
- [ ] Memory leak testing with Valgrind (1d)
- [ ] Thread safety testing (1d)
- [ ] Cross-platform verification (1d)

#### 0.6 Documentation (3 days)
- [ ] C API reference documentation (1d)
- [ ] Memory management guide (1d)
- [ ] Build and integration guide (1d)

### Phase 1: Go Bindings

#### 1.1 Go Module Setup (3 days)
- [ ] Create repository: `meta-oxide-go` (0.5d)
- [ ] Setup Go module structure (0.5d)
- [ ] Configure cgo build (1d)
- [ ] Setup CI/CD with GitHub Actions (1d)

#### 1.2 cgo Bindings (8 days)
- [ ] Import C header and library (1d)
- [ ] Create Go wrapper types (2d)
- [ ] Implement `ExtractAll` function (1d)
- [ ] Implement individual extractor functions (2d)
- [ ] Handle memory management properly (1d)
- [ ] Implement context support for cancellation (1d)

#### 1.3 Go Types (4 days)
- [ ] Define all Go struct types (2d)
- [ ] Implement type converters (1d)
- [ ] Add JSON marshaling support (1d)

#### 1.4 Testing (5 days)
- [ ] Unit tests for all functions (2d)
- [ ] Integration tests (1d)
- [ ] Benchmark tests (1d)
- [ ] Race condition tests (1d)

#### 1.5 Documentation & Release (5 days)
- [ ] Write README.md (1d)
- [ ] Write API documentation (1d)
- [ ] Create examples (1d)
- [ ] Setup pkg.go.dev (0.5d)
- [ ] Create release process (1.5d)

### Phase 1: Node.js Bindings

#### 1.6 Project Setup (3 days)
- [ ] Create repository: `meta-oxide-node` (0.5d)
- [ ] Setup npm package structure (0.5d)
- [ ] Configure neon-rs (1d)
- [ ] Setup TypeScript compilation (1d)

#### 1.7 N-API Bindings (8 days)
- [ ] Setup neon build configuration (1d)
- [ ] Implement native module entry point (1d)
- [ ] Create JavaScript wrapper types (2d)
- [ ] Implement `extractAll` async function (1d)
- [ ] Implement individual extractor functions (2d)
- [ ] Handle errors properly (1d)

#### 1.8 TypeScript Types (3 days)
- [ ] Write type definitions for all formats (2d)
- [ ] Generate JSDoc from types (1d)

#### 1.9 Async Wrappers (3 days)
- [ ] Implement Promise-based API (1d)
- [ ] Add worker thread support for heavy operations (1d)
- [ ] Handle Node.js event loop properly (1d)

#### 1.10 Testing & Release (8 days)
- [ ] Write Jest test suite (3d)
- [ ] Setup npm publishing (1d)
- [ ] Write README and documentation (2d)
- [ ] Create examples (2d)

### Phase 2: Java Bindings

#### 2.1 Project Setup (3 days)
- [ ] Create Maven project structure (1d)
- [ ] Setup JNI build with Gradle/Maven (1d)
- [ ] Configure cross-compilation (1d)

#### 2.2 JNI Bindings (10 days)
- [ ] Create JNI wrapper header (1d)
- [ ] Implement native methods in Rust/C (4d)
- [ ] Create Java native method declarations (2d)
- [ ] Implement Java wrapper classes (2d)
- [ ] Handle native library loading (1d)

#### 2.3 Java Types (4 days)
- [ ] Create POJO types for all formats (2d)
- [ ] Add Jackson annotations for JSON (1d)
- [ ] Implement builder patterns (1d)

#### 2.4 Android Support (5 days)
- [ ] Configure NDK builds (2d)
- [ ] Create AAR artifact (1d)
- [ ] Test on Android emulators (2d)

#### 2.5 Testing & Release (3 days)
- [ ] Write JUnit tests (1d)
- [ ] Setup Maven Central publishing (1d)
- [ ] Documentation and Javadoc (1d)

### Phase 2: C# Bindings

#### 2.6 Project Setup (2 days)
- [ ] Create .NET solution structure (1d)
- [ ] Setup NuGet packaging (1d)

#### 2.7 P/Invoke Bindings (8 days)
- [ ] Create P/Invoke declarations (2d)
- [ ] Implement SafeHandle wrappers (2d)
- [ ] Create C# wrapper classes (2d)
- [ ] Handle string marshaling (1d)
- [ ] Platform-specific native library loading (1d)

#### 2.8 .NET Types (4 days)
- [ ] Create record types for all formats (2d)
- [ ] Add System.Text.Json attributes (1d)
- [ ] Implement IDisposable where needed (1d)

#### 2.9 Testing & Release (5 days)
- [ ] Write xUnit tests (2d)
- [ ] Setup NuGet publishing (1d)
- [ ] XML documentation (1d)
- [ ] Create examples (1d)

### Phase 3: gRPC Service

#### 3.1 Proto Definition (3 days)
- [ ] Design proto messages for all formats (2d)
- [ ] Define service methods (1d)

#### 3.2 Server Implementation (8 days)
- [ ] Setup Tonic gRPC server (2d)
- [ ] Implement service methods (3d)
- [ ] Add streaming support (2d)
- [ ] Health checks and reflection (1d)

#### 3.3 Client Generation (5 days)
- [ ] Generate Go client (1d)
- [ ] Generate Python client (1d)
- [ ] Generate Java client (1d)
- [ ] Generate C# client (1d)
- [ ] Generate TypeScript client (1d)

#### 3.4 Deployment (6 days)
- [ ] Create Dockerfile (1d)
- [ ] Kubernetes manifests (2d)
- [ ] Helm chart (2d)
- [ ] Documentation (1d)

#### 3.5 Testing (8 days)
- [ ] Integration tests (3d)
- [ ] Performance benchmarks (2d)
- [ ] Load testing (2d)
- [ ] Documentation (1d)

### Phase 4: WASM Target

#### 4.1 WASM Build Setup (5 days)
- [ ] Configure wasm32-unknown-unknown target (1d)
- [ ] Setup wasm-bindgen (2d)
- [ ] Optimize binary size (2d)

#### 4.2 JavaScript Integration (8 days)
- [ ] Create JS wrapper module (2d)
- [ ] TypeScript definitions (1d)
- [ ] npm package configuration (1d)
- [ ] Async loading support (2d)
- [ ] Browser compatibility testing (2d)

#### 4.3 Testing & Release (7 days)
- [ ] Browser tests (2d)
- [ ] Node.js WASM tests (2d)
- [ ] Deno compatibility (1d)
- [ ] Documentation (2d)

### Phase 5: Polish & Ecosystem

#### 5.1 Documentation (6 days)
- [ ] Create unified documentation site (2d)
- [ ] Write getting started guides per language (2d)
- [ ] API reference consolidation (2d)

#### 5.2 Examples (4 days)
- [ ] Framework integration examples (2d)
- [ ] Real-world use case tutorials (2d)

#### 5.3 Benchmarks (3 days)
- [ ] Cross-language benchmark suite (2d)
- [ ] Performance comparison documentation (1d)

#### 5.4 Community (2 days)
- [ ] Contribution guide (1d)
- [ ] Issue templates and processes (1d)

---

## Publishing & Distribution Strategy

### Package Registry Overview

| Language | Registry | Package Name | Notes |
|----------|----------|--------------|-------|
| Rust | crates.io | `meta_oxide` | Already published |
| Python | PyPI | `meta-oxide` | Already published |
| Go | GitHub | `github.com/yfedoseev/meta-oxide-go` | Go modules |
| Node.js | npm | `@yfedoseev/meta-oxide` | Scoped package |
| Java | Maven Central | `io.github.yfedoseev:meta-oxide` | Group ID |
| C# | NuGet | `MetaOxide` | .NET Standard 2.0 |
| WASM | npm | `@yfedoseev/meta-oxide-wasm` | Separate package |

### Release Process

1. **Version Alignment**: All packages share same version number
2. **Changelog**: Unified changelog across all packages
3. **CI/CD**: Automated releases on tag push
4. **Pre-release**: Beta versions for testing
5. **LTS**: Major versions supported for 2 years

---

## Conclusion

The hybrid approach provides the optimal balance between performance, reach, and maintenance burden. By investing in a stable C-ABI layer first, we create a foundation that enables high-quality bindings across all target languages while maintaining a single source of truth in the Rust core.

The phased approach allows for iterative delivery of value, with Go and Node.js bindings providing the largest immediate impact. Enterprise languages (Java, C#) follow in Phase 2, with gRPC providing a universal fallback for remaining languages.

With a total estimated effort of 200 developer days over 40 weeks, MetaOxide can achieve true universal language support and establish itself as the industry standard for metadata extraction.