Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/QuickStartFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Link from "@docusaurus/Link";
import {FaGolang} from "react-icons/fa6";
import {FaJava, FaLaptopCode, FaDocker, FaPython, FaCheck, FaArrowRight, FaArrowLeft} from "react-icons/fa";
import {TbBrandCSharp} from "react-icons/tb";
import { TbBrandRust } from "react-icons/tb";
Comment thread
Gagan202005 marked this conversation as resolved.
Outdated
import {IoLogoJavascript} from "react-icons/io5";
import {useColorMode} from "@docusaurus/theme-common";

Expand All @@ -28,6 +29,8 @@ export default function QuickstartFilter({defaultLanguage = null}) {
{name: "Java", icon: <FaJava size={24} />, color: "#007396"},
{name: "JS/TS", icon: <IoLogoJavascript size={24} />, color: "#F7DF1E"},
{name: "C#", icon: <TbBrandCSharp size={24} />, color: "#512BD4"},
{name: "Rust", icon: <TbBrandRust size={24} />, color: "#DEA584"},

];

const servers = [
Expand Down
20 changes: 20 additions & 0 deletions src/components/QuickStartList.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,26 @@ const quickstarts = [
"A sample app to demonstrate Keploy integration capabilities using TypeScript and Nhost.",
link: "/docs/quickstart/samples-typescript/#running-the-app-using-docker",
},

// rust list
{
title: "Rust + MongoDB",
language: "Rust",
server: "Local",
description:
"A sample Rust CRUD notes application using MongoDB to demonstrate how Keploy records API calls and database interactions automatically and replays them without manual test writing.",
link: "/docs/quickstart/samples-rust-mongodb/#running-app-locally",
},
{
title: "Rust + MongoDB",
language: "Rust",
server: "Docker",
description:
"A sample Rust CRUD notes application using MongoDB to demonstrate Keploy record & replay workflows using Docker Compose.",
link: "/docs/quickstart/samples-rust-mongodb/#using-docker-compose",
},


];

