Skip to content

MartinezAvellan/confy

Repository files navigation

Confy - Configuration Management System

A powerful CRUD system for configuration management with JWT authentication and access token support, built in Go with MongoDB and Ristretto cache. Features a cyberpunk-themed web interface with OpenBMC Web UI Style Guide compliance.

✨ Features

  • 🔐 Dual Authentication: JWT for user auth + Access tokens for API integration
  • 📝 Complete Configuration CRUD: Create, read, update, delete settings
  • 🎯 Access Token Management: Generate tokens for external applications
  • 🚀 Ristretto Cache: High-performance in-memory caching with automatic invalidation
  • 🌐 Public API: Token-based endpoints for external consumption
  • 🎨 Cyberpunk UI: Modern responsive interface with Vice City theme
  • 📊 MongoDB Database: Reliable document storage
  • 🐳 Docker Ready: Containerized with distroless image
  • 🔔 Toast Notifications: OpenBMC compliant notification system
  • 🎛️ Toggle Controls: Enable/disable settings and tokens

🛠️ Technologies Used

  • Backend: Go (Gin framework)
  • Database: MongoDB
  • Cache: Ristretto (In-memory)
  • Authentication: JWT + Access Tokens
  • Frontend: HTML5, CSS3, JavaScript (Cyberpunk theme)
  • UI Framework: OpenBMC Web UI Style Guide
  • Containerization: Docker & Docker Compose
  • Middleware: Custom authentication & logging

Installation and Setup

Using Docker (Recommended)

  1. Clone the repository:
git clone https://github.com/MartinezAvellan/confy.git
cd confy
  1. Run with Docker Compose:
docker-compose up --build
  1. Access the application at http://localhost:8080

Local Development

  1. Make sure you have Go 1.24+ and MongoDB installed

  2. Configure environment variables:

cp .env.example .env
# Edit the .env file as needed
  1. Install dependencies:
go mod tidy
  1. Run the application:
go run main.go

Usage

1. User Registration

  • Go to /register
  • Fill in username, email and password
  • Click "Register"

2. Login

  • Go to /login
  • Use your credentials to login
  • You will be redirected to the dashboard

3. Manage Configurations

  • In the dashboard, you can:
    • Create new settings with environment support
    • Edit existing configurations inline
    • Delete configurations (with double-click confirmation)
    • Toggle enable/disable settings
    • View all your configurations with search/filter

4. Access Token Management

  • Generate access tokens for external applications
  • Manage token permissions and status
  • Use tokens to access public API endpoints

5. API Integration

  • Use the Postman collection for easy API testing
  • Integrate with external applications using access tokens
  • Access settings via public API endpoints

📡 API Endpoints

Authentication

  • POST /api/register - Register new user
  • POST /api/login - User login (returns JWT token)

Settings Management (JWT Authentication)

  • POST /api/settings - Create configuration
  • GET /api/settings - List all configurations
  • GET /api/settings/:id - Get specific configuration
  • PUT /api/settings/:id - Update configuration
  • PATCH /api/settings/:id/toggle - Toggle enable/disable
  • DELETE /api/settings/:id - Delete configuration

Access Tokens (JWT Authentication)

  • POST /api/tokens - Create access token
  • GET /api/tokens - List all tokens
  • PUT /api/tokens/:id - Update token
  • PATCH /api/tokens/:id/toggle - Toggle enable/disable
  • DELETE /api/tokens/:id - Delete token

Public API (Access Token Authentication)

  • GET /api/public/settings - Get settings (key-value format)
    • Query params: ?environment=dev&key=database_url
  • GET /api/public/settings/all - Get all settings (full objects)
    • Query params: ?environment=dev&key=database_url
  • GET /api/public/settings/:id - Get specific setting by ID

📬 Postman Collection

We provide a comprehensive Postman collection for easy API testing and integration:

📁 Location: /postman/Confy_API_Collection.json

Features:

  • All endpoints included with example requests
  • Auto-token management - JWT and access tokens saved automatically
  • Environment variables - Configurable base URL and IDs
  • Complete workflow - From registration to API consumption
  • Detailed documentation - Step-by-step usage guide

