Skip to content

Empowering enterprise applications with modern technology and security

Notifications You must be signed in to change notification settings

ak9024/studio45-old

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Studio45

A modern, full-stack application built with Go and React, featuring comprehensive role-based access control (RBAC), user management, and email template systems. Studio45 provides a secure, scalable platform for building enterprise-grade applications with advanced authentication and authorization capabilities.

Table of Contents

Features

Backend Features

  • Authentication & Authorization: JWT-based authentication with comprehensive RBAC
  • User Management: Complete user lifecycle with profile management and admin controls
  • Role-Based Access Control: Normalized RBAC system with granular permissions
  • Email Template Management: Database-driven customizable email templates with preview and testing
  • Password Reset: Secure email-based password recovery with configurable templates
  • Database Migrations: Version-controlled schema management with rollback support
  • Security: Input validation, SQL injection prevention, and rate limiting

Frontend Features

  • Modern React: React 19 with TypeScript and modern development practices
  • Beautiful UI: shadcn/ui components with Tailwind CSS styling
  • Responsive Design: Mobile-first design that works on all devices
  • Protected Routes: Role-based route protection with authentication guards
  • Admin Dashboard: Full-featured admin interface with data visualization
  • Theme Support: Dark/light theme with system preference detection

System Features

  • Monorepo Architecture: Organized codebase with clear separation of concerns
  • Docker Support: Containerized deployment with Docker Compose
  • Performance: Optimized builds with Vite and efficient database queries
  • Type Safety: Full TypeScript coverage with strict mode enabled

Architecture Overview

Studio45 follows a modern, layered architecture pattern with clear separation between frontend, backend, and data layers:

graph TB
    subgraph "Client Layer"
        BROWSER[Web Browser]
        MOBILE[Mobile Browser]
    end
    
    subgraph "Frontend Layer"
        WEB[React Web App<br/>TypeScript + Vite]
        UI[UI Components<br/>shadcn/ui + Tailwind]
        AUTH_CTX[Auth Context<br/>JWT Management]
    end
    
    subgraph "Backend Layer"
        API[Go API Server<br/>Fiber Framework]
        MIDDLEWARE[Middleware Stack<br/>Auth + RBAC + CORS]
        SERVICES[Business Services<br/>Auth + RBAC + Email]
    end
    
    subgraph "Infrastructure Layer"
        TRAEFIK[Traefik Proxy<br/>Load Balancer + HTTPS]
    end
    
    subgraph "Data Layer"
        DB[(PostgreSQL<br/>Primary Database)]
        CACHE[(Redis<br/>Cache Layer)]
    end
    
    subgraph "External Services"
        SMTP[SMTP Server<br/>Email Delivery]
        ACME[Let's Encrypt<br/>SSL Certificates]
    end
    
    %% Connections
    BROWSER --> TRAEFIK
    MOBILE --> TRAEFIK
    TRAEFIK --> WEB
    WEB --> UI
    WEB --> AUTH_CTX
    
    TRAEFIK --> API
    API --> MIDDLEWARE
    MIDDLEWARE --> SERVICES
    
    SERVICES --> DB
    SERVICES --> CACHE
    SERVICES --> SMTP
    TRAEFIK --> ACME
    
    %% Styling
    classDef client fill:#e3f2fd
    classDef frontend fill:#f3e5f5
    classDef backend fill:#e8f5e8
    classDef infrastructure fill:#f1f8e9
    classDef data fill:#fff3e0
    classDef external fill:#ffebee
    
    class BROWSER,MOBILE client
    class WEB,UI,AUTH_CTX frontend
    class API,MIDDLEWARE,SERVICES backend
    class TRAEFIK infrastructure
    class DB,CACHE data
    class SMTP,ACME external
Loading

Database Overview

database

Frontend Overview

Studio45 features a modern, responsive React-based administrative interface built with TypeScript and shadcn/ui components. The frontend provides comprehensive management capabilities for users, roles, permissions, and system configuration through an intuitive dashboard.

Admin Settings - Roles Management

Roles Management

The Roles Management interface allows administrators to create and manage user roles with granular permission control. Features include:

  • View all system roles with permission counts
  • Create new roles with custom permissions
  • Edit existing role configurations
  • Real-time permission assignment and management

Email Templates Management

Email Templates

The Email Templates system provides a powerful interface for managing dynamic email communications:

  • Template creation and customization with Go template syntax
  • Variable substitution support for personalized content
  • Template preview and testing capabilities
  • Conditional content rendering based on user data

Users Management

Users Management

Comprehensive user administration interface offering:

  • Complete user listing with search and filtering
  • User profile management with contact information
  • Role assignment and permission management
  • Account status monitoring and control

User Profile Interface

User Profile

Individual user profile pages provide detailed account information:

  • Personal information display and editing
  • Role and permission visualization
  • Account activity tracking
  • Membership and update history

Analytics Dashboard

Dashboard

The main dashboard offers business intelligence and system insights:

Technology Stack

Frontend:

  • React 19 with TypeScript
  • Vite for build tooling
  • shadcn/ui + Tailwind CSS
  • React Hook Form + Zod validation

Backend:

  • Go 1.24 with Fiber framework
  • GORM for database operations
  • JWT for authentication
  • Go Migrate for schema management

Database:

  • PostgreSQL (primary database)
  • Redis (caching layer)

Infrastructure:

  • Docker & Docker Compose
  • Traefik reverse proxy
  • Let's Encrypt SSL certificates

Development:

  • ESLint + TypeScript compiler
  • Git for version control

Quick Start

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/ak9024/studio45.git
    cd studio45
  2. Start the backend:

    cd apps/api
    cp .env.example .env
    # Edit .env with your database configuration
    go mod download
    go run main.go migrate up # automatic create database include tables
    go run main.go
  3. Start the frontend:

    cd apps/web
    cp .env.example .env
    # Edit .env with your API configuration
    npm install
    npm run dev
  4. Access the application:

Docker Development Setup

For local development with Docker:

# Start all services (API, Web, PostgreSQL)
docker-compose -f docker-compose.local.yaml up -d

# Check service status
docker-compose -f docker-compose.local.yaml ps

# View logs
docker-compose -f docker-compose.local.yaml logs -f

Access your application:

Service Management:

# Stop all services
docker-compose -f docker-compose.local.yaml down

# Rebuild after code changes
docker-compose -f docker-compose.local.yaml up --build

Docker Production Deployment

For production deployment with automatic HTTPS and reverse proxy:

1. Configure your domain and email:

# Edit docker-compose.yaml and update:
# - Line 38: your-email@gmail.com (Let's Encrypt notifications)
# - Line 61: CORS_ALLOWED_ORIGINS=https://yourdomain.com
# - Line 76: FRONTEND_URL=https://yourdomain.com
# - Line 121: traefik.http.routers.web.rule=Host(`yourdomain.com`)

2. Set up email configuration (optional):

# Update SMTP settings in docker-compose.yaml (lines 78-84)
# Or set EMAIL_PROVIDER=local for development

3. Deploy the stack:

# Start production services with Traefik reverse proxy
docker-compose up -d

# Monitor deployment
docker-compose logs -f

# Check service health
docker-compose ps

Production Services:

  • Traefik: Reverse proxy with automatic HTTPS (Let's Encrypt)
  • API: Go backend with database migrations
  • Web: React frontend served by nginx
  • PostgreSQL: Database with persistent storage

SSL Certificates: Traefik automatically obtains and renews SSL certificates from Let's Encrypt. Certificates are stored in ./letsencrypt/ directory.

Documentation

Detailed Documentation

Specialized Guides

API Endpoints

Public Endpoints

  • GET /health - Health check endpoint

Authentication Endpoints

  • POST /api/v1/auth/register - User registration
  • POST /api/v1/auth/login - User authentication
  • POST /api/v1/auth/forgot-password - Request password reset
  • POST /api/v1/auth/reset-password - Reset user password

Protected User Endpoints (Requires Authentication)

  • GET /api/v1/protected/profile - Get current user profile
  • PUT /api/v1/protected/profile - Update current user profile

Admin - User Management (Requires Admin Role)

  • GET /api/v1/admin/users - List all users
  • POST /api/v1/admin/users - Create new user
  • PUT /api/v1/admin/users/:id - Update specific user
  • PUT /api/v1/admin/users/:id/roles - Update user roles
  • DELETE /api/v1/admin/users/:id - Delete user

Admin - Role Management (Requires Admin Role)

  • GET /api/v1/admin/roles - List all roles
  • POST /api/v1/admin/roles - Create new role
  • GET /api/v1/admin/roles/:id - Get specific role
  • PUT /api/v1/admin/roles/:id - Update specific role
  • DELETE /api/v1/admin/roles/:id - Delete role
  • GET /api/v1/admin/roles/:id/permissions - Get role permissions
  • PUT /api/v1/admin/roles/:id/permissions - Update role permissions

Admin - Permission Management (Requires Admin Role)

  • GET /api/v1/admin/permissions - List all permissions
  • POST /api/v1/admin/permissions - Create new permission
  • GET /api/v1/admin/permissions/:id - Get specific permission
  • PUT /api/v1/admin/permissions/:id - Update specific permission
  • DELETE /api/v1/admin/permissions/:id - Delete permission

Admin - RBAC Queries (Requires Admin Role)

  • GET /api/v1/admin/users/:id/permissions - Get user permissions
  • GET /api/v1/admin/users/:id/permissions/:permission - Check user permission

Admin - User Promotion (Requires Admin Role)

Studio45 provides multiple methods to promote users to different roles:

CLI Promotion (Direct Database)

  • go run main.go promote [email] - Promote user from 'user' to 'admin' role via CLI

CLI Usage Examples:

Promote user to admin (direct database access):

# Navigate to API directory
cd apps/api

# Promote user by email
go run main.go promote user@example.com

Security Considerations:

  • API promotion requires admin authentication token
  • CLI promotion requires direct server access and database connection
  • All promotions are logged with audit trail (timestamp, granted_by)
  • Users cannot promote themselves via API
  • CLI promotion only works for user → admin promotion

Admin - Email Template Management (Requires Admin Role)

  • GET /api/v1/admin/email-templates - List all email templates
  • POST /api/v1/admin/email-templates - Create new email template
  • GET /api/v1/admin/email-templates/:id - Get specific template
  • PUT /api/v1/admin/email-templates/:id - Update email template
  • DELETE /api/v1/admin/email-templates/:id - Delete email template
  • GET /api/v1/admin/email-templates/:id/variables - Get template variables
  • POST /api/v1/admin/email-templates/:id/preview - Preview email template
  • POST /api/v1/admin/email-templates/:id/test - Send test email

Support

Getting Help

  1. Documentation: Check the comprehensive docs in each app directory
  2. Issues: Report bugs or request features in GitHub Issues
  3. Discussions: Join discussions in GitHub Discussions

Common Issues

  • Database Connection: Verify PostgreSQL is running and DB_DSN is correct
  • Frontend Build: Clear node_modules and reinstall dependencies
  • Authentication: Verify JWT_SECRET is set consistently

Built with ❤️ by @ak9024

Studio45 - Empowering enterprise applications with modern technology and security

About

Empowering enterprise applications with modern technology and security

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published