export default quickstarts;
13 changes: 9 additions & 4 deletions src/components/SidebarCategoryIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import {
import {
SiKubernetes,
SiDocker,
SiGithubactions
SiGithubactions,
} from 'react-icons/si';
import { TbBrandRust } from 'react-icons/tb';
Comment thread
Gagan202005 marked this conversation as resolved.
Outdated

/**
* SidebarCategoryIcon - Icon component for sidebar top-level categories
Expand All @@ -48,12 +49,13 @@ const categoryIcons = {
'security': FaShieldAlt,
'operation': FaTools,

// Language/Framework categories
// Language / Framework categories
'java': FaCode,
'golang': FaCode,
'python': FaCode,
'javascript': FaCode,
'typescript': FaCode,
'rust': FaCode,

// Infrastructure
'docker': SiDocker,
Expand All @@ -79,7 +81,11 @@ export function getCategoryIcon(categoryLabel) {
return categoryIcons[key] || null;
}

export default function SidebarCategoryIcon({ category, size = 16, className = '' }) {
export default function SidebarCategoryIcon({
category,
size = 16,
className = '',
}) {
const Icon = getCategoryIcon(category);

if (!Icon) return null;
Expand Down Expand Up @@ -113,4 +119,3 @@ export default function SidebarCategoryIcon({ category, size = 16, className = '

// Export icon mapping for use in sidebar configuration
export { categoryIcons };

Binary file added static/img/rust-mongodb-docker-record.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/rust-mongodb-docker-replay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/rust-mongodb-local-record.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/rust-mongodb-local-replay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
282 changes: 282 additions & 0 deletions versioned_docs/version-4.0.0/quickstart/samples-rust-mongodb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
---
id: samples-rust-mongodb
title: Rust + MongoDB
sidebar_label: Rust + MongoDB
description: This sample app demonstrates how to use Rust with MongoDB and Keploy to automatically record and replay API test cases.
tags:
- rust
- quickstart
- samples
- examples
- tutorial
- mongodb
- keploy
keyword:
- Rust
- MongoDB
- Keploy
- API Test Generator
- Auto Testcase Generation
---

import EnterpriseInstallReminder from '@site/src/components/EnterpriseInstallReminder';
import SectionDivider from '@site/src/components/SectionDivider';
import ProductTier from '@site/src/components/ProductTier';

# Using Docker Compose 🐳. {#using-docker-compose}
Comment thread
Gagan202005 marked this conversation as resolved.
Outdated

<ProductTier tiers="Enterprise" offerings="Self-Hosted, Dedicated" />

A simple **Notes REST API** built with **Rust** and **MongoDB**, showcasing **Keploy’s record & replay** capabilities without writing manual test cases.

<EnterpriseInstallReminder />

---

### Clone the Sample Application

```bash
git clone https://github.com/Gagan202005/Keploy-Rust-Mongodb-QuickStart.git
cd Keploy-Rust-Mongodb-QuickStart
```
### Rust (Cargo)

Rust is required to build and run the application.

Install Rust using **rustup**:
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
```
**Verify installation**:
```bash
rustc --version
cargo --version
```

### Lights, Camera, Record!


Start MongoDB and Mongo Express using Docker Compose:

```bash
docker compose up -d mongo mongo-express
```

Build & Run the Application 🛠️
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be formatted as a heading for consistency with the document structure. Add "###" prefix to make it a subsection heading.

Suggested change
Build & Run the Application 🛠️
### Build & Run the Application 🛠️

Copilot uses AI. Check for mistakes.

```bash
docker compose up -d --build app
```

Verify the application:

```bash
curl http://localhost:8000/
```

Expected response:
```bash
Rust + MongoDB + Keploy Quickstart is running!
```
### Capture Test Cases

Start recording with Keploy:

```bash
keploy record -c "docker compose up --build app" --container-name keploy-rust-app
```

Now make some API calls (via curl, Postman, or Hoppscotch).
Comment thread
Gagan202005 marked this conversation as resolved.
Outdated

1️⃣ Create a Note

```bash
curl -X POST http://localhost:8000/notes \
-H "Content-Type: application/json" \
-d '{"text":"hello keploy"}'
```

Response:

```bash
{
"text": "hello keploy"
}
```

2️⃣ Fetch All Notes

```bash
curl http://localhost:8000/notes
```

Response:

```bash
{
"text": "hello keploy"
}
```
We will get output something like this:

![Keploy Record Mode](../../../static/img/rust-mongodb-docker-record.png)

Keploy automatically records:

- HTTP test cases

- MongoDB mocks

Recorded data is stored at:

```bash
keploy/test-set-0/tests
keploy/test-set-0/mocks
```

### Run Tests ▶️

Replay the recorded test cases:

```bash
keploy test -c "docker compose up --build app" --delay 10 --container-name keploy-rust-app
```
We will get output something like this:

![Keploy Replay Mode](../../../static/img/rust-mongodb-docker-replay.png)

The --delay flag allows the application time to start before replay begins.

<SectionDivider />
# Running Locally on Linux / WSL 🐧 {#running-app-locally}

<ProductTier tiers="Enterprise" offerings="Self-Hosted, Dedicated" />
A simple Notes REST API built with Rust and MongoDB, showcasing Keploy’s record & replay capabilities without writing manual test cases.



In local mode:


- MongoDB runs in Docker

- Rust application runs using cargo run

### Clone the Sample Application

```bash
git clone https://github.com/Gagan202005/Keploy-Rust-Mongodb-QuickStart.git
cd Keploy-Rust-Mongodb-QuickStart
```
### Rust (Cargo)

Rust is required to build and run the application locally.

Install Rust using **rustup**:
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
```

**Verify installation**:
```bash
rustc --version
cargo --version
```
### Lights, Camera, Record!

**Start MongoDB**

```bash
docker compose up -d mongo mongo-express
```

**Run the Application**

```bash
cargo run
```

You should see:
```bash
Server running at http://localhost:8000
```
### Record Tests (Local)

Start recording:

```bash
keploy record -c "cargo run"
```

Now make some API calls (via curl, Postman, or Hoppscotch).

1️⃣ Create a Note

```bash
curl -X POST http://localhost:8000/notes \
-H "Content-Type: application/json" \
-d '{"text":"hello keploy"}'
```

Response:

```bash
{
"text": "hello keploy"
}
```

2️⃣ Fetch All Notes

```bash
curl http://localhost:8000/notes
```

Response:

```bash
{
"text": "hello keploy"
}
```
We will get output something like this:

![Keploy Replay Mode](../../../static/img/rust-mongodb-local-record.png)
Comment thread
Gagan202005 marked this conversation as resolved.
Outdated


Stop recording:

- `Ctrl + C`

### Replay Tests (Local)

```bash
keploy test -c "cargo run" --delay 10
```
We will get output something like this:

![Keploy Replay Mode](../../../static/img/rust-mongodb-local-replay.png)

<SectionDivider />

# Wrapping It Up

You’ve successfully:

- Built a Rust + MongoDB REST API

- Recorded real API traffic using Keploy

- Replayed deterministic tests without hitting the database

Feel free to explore further by modifying:

- `test-x.yml`

- `mocks.yml`

Happy Testing with Keploy 🐰✨

<SectionDivider />
Loading