Quick Start:

  1. Import postman/Confy_API_Collection.json into Postman
  2. Follow the requests in order: Register → Login → Create Token → Use APIs
  3. Tokens are automatically saved and used in subsequent requests

📖 Read the complete Postman guide for detailed instructions.

📁 Project Structure

confy/
├── config/          # Configurations (DB, Cache, Environment)
├── handlers/        # HTTP Handlers (Auth, Settings, Tokens)
├── middleware/      # Middlewares (Auth, Token Auth, Logger)
├── models/          # Data Models (User, Setting, Token)
├── templates/       # Frontend Templates
│   ├── css/         # Cyberpunk theme styles
│   ├── js/          # JavaScript functionality
│   ├── *.html       # HTML templates
├── postman/         # API Testing Collection
│   ├── Confy_API_Collection.json
│   └── README.md    # Postman guide
├── main.go          # Application entry point
├── Dockerfile       # Docker configuration
├── docker-compose.yml
├── CONTRIBUTING.md  # Contribution guidelines
└── README.md        # This file

⚙️ Environment Variables

Variable Description Default
MONGO_URI MongoDB connection URI mongodb://localhost:27017
DB_NAME Database name confy
JWT_SECRET JWT secret key your-secret-key
JWT_EXPIRATION_HOURS JWT token expiration time 24
CACHE_TTL_MINUTES Cache TTL in minutes 5
SERVER_PORT Server port 8080
GIN_MODE Gin mode (debug/release) debug

🚀 Cache Features

The system uses Ristretto for high-performance in-memory caching:

  • Per-user setting cache with automatic invalidation
  • Public API cache with application-specific keys
  • Configurable TTL (default: 5 minutes)
  • Pattern-based invalidation for related cache entries
  • Optimized queries to reduce database load

🔒 Security

The project implements several security practices:

  • Dual Authentication: JWT for users + Access tokens for APIs
  • Distroless Image: Final container without shell, package managers or unnecessary binaries
  • Non-root User: Application runs with nonroot user
  • Password Hashing: Bcrypt for secure password hashing
  • Input Validation: Strict validation of all input data
  • Token-based Access: Secure API access with revocable tokens
  • User Isolation: Users can only access their own settings
  • Cache Security: User-specific cache keys prevent data leakage

Contributing

We welcome contributions from the community! Please read our Contributing Guide for details on:

  • 🐛 Reporting bugs
  • 💡 Requesting features
  • 🔧 Submitting code changes
  • 📖 Improving documentation

Development Setup

# Clone the repository
git clone https://github.com/MartinezAvellan/confy.git
cd confy

# Set up development environment
make dev-setup

# Start development server
make up

🎨 UI/UX Features

The modern web interface includes:

Cyberpunk Vice City Theme

  • Color Palette: Neon blues (#00a8ff), pinks (#f4afc2), purples (#b28bc0)
  • Dark Gradient Background: Professional cyberpunk aesthetic
  • Glowing Effects: Text shadows and box shadows for depth
  • Responsive Design: Works seamlessly on desktop and mobile

OpenBMC Web UI Style Guide Compliance

  • Toast Notifications: Auto-dismiss success (10s), manual dismiss for errors
  • Consistent Typography: Sans-serif fonts throughout
  • Proper Spacing: 8px/0.5rem grid system
  • Interactive Elements: Hover effects and smooth transitions

User Experience

  • Toggle Switches: Visual enable/disable controls
  • Double-click Confirmation: Prevents accidental deletions
  • Modal Centering: Perfect positioning for all screen sizes
  • Disabled State Handling: Clear visual feedback for inactive items
  • Loading States: Smooth transitions and feedback

Support the Project

If you find Confy useful, consider supporting the development:

Star this repository - Help others discover Confy! 🐛 Report issues - Help improve the project 💡 Suggest features - Share your ideas 🔧 Contribute code - Join the development

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built with ❤️ using Go, MongoDB, and modern web technologies
  • Thanks to all contributors who help make Confy better!

About

A simple CRUD system for configuration management with authentication, built in Go with MongoDB and Ristretto cache.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors