1. Architecture
DATA SPORT
  • DATABASE-SPORT
    • Tổng quan
    • Logic
      • Logic tổng thể
    • Projects
      • Yêu cầu hệ thống
      • Architecture
        • Database
    • Public APi
      • Tổng quan
    • Cron Make File
      • Tổng quan
  • GOLANG-THESPORT
    • Tổng quan
    • Architecture
      • System
      • Database
      • Source Code
    • Development
      • Local
      • Production
  • GOLANG-KSPORT
    • Tổng quan
    • Architecture
      • System
      • Database
      • Source Code
    • Development
      • Production
  • CRONJOB-LARAVEL
    • Tổng quan
    • Logic
      • Logic tổng thể
    • Projects
      • Yêu cầu hệ thống
      • Architecture
        • System
        • Source code
        • Database
      • Development
        • Dev
        • Production
      • Public API
        • Common API
          • League & Cup Profile (Basic)
          • Schedule & Results (Basic)
          • Match Modify Record
          • List of Countries
          • List of Bookmakers
          • Configuration instructions
        • Live animation
          • Configuration instructions
          • Schedule & Results
        • Live Data
          • Livescores for Today
          • Livescores Changes
          • Schedule & Results
          • Schedule Changes
          • Events
          • Stats
          • Corner
          • Lineups
          • Injury
          • Match List of Live Text
          • Live Text
          • Transfer
        • Profile
          • League & Cup Profile
          • Subleague Profile
          • Cup Stage Profile
          • Team Profile
          • Team Profile Copy
          • Team Profile for Search
          • Player Profile
          • Player Profile for Search
          • Referee Profile
          • Teamlist with Player Profile
        • Stats
          • Matches Analysis
          • List of Player Stats (Match)
          • Player Stats (Match)
          • List of Player Stats (League & Cup)
          • Player Stats (League & Cup)
          • League Standing (Get Subleague)
          • League Standing
          • Cup Standing
          • Top Scorer
          • FIFA Ranking
        • Odds (18 bookmakers)
          • Pre-match and In-play Odds (Main)
          • Live Odds Changes (Main)
          • Historical Odds (Main)
          • Future Odds (Main)
          • Pre-match and In-play Odds (All)
          • Live Odds Changes (All)
          • Historical Odds (All)
          • Future Odds (All)
          • European Odds (Halftime)
          • In-play Odds
          • In-play Odds (Halftime)
          • Odd Modify Record
        • European Odds (200+ Bookmakers)
          • European Odds (200+ Bookmakers)
        • Other Odds
          • Outrights
          • First/Last Team To Score (pre-match)
          • Goals Odd/Even (pre-match)
          • Goals Odd/Even (In-play)
          • Number of Goals in Match (pre-match)
          • Number of Goals in Match (In-play)
          • Half Time/Full Time (pre-match)
          • Half Time/Full Time (In-play)
          • Correct Score (pre-match)
          • Correct Score (In-play)
          • Half Time Correct Score (pre-match)
          • Half Time Correct Score (In-play)
          • Handicap Corners (pre-match)
          • Handicap Corners (In-play)
          • Total Corners (pre-match) - Tổng phạt góc trước trận đấu: First Odds
          • Total Corners (In-play) - Tổng số quả phạt góc (Trong trận) - Run Odds
          • Double Chance(pre-match)
          • EuroHandicap(pre-match)
  • GOLANG-WEBSOCKET
    • Tổng Quan
    • Logic
      • Logic tổng thể
    • Projects
      • Yêu cầu hệ thống
      • Architecture
        • System
        • Source code
      • Development
        • Dev
        • Production
      • Public API
        • API
  • ADMIN-BANNER
    • Tổng quan
    • Logic
      • Logic tổng thể
    • Projects
      • Architecture
        • System
        • Source Code
      • Development
        • Develop
        • Production
      • Public API
        • API
      • Database
        • Cấu trúc Database
      • Admin FE
        • HƯỚNG DẪN CÀI ĐẶT MÔI TRƯỜNG DỰ ÁN SPORT ADMIN
        • Hướng dẫn Đăng nhập
        • QUẢN LÝ SITE (SITE MANAGEMENT)
        • QUẢN LÝ GIẢI ĐẤU (LEAGUE MANAGEMENT)
        • QUẢN LÝ NHÀ CUNG CẤP (SUPPLIER MANAGEMENT)
        • TIP & CHUYÊN GIA - TAB QUẢN LÝ TIPS (TIPS MANAGEMENT)
        • WHITELIST
        • QUẢN LÝ MINIGAME (MINIGAME MANAGEMENT)
        • TRAFFIC REPORT
        • TOOLS - RAPID DATA
        • TOOLS - LIVE SITES
        • TOOLS - SUPPLIERS
        • THEME / PLUGIN
        • NGƯỜI DÙNG - PHÂN QUYỀN VÀ HIỂN THỊ (PERMISSION & DISPLAY MANAGEMENT)
        • QUẢN LÝ NGƯỜI DÙNG (USER MANAGEMENT)
        • NGƯỜI DÙNG - QUẢN LÝ NHÓM QUYỀN (ROLE GROUP MANAGEMENT)
  1. Architecture

