Skip to content

one-project-one-month/multi-tenants-cms-golang

Repository files navigation

Content Management System (CMS) - Complete Repository Architecture

img.png

🌟 Repository Overview

This CMS platform implements a sophisticated microservices architecture with multiple backend services, comprehensive infrastructure management, and extensive learning components for educational content delivery.


πŸ“ Complete Project Structure

.
β”œβ”€β”€ README.md
β”œβ”€β”€ Makefile                              # Build automation and tasks
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ cms-sys/                          # Core CMS Service (Go)
β”‚   β”œβ”€β”€ gateway/                          # API Gateway Service (Spring Boot)
β”‚   └── lms-sys/                          # Learning Management System (Go)
β”œβ”€β”€ components-learning/                   # Educational Components & Examples
β”‚   β”œβ”€β”€ certificate_signing/              # Digital Certificate Generation
β”‚   β”œβ”€β”€ docker/                           # Docker Learning Examples
β”‚   β”œβ”€β”€ elastic-search/                   # Search Implementation
β”‚   β”œβ”€β”€ mfa/                              # Multi-Factor Authentication
β”‚   └── postgres/                         # Database Examples
β”œβ”€β”€ docker-compose.yml                     # Main Orchestration
β”œβ”€β”€ infra/                                # Infrastructure as Code
β”‚   β”œβ”€β”€ migration/                        # Database Migrations
β”‚   β”œβ”€β”€ github/                           # CI/CD Configuration
β”‚   β”œβ”€β”€ schema/                           # Database Schemas
β”‚   └── terraform/                        # Infrastructure Provisioning
β”œβ”€β”€ keys/                                 # Cryptographic Keys
β”œβ”€β”€ scripts/                              # Automation Scripts
└── vault-init.sh                         # Vault Initialization

CMS High level

img_2.png

API level overview

πŸ›οΈ Architecture Overview

πŸš€ Backend Services (backend/)

πŸ“¦ CMS Core System (cms-sys/)

Technology: Go 1.24 | Purpose: Primary content management functionality

cms-sys/
β”œβ”€β”€ cmd/main.go                           # Application entry point
β”œβ”€β”€ internal/                             # Core business logic
β”‚   β”œβ”€β”€ handler/                          # HTTP handlers
β”‚   β”œβ”€β”€ repository/                       # Data access layer
β”‚   β”œβ”€β”€ routes/                           # API route definitions
β”‚   β”œβ”€β”€ service/                          # Business logic layer
β”‚   └── types/                            # Data structures
β”œβ”€β”€ pkg/utils/                            # Shared utilities
β”œβ”€β”€ Makefile                              # Build and development tasks
└── test/                                 # Test suites

Key Features:

  • βœ… Authentication & authorization
  • πŸ“ Content CRUD operations
  • πŸ” JWT token management
  • πŸ’Ύ Database abstraction
  • ❀️ Health monitoring
🌐 API Gateway (gateway/)

Technology: Spring Boot (Java 17) | Purpose: Service orchestration and routing

gateway/
β”œβ”€β”€ src/main/java/com/content_management_system/gateway/
β”‚   └── GatewayApplication.java           # Spring Boot application
β”œβ”€β”€ src/main/resources/
β”‚   └── application.yml                   # Configuration
β”œβ”€β”€ Makefile                              # Java build automation
└── src/test/                             # Integration tests

Key Features:

  • πŸ”„ Request routing and load balancing
  • πŸ“Š Cross-cutting concerns (logging, monitoring)
  • πŸ“‹ API versioning and documentation
  • πŸ›‘οΈ Security policies enforcement
πŸ“š Learning Management System (lms-sys/)

Technology: Go 1.24 | Purpose: Educational content delivery

lms-sys/
β”œβ”€β”€ cmd/main.go                           # LMS application entry
β”œβ”€β”€ internal/                             # LMS-specific logic
β”‚   β”œβ”€β”€ config/                           # Configuration management
β”‚   β”œβ”€β”€ handler/                          # LMS API handlers
β”‚   β”œβ”€β”€ model/                            # Domain models
β”‚   β”œβ”€β”€ repository/                       # Data persistence
β”‚   └── service/                          # Business services
β”œβ”€β”€ pkg/utils/                            # LMS utilities
└── Makefile                              # Build and development tasks

Key Features:

  • πŸ“– Course management
  • πŸ“ˆ Student progress tracking
  • 🎯 Assessment and grading
  • ⚑ Content delivery optimization

🧩 Learning Components (components-learning/)

πŸ† Certificate Signing (certificate_signing/)

  • Digital certificate generation and validation
  • PDF certificate creation with cryptographic signatures
  • Private key management and security

🐳 Docker Orchestration (docker/)

  • Multi-service containerization examples
  • Service discovery and communication
  • Container networking and scaling

πŸ” Elasticsearch Integration (elastic-search/)

  • Full-text search implementation
  • Product catalog search optimization
  • Real-time indexing and querying

πŸ” Multi-Factor Authentication (mfa/)

  • TOTP (Time-based One-Time Password) implementation
  • Security token generation and validation
  • Authentication flow optimization

🐘 PostgreSQL Advanced Features (postgres/)

  • Schema Management: Multi-tenant architecture patterns
  • Geometric Data: PostGIS spatial data handling
  • Functions & Domains: Advanced SQL programming
  • GORM Integration: Go ORM implementation

