A simple secret management system with a React UI and Go API backend for securely storing and managing secrets.
- π Create, read, update, and delete secrets
- π¨ Modern React UI with a beautiful interface
- π Fast Go API backend with Gin framework
- πΎ MongoDB for persistent storage
- Frontend: React with Vite
- Backend: Go with Gin framework
- Database: MongoDB (persistent storage)
- Driver: Official MongoDB Go Driver
- Go 1.21 or later
- Node.js 18+ and npm
- MongoDB 4.4+ (or use Docker Compose)
- Docker (optional, for containerized deployment)
The easiest way is to use Docker Compose which includes MongoDB:
docker-compose up -dThis will start MongoDB, API, and UI services.
- Install and start MongoDB:
# On Ubuntu/Debian
sudo apt-get install mongodb
sudo systemctl start mongodb
# On macOS (using Homebrew)
brew install mongodb-community
brew services start mongodb-community- Create database and user (optional, MongoDB creates databases automatically):
mongoshThen in the MongoDB shell:
use vault
db.createUser({
user: "vault",
pwd: "vault",
roles: [{ role: "readWrite", db: "vault" }]
})- Set environment variables:
export DB_HOST=localhost
export DB_USER=vault
export DB_PASSWORD=vault
export DB_NAME=vault
export DB_PORT=27017Or use a connection string:
export MONGODB_URI="mongodb://vault:vault@localhost:27017/vault?authSource=admin"- Navigate to the API directory:
cd api- Install dependencies:
go mod download- Run the API server:
go run main.goThe API will start on http://localhost:8080 by default. You can change the port by setting the PORT environment variable.
Note: MongoDB will automatically create the database and collections on first use. No manual schema creation is needed.
- Navigate to the UI directory:
cd ui- Install dependencies:
npm install- Start the development server:
npm run devThe UI will start on http://localhost:5173 by default.
- Configure the API URL (optional):
Create a
.envfile in theuidirectory:
VITE_API_URL=http://localhost:8080/api/v1
GET /api/v1/secrets- Get all secretsGET /api/v1/secrets/:id- Get a specific secretPOST /api/v1/secrets- Create a new secretPUT /api/v1/secrets/:id- Update a secretDELETE /api/v1/secrets/:id- Delete a secret
# Build API image
cd api
docker build -t simple-vault-api:latest .
# Build UI image
cd ../ui
docker build -t simple-vault-ui:latest .docker-compose up -dThis will start both the API and UI services.
-
Create a Secret:
- Click "Create Secret" button
- Enter a name and optional description
- Add key-value pairs for your secrets
- Click "Create"
-
Edit a Secret:
- Click the edit icon (βοΈ) on any secret card
- Modify the secret data
- Click "Update"
-
Delete a Secret:
- Click the delete icon (ποΈ) on any secret card
- Confirm the deletion
The application uses MongoDB for persistent storage. Secrets are stored in a secrets collection with the following structure:
_id(string, primary key - UUID)name(string, required)description(string, optional)data(object/map, stores key-value pairs)createdAt(timestamp)updatedAt(timestamp)
The API supports the following database configuration options:
Option 1: Individual variables
DB_HOST- Database host (default: localhost)DB_USER- Database user (optional, for authentication)DB_PASSWORD- Database password (optional, for authentication)DB_NAME- Database name (default: vault)DB_PORT- Database port (default: 27017)
Option 2: Connection string (recommended)
MONGODB_URI- Full MongoDB connection string- Example:
mongodb://user:password@host:port/dbname?authSource=admin - Example (no auth):
mongodb://localhost:27017/vault
- Example:
MongoDB automatically creates collections when first used. The secrets collection will be created automatically when you create your first secret. An index is created on the name field for faster lookups.
- Adding authentication and authorization
- Encrypting secrets at rest (MongoDB supports encryption at rest, or use application-level encryption)
- Using MongoDB's built-in encryption features
- Implementing audit logging
- Adding rate limiting
- Using connection pooling (already implemented in MongoDB driver)
- Regular database backups
- Using external secret management systems (e.g., HashiCorp Vault) for production workloads
# Backend tests
cd api
go test ./...
# Frontend tests (if configured)
cd ui
npm testsimple-vault/
βββ api/
β βββ main.go # Go API server
β βββ go.mod # Go dependencies
βββ ui/
β βββ src/
β β βββ App.jsx # Main React component
β β βββ App.css # Styles
β β βββ main.jsx # React entry point
β βββ package.json # Node dependencies
β βββ vite.config.js # Vite configuration
βββ docker-compose.yml # Docker Compose configuration
βββ README.md # This file
MIT
Contributions are welcome! Please feel free to submit a Pull Request.