Source Code

Cấu trúc dự án#

├── cmd/                        # Các điểm chạy (Entry points) của ứng dụng
│   ├── searchsync/            # Script đồng bộ dữ liệu vào Elasticsearch
│   └── worker/                # Script khởi chạy Worker xử lý background jobs
├── commons/                    # Các thành phần dùng chung (Shared layer)
│   ├── appError.go            # Chuẩn hóa xử lý lỗi toàn hệ thống
│   ├── appSuccess.go          # Chuẩn hóa phản hồi (Response) thành công
│   ├── errors/                # Định nghĩa các mã lỗi tùy chỉnh theo module
│   ├── models/                # Các struct model dùng chung
│   ├── pagination.go          # Logic phân trang cho API
│   ├── queryBuilder.go        # Bộ xây dựng câu lệnh truy vấn linh hoạt
│   └── uows/                  # Pattern Unit of Work quản lý transaction
├── config/                     # Quản lý cấu hình (Configuration)
│   ├── config.go              # Load biến môi trường, cấu hình Viper
│   ├── database.go            # Khởi tạo kết nối MySQL (Read/Write)
│   └── redis.go               # Cấu hình Redis và Asynq
├── db/                         # Lớp dữ liệu (Database layer)
│   ├── migrations/            # Các file schema SQL quản lý version DB
│   ├── models/                # Định nghĩa bảng (SQL schema) cho SQLC
│   ├── queries/               # Các câu lệnh SQL dùng để generate code Go
│   └── *.sql.go               # Code Go được SQLC tự động tạo ra
├── internal/                   # Logic xử lý nội bộ (Core backend logic)
│   ├── cron/                  # Đăng ký và quản lý tất cả các lịch chạy Cron
│   └── worker/                # Cấu hình và chạy Asynq worker server
├── modules/                    # Các module tính năng (Feature-based - Clean Arch)
│   ├── [feature_name]/        # Ví dụ: team, player, schedule...
│   │   ├── domain.go         # Chứa các Model và Interface của module
│   │   ├── handler.go        # Xử lý HTTP Request/Response (Fiber)
│   │   ├── usecase.go        # Xử lý logic nghiệp vụ (Business logic)
│   │   ├── routes.go         # Khai báo các endpoint API của module
│   │   └── rapidsync/        # Logic đồng bộ riêng từ RapidAPI cho module đó
├── pkg/                        # Các gói thư viện bao gói (Wrappers)
│   ├── cloudinary/            # Tích hợp lưu trữ ảnh Cloudinary
│   ├── elasticsearch/         # Wrapper truy vấn Elasticsearch
│   ├── redis/                 # Wrapper quản lý Redis client
│   └── external/rapidapi/     # Client gọi API hệ thống RapidAPI
├── server/                     # Khởi tạo và vận hành Server
│   ├── index.go               # Cấu hình Fiber app, Graceful shutdown
│   └── router.go              # Đăng ký Route và Middleware toàn hệ thống
├── utils/                      # Các hàm tiện ích bổ trợ (Helpers)
│   ├── convertTime.go         # Xử lý chuyển đổi định dạng thời gian
│   ├── validate.go            # Logic validation dữ liệu đầu vào
│   └── random.go              # Tạo chuỗi hoặc số ngẫu nhiên
├── main.go                     # File chạy chính của toàn bộ hệ thống
└── sqlc.yaml                   # File cấu hình của SQLC tool