πŸ—οΈ Infrastructure (infra/)

Component Description Technology
Database Management β€’ CMS Schema: Content management database structure
β€’ LMS Schema: Learning management database design
β€’ Migration Tools: Database version control
β€’ Diagrams: Visual database architecture
PostgreSQL, Migrations
Infrastructure as Code β€’ Cloud resource provisioning
β€’ Environment-specific configurations
β€’ Scalability and high availability setup
Terraform
CI/CD Pipeline β€’ Automated testing and deployment
β€’ Code quality enforcement
β€’ Security scanning integration
GitHub Actions

πŸ”§ Development & Operations

πŸ”¨ Build Automation (Makefile)

  • Cross-platform build commands
  • Development environment setup
  • Testing and linting automation
  • Docker image building

πŸ” Security & Cryptography (keys/)

  • RSA key pair management
  • Encryption/decryption utilities
  • Secure communication setup

βš™οΈ Automation (scripts/)

  • Deployment automation
  • Environment setup scripts
  • Maintenance and monitoring tools

πŸ‹ Service Orchestration (docker-compose.yml)

  • Multi-service local development
  • Service dependency management
  • Environment variable configuration

🎯 Design Principles & Patterns

πŸ—οΈ Microservices Architecture

  • Service Independence: Each service can be developed, deployed, and scaled independently
  • Technology Diversity: Go 1.24 for performance-critical services, Java 17 for gateway complexity
  • Data Isolation: Each service maintains its own database and data models

🧹 Clean Architecture Implementation

  • Separation of Concerns: Clear boundaries between presentation, business, and data layers
  • Dependency Inversion: Business logic independent of external frameworks
  • Testability: Comprehensive testing at unit, integration, and system levels

🏭 Infrastructure as Code

  • Reproducible Environments: Consistent deployment across development, staging, and production
  • Version Control: Infrastructure changes tracked and reviewed
  • Automation: Minimal manual intervention in deployment processes

πŸ”’ Security-First Design

  • Authentication: Multi-factor authentication and JWT token management
  • Authorization: Role-based access control across services
  • Encryption: End-to-end encryption for sensitive data
  • Certificate Management: Digital certificates for document authenticity

πŸš€ Deployment & Scalability

🏠 Local Development ☁️ Cloud Deployment
Docker Compose for rapid development cycles Terraform for cloud infrastructure
Make commands for consistent builds Auto-scaling and load balancing
Hot reloading and debugging Multi-region deployment

🀝 Contribution Guide


πŸš€ Getting Started

Follow these steps to contribute to the Multi-Tenant CMS project:

πŸ“₯ Step 1: Clone the Repository

git clone https://github.com/one-project-one-month/multi-tenants-cms-golang.git
cd multi-tenant-cms-doc-golang

🌿 Step 2: Create Feature Branch

# Create and switch to your feature branch
git checkout -b ft-CM-<according-to-your-ticket>

# Example: git checkout -b ft-CM-user-authentication

πŸ“ Branch Naming Convention: Use ft-CM-<feature-description> format based on your assigned ticket


πŸ’» Development Workflow

✏️ Step 3: Code Implementation

  • Focus: Work only on your assigned ticket/feature
  • Quality: Follow project coding standards
  • Testing: Ensure your code is properly tested

πŸ” Step 4: Check Your Changes

# Review what files have been modified
git status

# Review the actual changes
git diff

πŸ“¦ Step 5: Stage Your Changes

# Add specific file(s)
git add <fileName>

# Or add all changes (use with caution)
git add .

# Or add multiple specific files
git add file1.go file2.go

πŸ“ Step 6: Commit Your Changes

git commit -m "feat: add user authentication middleware

- Implement JWT token validation
- Add role-based access control
- Include unit tests for auth handlers"

πŸ’‘ Commit Message Format: Use conventional commits format:

  • feat: for new features
  • fix: for bug fixes
  • docs: for documentation
  • test: for adding tests
  • refactor: for code refactoring

πŸ”„ Synchronization & Push

πŸ”ƒ Step 7: Stay Up-to-Date

# Fetch latest changes from remote
git fetch origin

# Pull latest changes to avoid conflicts
git pull origin ft-CM-<according-to-your-ticket>

πŸš€ Step 8: Push Your Changes

# Push your feature branch to remote
git push origin ft-CM-<according-to-your-ticket>

# If it's your first push on this branch
git push -u origin ft-CM-<according-to-your-ticket>

πŸ“‹ Quick Reference

Command Purpose Example
git status Check working directory status See modified files
git diff Show changes in files Review code changes
git add Stage files for commit git add main.go
git commit Save changes with message git commit -m "fix: resolve auth bug"
git push Upload changes to remote git push origin ft-CM-auth

Pro Tips

# View commit history
git log --oneline

# Undo last commit (keep changes)
git reset --soft HEAD~1

# Stash current changes
git stash

# Apply stashed changes
git stash pop

# Check remote branches
git branch -r

🎯 After Push

  1. Create Pull Request: Go to GitHub and create a PR from your feature branch
  2. Code Review: Wait for team review and address feedback
  3. Merge: Once approved, your changes will be merged to main branch
  4. Cleanup: Delete your feature branch after successful merge