Skip to content

Commit 86b1134

Browse files
committed
Initiate docusaurus website
1 parent 4bdc815 commit 86b1134

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+20436
-1
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ pkg/
1010

1111
# Outputs of build-tests-webrtc
1212
cargo-build-test.json
13-
tests.tsv
13+
tests.tsv
14+
15+
# Generated API docs should not be committed
16+
website/static/api-docs/

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,33 @@ postgres-setup: ## Set up PostgreSQL database for archive node
259259
@sudo -u postgres psql -c "ALTER USER $(PG_USER) PASSWORD '$(PG_PW)'" 2>/dev/null || true
260260
@sudo -u postgres createdb -O $(PG_USER) $(PG_DB) 2>/dev/null || true
261261
@sudo -u postgres createdb -O $(PG_USER) $(PG_USER) 2>/dev/null || true
262+
263+
# Documentation targets
264+
.PHONY: docs-install
265+
docs-install: ## Install documentation dependencies
266+
@echo "Installing documentation dependencies..."
267+
@cd website && npm install
268+
269+
.PHONY: docs-build
270+
docs-build: docs-install ## Build the documentation website
271+
@echo "Building documentation website..."
272+
@cd website && npm run build
273+
@echo "Documentation built successfully!"
274+
@echo "Built files are in website/build/"
275+
276+
.PHONY: docs-serve
277+
docs-serve: docs-install ## Serve the documentation website locally
278+
@echo "Starting documentation server..."
279+
@echo "Documentation will be available at: http://localhost:3000"
280+
@cd website && npm start
281+
282+
.PHONY: docs-build-serve
283+
docs-build-serve: docs-build ## Build and serve the documentation website locally
284+
@echo "Serving built documentation at: http://localhost:3000"
285+
@cd website && npm run serve
286+
287+
.PHONY: docs-clean
288+
docs-clean: ## Clean documentation build artifacts
289+
@echo "Cleaning documentation build artifacts..."
290+
@rm -rf website/build website/.docusaurus
291+
@echo "Documentation artifacts cleaned!"

website/.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
11+
# Misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*

