Skip to content

trong2409/software-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Software Template

Te├── infrastructure/ # Infrastructure services ├── databases/ # Database services │ ├── mysql/ ## 📂 Data Persi## 📝 Development Status

  • ✅ **Infrastruc## 📊 Monitoring Features

Grafana Dashboards:

  • System Overview (CPU, Memory, Disk)
  • Container Metrics
  • Application Performance (khi implement services)
  • Custom dashboards có thể thêm

Prometheus Metrics:

  • System metrics (Node Exporter)
  • Container metrics (cAdvisor)
  • Application metrics (ready for services)
  • Custom alerting rules

Loki Logging:

  • Docker container logs
  • System logs
  • Application logs (structured logging ready)
  • Log search và filtering trong Grafana

🚀 Quick Start

# Clone và setup
git clone <your-repo>
cd software-templatetack**: Hoàn thiện (MySQL, MongoDB, Redis, Kafka)
- ✅ **Monitoring & Logging**: Hoàn thiện (Grafana, Prometheus, Loki)
- ✅ **Docker Orchestration**: Centralized compose với environment variables
- ✅ **Data Persistence**: Local folder mapping
- ✅ **Web Management UIs**: Grafana, Prometheus, Mongo Express, Redis Commander, Kafka UI
- ✅ **Observability**: Metrics collection, log aggregation, alerting rules
- ⚠️ **Backend Services**: Template đã sẵn sàng, chờ implementation
- ⚠️ **Frontend Applications**: Template đã sẵn sàng, chờ implementation
- ⚠️ **Custom Dashboards**: Sẽ được thêm theo từng service
- ⚠️ **API Documentation**: Sẽ được thêm khi implement servicesất cả data được lưu trong các folder local:
- `infrastructure/databases/mysql/data/` - MySQL data
- `infrastructure/databases/mongodb/data/` - MongoDB data  
- `infrastructure/redis/data/` - Redis data
- `infrastructure/kafka/data/` - Kafka data
- `infrastructure/monitoring/data/` - Prometheus metrics data
- Docker volumes cho Grafana và Loki dataQL + data folder
    │   └── mongodb/      # MongoDB + data folder
    ├── kafka/            # Apache Kafka + data folder
    ├── redis/            # Redis cache + data folder
    ├── monitoring/       # Monitoring & Logging stack
    │   ├── grafana/      # Grafana dashboards & config
    │   ├── data/         # Prometheus data
    │   └── *.yml         # Config files
    └── docker-compose.yml # Infrastructure orchestrationcấu trúc software với kiến trúc microservices sử dụng Docker và Docker Compose. Toàn bộ stack được quản lý tập trung với một file docker-compose.yml duy nhất.

## 🏗️ Cấu trúc dự án

software-template/ ├── docker-compose.yml # Main orchestration file ├── .env # Environment configuration ├── .env.example # Environment template ├── .gitignore # Git ignore rules ├── README.md # This file ├── back-end/ # Backend services │ ├── gateway/ # API Gateway (placeholder) │ ├── service1/ # Microservice 1 (placeholder) │ ├── service2/ # Microservice 2 (placeholder) │ ├── service3/ # Microservice 3 (placeholder) │ └── docker-compose.yml # Backend services config ├── front-end/ # Frontend applications │ ├── application/ # User application (placeholder) │ ├── admin-dashboard/ # Admin dashboard (placeholder) │ └── docker-compose.yml # Frontend services config └── infrastructure/ # Infrastructure services ├── databases/ # Database services │ ├── mysql/ # MySQL + data folder │ └── mongodb/ # MongoDB + data folder ├── kafka/ # Apache Kafka + data folder ├── redis/ # Redis cache + data folder └── docker-compose.yml # Infrastructure orchestration


## 🚀 Tính năng chính

- **Microservices Architecture**: Backend được chia thành các services độc lập
- **API Gateway**: Centralized entry point cho tất cả APIs
- **Multi Frontend**: Hỗ trợ cả user app và admin dashboard
- **Container-first**: Toàn bộ services chạy trên Docker
- **Infrastructure as Code**: Database, cache, message broker được containerized

## 🛠️ Tech Stack

### Backend
- API Gateway (Kong, Nginx, hoặc custom)
- Microservices (Node.js, Python, Java, Go...)
- Message Broker: Apache Kafka + Zookeeper
- Cache: Redis

### Frontend
- User Application (React, Vue, Angular...)
- Admin Dashboard (React Admin, Angular Admin...)

### Database
- MySQL 8.0 (Primary database)
- MongoDB 7.0 (NoSQL database)

### Monitoring & Logging
- **Grafana** - Dashboards và visualization
- **Prometheus** - Metrics collection và alerting
- **Loki** - Centralized logging
- **Promtail** - Log shipping agent
- **Node Exporter** - System metrics
- **cAdvisor** - Container metrics