Environment Variables (.env)#

1. Server & Logging#

PORT=8080
ENV=production

LOG_LEVEL=info
LOG_FILE=logs/app.log

2. Database Pool & Storage#

DB_POOL_MAX_OPEN=80
DB_POOL_MAX_IDLE=20


REDIS_HOST=74.82.63.183
REDIS_PORT=21002
REDIS_PASSWORD=
REDIS_DB=0

#REDIS_HOST_SPORT_READ=redis-14740.c10.us-east-1-4.ec2.cloud.redislabs.com
#REDIS_PORT_SPORT_READ=14740
#REDIS_PASSWORD_SPORT_READ=
#REDIS_DB_SPORT_READ=0

REDIS_HOST_SPORT_READ=74.82.63.183
REDIS_PORT_SPORT_READ=21002
REDIS_PASSWORD_SPORT_READ=
REDIS_DB_SPORT_READ=1

REDIS_PREFIX_RAPID_SYNC=api_soccer_database_api_soccer_cache_:


REDIS_HOST_ELASTIC_SEARCH_READ=74.82.63.183
REDIS_PORT_ELASTIC_SEARCH_READ=21002
REDIS_PASSWORD_ELASTIC_SEARCH_READ=
REDIS_DB_ELASTIC_SEARCH_READ=0

3. External APIs#

API_ISPORT=http://api.demo.com/
KEY_API_ISPORT=***

RAPID_API=https://data.rapid-api.icu/v1
RAPID_KEY=***

RAPID_API_ENDPOINT_TEAMS=/football/team/additional/list
RAPID_API_ENDPOINT_ODDS=/football/odds/live

ENDPOINT_SCHEDULE_RESULTS=path_demo

4. S3 & CDN#

AWS_ENDPOINT_URL=https://img.nospace.network
AWS_DEFAULT_REGION=auto

AWS_ACCESS_KEY_ID=***
AWS_SECRET_ACCESS_KEY=***

AWS_ENDPOINT=https://35666.oss.swiftserve.com

AWS_BUCKET_DATA=cdn-dien-sport
AWS_BUCKET=cdn-sport

DISK=s3
S3_TYPE=total

5. Cron Control (Bật/Tắt)#

ENABLE_CRON_HEAD_TO_HEAD=ON
ENABLE_CRON_MATCH_ANALYSIS=ON

ENABEL_CRON_RAPID_TEAMS=OFF
ENABEL_CRON_RAPID_DETAIL_LIVE=ON
ENABEL_CRON_RAPID_SCHEDULE_CHANGES=ON
ENABEL_CRON_RAPID_TEAM_STATS=ON
ENABEL_CRON_RAPID_ODDS=ON
ENABEL_CRON_RAPID_PLAYER_STATS=ON
ENABEL_CRON_RAPID_REFEREE=ON
ENABEL_CRON_RAPID_ODDS_DETAIL=ON

6. AI / External Service (Optional)#

GROK_API_KEY=***
GROK_API_ENDPOINT=
Modified at 2026-03-26 10:16:04
Previous
Database
Next
Local
Built with