website/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# OpenMina Documentation Website
2+
3+
This directory contains the Docusaurus-based documentation website for OpenMina.
4+
5+
## Quick Start
6+
7+
### Development
8+
```bash
9+
# From project root
10+
make docs-serve
11+
# Or directly:
12+
cd website && npm start
13+
```
14+
15+
### Build
16+
```bash
17+
# From project root
18+
make docs-build
19+
# Or directly:
20+
cd website && npm run build
21+
```
22+
23+
### Serve Built Site
24+
```bash
25+
# From project root
26+
make docs-build-serve
27+
# Or directly:
28+
cd website && npm run serve
29+
```
30+
31+
## Structure
32+
33+
### User-Focused Documentation
34+
The documentation is organized around three main user personas:
35+
36+
- **Node Runners** (`docs/node-runners/`) - Installation, configuration, and operation guides
37+
- **Developers** (`docs/developers/`) - Architecture, codebase understanding, and contribution guides
38+
- **Researchers** (`docs/researchers/`) - Protocol details, cryptography, and research materials
39+
40+
### Configuration
41+
- `docusaurus.config.ts` - Main configuration file
42+
- `sidebars.ts` - Navigation structure for each user type
43+
- `src/pages/index.tsx` - Homepage
44+
- `src/components/` - Custom React components
45+
46+
## Adding Documentation
47+
48+
### New Pages
49+
1. Create markdown files in the appropriate directory (`docs/node-runners/`, `docs/developers/`, or `docs/researchers/`)
50+
2. Add frontmatter with title, description, and sidebar position:
51+
```yaml
52+
---
53+
sidebar_position: 1
54+
title: Page Title
55+
description: Brief description for SEO
56+
---
57+
```
58+
3. Update `sidebars.ts` to include the new page in navigation
59+
60+
### Editing Content
61+
Simply edit the markdown files - developers only need to modify markdown files, not the Docusaurus configuration.
62+
63+
## Versioning
64+
65+
The site supports versioning with the current version labeled as "develop". When tags are created, new documentation versions will be automatically deployed.
66+
67+
## Available Commands
68+
69+
From project root using Makefile:
70+
- `make docs-install` - Install dependencies
71+
- `make docs-build` - Build the website
72+
- `make docs-serve` - Start development server
73+
- `make docs-build-serve` - Build and serve locally
74+
- `make docs-clean` - Clean build artifacts
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
sidebar_position: 1
3+
title: Architecture Overview
4+
description: Understand OpenMina's Redux-style state machine architecture and design principles
5+
slug: /developers/architecture
6+
---
7+
8+
# OpenMina Architecture
9+
10+
OpenMina follows a Redux-style state machine architecture for predictable, debuggable behavior. This design ensures that all state changes are traceable and the system behavior is deterministic.
11+
12+
## Core Principles
13+
14+
### State Machine Pattern
15+
16+
OpenMina implements Redux principles adapted for a blockchain node:
17+
18+
- **State** - Centralized, immutable data structure representing the entire node state
19+
- **Actions** - Events that trigger state changes throughout the system
20+
- **Enabling Conditions** - Guards that prevent invalid state transitions
21+
- **Reducers** - Pure functions that update state and dispatch new actions
22+
- **Effects** - Thin wrappers for service calls and side effects
23+
- **Services** - Separate threads handling I/O and heavy computation
24+
25+
### Predictable State Management
26+
27+
Every state change in OpenMina follows the same pattern:
28+
29+
```rust
30+
// 1. Action is dispatched
31+
dispatch(SomeAction { data });
32+
33+
// 2. Enabling condition is checked
34+
if enabling_condition_met(&state, &action) {
35+
// 3. Reducer processes the action
36+
let new_state = reducer(state, action);
37+
38+
// 4. Effects may be triggered
39+
trigger_effects(&new_state, &action);
40+
}
41+
```
42+
43+
## Architecture Styles
44+
45+
The codebase contains two architectural styles:
46+
47+
### New Style (Recommended)
48+
- **Unified reducers** that handle both state updates and action dispatch
49+
- Single file per component containing all logic
50+
- Cleaner separation of concerns
51+
52+
### Old Style (Being Migrated)
53+
- Separate reducer and effects files
54+
- Split between `*_reducer.rs` and `*_effects.rs`
55+
- Gradually being converted to new style
56+
57+
## Component Structure
58+
59+
### Core Components
60+
61+
**Node** - Main node logic
62+
- Block production and validation
63+
- Transaction pool management
64+
- Consensus and blockchain state
65+
- RPC interface
66+
67+
**P2P** - Networking layer
68+
- Dual transport: libp2p and WebRTC
69+
- Peer discovery and connection management
70+
- Message routing and validation
71+
72+
**Ledger** - Blockchain state
73+
- Account state and transactions
74+
- Proof verification
75+
- Scan state management
76+
77+
**Core** - Shared utilities
78+
- Common types and data structures
79+
- Cryptographic primitives
80+
- Configuration management
81+
82+
### File Organization
83+
84+
Each component follows consistent patterns:
85+
86+
- `*_state.rs` - State definitions and data structures
87+
- `*_actions.rs` - Action types and event definitions
88+
- `*_reducer.rs` - State transition logic
89+
- `*_effects.rs` - Service interaction wrappers
90+
- `*_service.rs` - Service interface definitions
91+
- `summary.md` - Component documentation
92+
93+
## Data Flow
94+
95+
1. **External Events** (network messages, user commands) create actions
96+
2. **Actions** flow through the dispatch system
97+
3. **Enabling Conditions** validate whether actions can be processed
98+
4. **Reducers** compute new state based on current state and action
99+
5. **Effects** trigger service calls when state changes require external interaction
100+
6. **Services** handle async operations and generate new events
101+
102+
## Key Benefits
103+
104+
- **Debuggability** - Complete state history and action replay
105+
- **Testability** - Pure functions and predictable state changes
106+
- **Maintainability** - Clear separation of concerns and data flow
107+
- **Performance** - Efficient state updates and selective processing
108+
109+
## Development Guidelines
110+
111+
- Use `bug_condition!` macro for theoretically unreachable code paths
112+
- Extract complex logic into state methods rather than bloating reducers
113+
- Prefer enabling conditions over error handling in reducers
114+
- Document component responsibilities in `summary.md` files
115+
116+
For detailed implementation examples, see the component-specific documentation in the codebase.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
sidebar_position: 2
3+
title: Why OpenMina?
4+
description: Learn about the motivation and benefits of developing OpenMina as an alternative Mina Protocol implementation
5+
---
6+
7+
# Why are we developing the Open Mina node and the Mina Web node?
8+
9+
## Diversifying the Mina ecosystem
10+
11+
Just as with any blockchain, Mina benefits from increasing its diversity of
12+
nodes. It contributes to the network’s security, improves the protocol's clarity
13+
and ensures transparency across the blockchain. Additionally, it fosters an
14+
environment conducive to innovation while also safeguarding the integrity of all
15+
network participants.
16+
17+
## Choosing Rust for safety and stability
18+
19+
In systems responsible for safeguarding financial data, such as Mina, security
20+
and stability are of paramount importance. Hence, we have chosen Rust as our
21+
preferred language due to its exceptional levels of security, memory safety, and
22+
its ability to prevent concurrency issues, such as race conditions.
23+
24+
## Increasing network resilience
25+
26+
With multiple development teams actively engaged in creating various node
27+
implementations, the identification and resolution of bugs become a smoother
28+
process, diminishing the likelihood of negative impacts on the ecosystem. Since
29+
the burden of chain validation isn't concentrated in a single implementation,
30+
any bugs that do arise are effectively isolated within a limited subset of
31+
nodes, minimizing the potential impact on the entire blockchain.
32+
33+
## More node options for the Mina community
34+
35+
Lastly, users always benefit from having more options for running a Mina node.
36+
People may have different preferences when it comes to node implementations.
37+
Each programming language brings its own unique set of features to the table.
38+
The availability of a wide range of nodes empowers users to make choices that
39+
align with their specific preferences and requirements.