### DevOps
- Docker & Docker Compose
- Container orchestration ready
- Infrastructure as Code

## 🚦 Cách sử dụng

### 1. Setup Environment
```bash
# Copy environment template
cp .env.example .env

# Cập nhật các giá trị trong .env theo nhu cầu
nano .env

2. Khởi động toàn bộ stack

# Khởi động tất cả services
docker-compose up -d

# Xem logs
docker-compose logs -f

# Dừng tất cả services
docker-compose down

3. Khởi động từng phần (optional)

# Chỉ databases
docker-compose up -d mysql mongodb

# Chỉ cache và message broker
docker-compose up -d redis kafka zookeeper

# Chỉ monitoring stack
docker-compose up -d grafana prometheus loki promtail node-exporter cadvisor

# Infrastructure cơ bản (không có monitoring)
docker-compose up -d mysql mongodb redis kafka zookeeper

4. Quản lý services

# Xem trạng thái services
docker-compose ps

# Restart một service
docker-compose restart mysql

# Xem logs của service cụ thể
docker-compose logs -f mongodb

# Clean up (xóa containers, networks, volumes)
docker-compose down -v

🌐 Web Interfaces

Sau khi khởi động, các web interface sau sẽ có sẵn:

Service URL Credentials Description
Grafana http://localhost:3000 Xem trong .env Dashboards & Monitoring
Prometheus http://localhost:9090 Không cần Metrics & Alerts
Mongo Express http://localhost:8081 Xem trong .env MongoDB Admin
Redis Commander http://localhost:8082 Xem trong .env Redis Admin
Kafka UI http://localhost:8080 Không cần Kafka Management
cAdvisor http://localhost:8088 Không cần Container Metrics

� Data Persistence

Tất cả data được lưu trong các folder local:

  • infrastructure/databases/mysql/data/ - MySQL data
  • infrastructure/databases/mongodb/data/ - MongoDB data
  • infrastructure/redis/data/ - Redis data
  • infrastructure/kafka/data/ - Kafka data

�📝 Development Status

  • Infrastructure Stack: Hoàn thiện (MySQL, MongoDB, Redis, Kafka)
  • Docker Orchestration: Centralized compose với environment variables
  • Data Persistence: Local folder mapping
  • Web Management UIs: Mongo Express, Redis Commander, Kafka UI
  • ⚠️ Backend Services: Template đã sẵn sàng, chờ implementation
  • ⚠️ Frontend Applications: Template đã sẵn sàng, chờ implementation
  • ⚠️ API Documentation: Sẽ được thêm khi implement services

🔧 Development Workflow

Thêm Backend Service:

  1. Tạo folder trong back-end/service-name/
  2. Thêm Dockerfile và source code
  3. Uncomment service trong back-end/docker-compose.yml
  4. Thêm environment variables trong .env
  5. Thêm metrics endpoint /metrics cho Prometheus
  6. Configure logging để ship logs tới Loki
  7. Run: docker-compose up -d service-name

Thêm Frontend Application:

  1. Tạo folder trong front-end/app-name/
  2. Thêm Dockerfile và source code
  3. Uncomment application trong front-end/docker-compose.yml
  4. Thêm environment variables trong .env
  5. Configure logging và error tracking
  6. Run: docker-compose up -d app-name

Tạo Custom Grafana Dashboard:

  1. Truy cập Grafana: http://localhost:3000
  2. Import dashboard hoặc tạo mới
  3. Save dashboard JSON vào infrastructure/monitoring/grafana/dashboards/
  4. Dashboard sẽ auto-load khi restart Grafana

🔒 Security Notes

  • Environment Files: .env được git ignore, chỉ commit .env.example
  • Default Passwords: Thay đổi tất cả passwords trong .env cho production
  • Network: Services communicate qua Docker's default bridge network
  • Ports: Chỉ expose ports cần thiết ra host

� Quick Start

# Clone và setup
git clone <your-repo>
cd software-template

# Setup environment
cp .env.example .env
# Sửa các giá trị trong .env theo nhu cầu

# Khởi động infrastructure
docker-compose up -d

# Kiểm tra services
docker-compose ps

# Truy cập web interfaces:
# - Grafana (Monitoring): http://localhost:3000
# - Prometheus (Metrics): http://localhost:9090
# - Mongo Express: http://localhost:8081
# - Redis Commander: http://localhost:8082  
# - Kafka UI: http://localhost:8080
# - cAdvisor: http://localhost:8088

🤝 Contributing

  1. Fork repository
  2. Tạo feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push branch: git push origin feature/amazing-feature
  5. Tạo Pull Request

📄 License

Đây là template mở, có thể sử dụng và customize theo nhu cầu dự án.


Template version: v1.0 - Last updated: October 2025

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published