website/docs/intro.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Tutorial Intro
6+
7+
Let's discover **Docusaurus in less than 5 minutes**.
8+
9+
## Getting Started
10+
11+
Get started by **creating a new site**.
12+
13+
Or **try Docusaurus immediately** with **[docusaurus.new](https://docusaurus.new)**.
14+
15+
### What you'll need
16+
17+
- [Node.js](https://nodejs.org/en/download/) version 18.0 or above:
18+
- When installing Node.js, you are recommended to check all checkboxes related to dependencies.
19+
20+
## Generate a new site
21+
22+
Generate a new Docusaurus site using the **classic template**.
23+
24+
The classic template will automatically be added to your project after you run the command:
25+
26+
```bash
27+
npm init docusaurus@latest my-website classic
28+
```
29+
30+
You can type this command into Command Prompt, Powershell, Terminal, or any other integrated terminal of your code editor.
31+
32+
The command also installs all necessary dependencies you need to run Docusaurus.
33+
34+
## Start your site
35+
36+
Run the development server:
37+
38+
```bash
39+
cd my-website
40+
npm run start
41+
```
42+
43+
The `cd` command changes the directory you're working with. In order to work with your newly created Docusaurus site, you'll need to navigate the terminal there.
44+
45+
The `npm run start` command builds your website locally and serves it through a development server, ready for you to view at http://localhost:3000/.
46+
47+
Open `docs/intro.md` (this page) and edit some lines: the site **reloads automatically** and displays your changes.

0 commit comments

Comments
 (0)