Skip to content

project UKK, am i cooked? i don't care about your comment whether if this project is over engineered because there's a microservice.

Notifications You must be signed in to change notification settings

fauzymadani/E-Learn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

E-Learning Platform

Platform pembelajaran online berbasis web yang dibangun dengan arsitektur microservices menggunakan Go, gRPC, dan React.

Daftar Isi

Tentang Proyek

E-Learning Platform adalah sistem manajemen pembelajaran yang dirancang untuk memfasilitasi interaksi antara guru dan siswa dalam lingkungan digital. Platform ini mendukung berbagai role pengguna (Admin, Guru, Siswa) dengan fitur-fitur lengkap untuk pengelolaan kursus, materi pembelajaran, progress tracking, dan sistem notifikasi real-time.

Proyek ini dikembangkan sebagai bagian dari Uji Kompetensi Keahlian (UKK) jurusan Rekayasa Perangkat Lunak.

Tech Stack

Backend

Teknologi Deskripsi
Go Bahasa pemrograman utama backend
Gin HTTP web framework
gRPC Remote procedure call framework
Protocol Buffers Serialisasi data
PostgreSQL Database relational
JWT Authentication & Authorization
Zap Structured logging
Lumberjack Log rotation

Frontend

Teknologi Deskripsi
React Library JavaScript untuk UI
TypeScript Superset JavaScript dengan typing
Vite Build tool & dev server
shadcn/ui Component library
TailwindCSS Utility-first CSS framework
React Router Client-side routing
Axios HTTP client

DevOps & Tools

Teknologi Deskripsi
Docker Containerization
Podman Container engine (alternatif Docker)
Docker Compose Multi-container orchestration
Prometheus Monitoring and metrics collection
Grafana Visualization and dashboarding for metrics
Git Version control

It works on my machine

versi tools yang saya pake:

  • go version go1.25.4 X:nodwarf5 linux/amd64
  • Bun 1.3.3
  • podman-compose version 1.5.0
  • podman version 5.7.0
  • postgres (PostgreSQL) 18.1
  • Linux 6.17.9-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 24 Nov 2025 15:21:09 +0000 x86_64 GNU/Linux

Fitur Utama

Role Admin

  • Manajemen pengguna (CRUD guru dan siswa)
  • Manajemen kursus (approval, monitoring)
  • Sistem notifikasi broadcast
  • Dashboard analytics dan reporting
  • Monitoring aktivitas sistem

Role Guru

  • Membuat dan mengelola kursus
  • Upload materi pembelajaran (PDF, video)
  • Manajemen lesson dan chapter
  • Monitoring progress siswa
  • Memberikan feedback dan penilaian

Role Siswa

  • Browse dan enroll kursus
  • Akses materi pembelajaran
  • Progress tracking otomatis
  • Dashboard personal
  • Notifikasi real-time

Fitur Umum

  • Authentication & Authorization dengan JWT
  • Upload file dengan validasi (PDF, video)
  • Dark mode / Light mode
  • Responsive design
  • Real-time notification via gRPC
  • Log rotation dan monitoring
  • RESTful API

Kenapa Menggunakan Go?

singkatnya: pengen nyoba aja sih. lengkapnya: Go (Golang) dipilih sebagai bahasa pemrograman backend karena mendukung paradigma Object-Oriented Programming (OOP) dengan pendekatan yang unik dan modern. Meskipun Go tidak memiliki class seperti Java atau C++, Go tetap mendukung prinsip-prinsip OOP melalui:

Implementasi OOP di Go

1. Encapsulation (Enkapsulasi)

Go menggunakan struct dan visibility rules (exported/unexported) untuk enkapsulasi data:

type User struct {
    ID       uint
    name     string  // private (unexported)
    Password string  // public (exported)
}

2. Composition over Inheritance

Go tidak mendukung inheritance, namun menggunakan composition yang lebih fleksibel:

type Repository struct {
    db *gorm.DB
}

type UserRepository struct {
    Repository  // embedded struct (composition)
}

3. Polymorphism melalui Interface

Go menggunakan interface untuk mencapai polymorphism tanpa coupling yang ketat:

type CourseService interface {
    Create(course *Course) error
    GetByID(id uint) (*Course, error)
}

type courseServiceImpl struct {
    repo CourseRepository
}

func (s *courseServiceImpl) Create(course *Course) error {
    // implementation
}

4. Methods pada Struct

Go mendukung method yang di-attach pada struct, mirip dengan class methods:

func (u *User) ValidatePassword(password string) bool {
    return bcrypt.CompareHashAndPassword(u.Password, password) == nil
}

Keunggulan Pendekatan OOP Go

Simplicity: Tidak ada inheritance kompleks, lebih mudah dipahami Composition: Lebih fleksibel daripada inheritance hierarchy Interface Satisfaction: Duck typing membuat code lebih loosely coupled No Constructor Overhead: Initialization lebih eksplisit dan jelas Better Performance: Tanpa virtual method table overhead

Penerapan dalam Proyek

Dalam proyek E-Learning Platform ini, prinsip OOP diterapkan melalui:

  1. Domain Layer: Struct sebagai representasi entity
  2. Repository Pattern: Interface untuk abstraksi database operations
  3. Service Layer: Business logic dengan dependency injection
  4. Handler Layer: Request/response handling dengan method receivers
  5. Middleware: Composition untuk chain of responsibility pattern

Arsitektur ini mengikuti Clean Architecture dan SOLID Principles, membuktikan bahwa Go dapat digunakan untuk membangun aplikasi enterprise-grade dengan prinsip OOP yang baik.

Arsitektur Sistem

┌─────────────────┐
│   React SPA     │
│   (Frontend)    │
└────────┬────────┘
         │ HTTP/REST
         ▼
┌─────────────────┐
│   Gin Router    │
│   (API Gateway) │
└────────┬────────┘
         │
    ┌────┴──────┐
    │           │
    ▼           ▼
┌────────┐  ┌──────────────┐
│  Main  │  │ Notification │
│Service │◄─┤  Service     │
│        │  │   (gRPC)     │
└───┬────┘  └──────────────┘
    │
    ▼
┌─────────────┐
│ PostgreSQL  │
└─────────────┘

Diagram

Class diagram

Class Diagram

Use Case Diagram

---
config:
  theme: neo
  themeVariables:
    primaryColor: '#e3f2fd'
    primaryTextColor: '#1976d2'
    primaryBorderColor: '#1976d2'
    lineColor: '#666'
    secondaryColor: '#f5f5f5'
    tertiaryColor: '#fff'
  look: handDrawn
  layout: elk
---
flowchart TB
    subgraph Auth["Authentication"]
        Login["Login"]
        Register["Register"]
        Logout["Logout"]
    end
    subgraph StudentF["Student Features"]
        Browse["Browse Courses"]
        ViewDetail["View Course Detail"]
        Enroll["Enroll in Course"]
        Learn["Learn Lessons"]
        Track["Track Progress"]
        MarkDone["Mark Lesson Complete"]
        StudentDash["Student Dashboard"]
    end
    subgraph TeacherF["Teacher Features"]
        CreateCourse["Create Course"]
        EditCourse["Edit Course"]
        DeleteCourse["Delete Course"]
        Publish["Publish/Unpublish"]
        ManageLessons["Manage Lessons"]
        ViewStudents["View Students"]
        TeacherDash["Teacher Dashboard"]
    end
    subgraph AdminF["Admin Features"]
        ManageUsers["Manage Users"]
        ManageCourses["Manage All Courses"]
        ViewReports["View Reports"]
        SendNotif["Send Notifications"]
        AdminDash["Admin Dashboard"]
    end
    subgraph Common["Common Features"]
        ViewProfile["View Profile"]
        EditProfile["Edit Profile"]
        ChangePass["Change Password"]
        ViewNotif["View Notifications"]
    end
    subgraph System["E-Learning Platform"]
        direction TB
        Auth
        StudentF
        TeacherF
        AdminF
        Common
    end
    Guest(["Guest"]) --> Browse & ViewDetail & Register & Login
    Student(["Student"]) --> Login & Browse & ViewDetail & Enroll & Learn & Track & MarkDone & StudentDash & ViewProfile & EditProfile & ChangePass & ViewNotif & Logout
    Teacher(["Teacher"]) --> Login & CreateCourse & EditCourse & DeleteCourse & Publish & ManageLessons & ViewStudents & TeacherDash & ViewProfile & EditProfile & ChangePass & ViewNotif & Logout
    Admin(["Admin"]) --> Login & ManageUsers & ManageCourses & ViewReports & SendNotif & AdminDash & ViewProfile & EditProfile & ChangePass & ViewNotif & Logout
    Enroll -. requires .-> Login
    Learn -. requires .-> Login
    CreateCourse -. requires .-> Login
    ManageUsers -. requires .-> Login
    Auth --> n1["Untitled Node"]

    Guest:::actorStyle
    Student:::actorStyle
    Teacher:::actorStyle
    Admin:::actorStyle
    classDef actorStyle fill:#e3f2fd,stroke:#1976d2,stroke-width:3px,color:#1976d2
    classDef usecaseStyle fill:#fff,stroke:#666,stroke-width:2px
    classDef systemStyle fill:#f5f5f5,stroke:#999,stroke-width:2px
Loading

Arsitektur Microservices

Main Service (Port 8080)

  • Handler: Auth, User, Course, Lesson, Enrollment, Progress, Dashboard
  • Middleware: Authentication, Logger, Ownership
  • Repository Pattern dengan domain-driven design

Notification Service (Port 50051)

  • gRPC server untuk notifikasi real-time
  • Independent database connection
  • Protocol Buffers untuk contract definition

Skema Database

ERD

Entity Relationship Diagram (ERD)

erDiagram
    users ||--o{ categories : creates
    users ||--o{ courses : teaches
    users ||--o{ enrollments : enrolls
    users ||--o{ student_progress : tracks
    users ||--o{ notifications : receives
    users ||--o{ progress : completes
    
    categories ||--o{ courses : contains
    
    courses ||--o{ lessons : has
    courses ||--o{ enrollments : "enrolled in"
    courses ||--o{ student_progress : tracks
    courses ||--|{ course_details : "detailed by"
    
    lessons ||--o{ progress : "completed in"
    
    users {
        integer id PK
        varchar name
        varchar email
        varchar password
        user_role role
        varchar avatar
        timestamp created_at
        timestamp updated_at
    }
    
    categories {
        integer id PK
        varchar name
        text description
        timestamp created_at
    }
    
    courses {
        integer id PK
        varchar title
        text description
        varchar thumbnail
        integer category_id FK
        integer teacher_id FK
        boolean is_published
        timestamp created_at
        timestamp updated_at
    }
    
    lessons {
        integer id PK
        integer course_id FK
        varchar title
        text content
        varchar video_url
        varchar file_url
        integer order_number
        integer duration
        timestamp created_at
        timestamp updated_at
    }
    
    course_details {
        integer id PK
        varchar title
        text description
        varchar thumbnail
        boolean is_published
        varchar category_name
        varchar teacher_name
        varchar teacher_email
        bigint total_lessons
        bigint total_students
        timestamp created_at
        timestamp updated_at
    }
    
    enrollments {
        integer id PK
        integer user_id FK
        integer course_id FK
        timestamp enrolled_at
        enrollment_status status
        timestamp completed_at
    }
    
    student_progress {
        integer user_id FK
        integer course_id FK
        varchar course_title
        bigint total_lessons
        bigint completed_lessons
        numeric progress_percentage
        timestamp enrolled_at
        enrollment_status status
    }
    
    progress {
        integer id PK
        integer user_id FK
        integer lesson_id FK
        boolean is_completed
        timestamp completed_at
    }
    
    notifications {
        integer id PK
        integer user_id FK
        varchar title
        text message
        notification_type type
        boolean is_read
        timestamp created_at
    }
Loading

Tabel Utama

users

  • Menyimpan data pengguna (admin, guru, siswa)
  • Relasi: courses (1:N), enrollments (1:N)

courses

  • Menyimpan data kursus
  • Relasi: users (N:1), lessons (1:N), enrollments (1:N)

lessons

  • Menyimpan materi pembelajaran
  • Relasi: courses (N:1), progress (1:N)

enrollments

  • Menyimpan data pendaftaran siswa ke kursus
  • Relasi: users (N:1), courses (N:1)

progress

  • Tracking progress pembelajaran siswa
  • Relasi: users (N:1), lessons (N:1)

notifications

  • Menyimpan notifikasi sistem
  • Relasi: users (N:1)

Prerequisites

Pastikan sistem Anda telah terinstall:

  • Go
  • Node.js dan Bun (atau npm/yarn)
  • PostgreSQL
  • Podman atau Docker dan Docker Compose
  • Protocol Buffer Compiler (protoc)
  • Git

Instalasi Prerequisites

Linux (Arch-based)

# Install Go
sudo pacman -S go

# Install Node.js dan Bun
sudo pacman -S nodejs npm
curl -fsSL https://bun.sh/install | bash

# Install PostgreSQL
sudo pacman -S postgresql
sudo systemctl enable postgresql
sudo systemctl start postgresql

# Install Podman
sudo pacman -S podman podman-compose

# Install protoc
sudo pacman -S protobuf

Linux (Debian/Ubuntu)

# Install Go
wget https://go.dev/dl/go1.21.0.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc

# Install Bun
curl -fsSL https://bun.sh/install | bash

# Install PostgreSQL
sudo apt update
sudo apt install postgresql postgresql-contrib

# Install Podman
sudo apt install podman podman-compose

Instalasi

1. Clone Repository

git clone --recurse-submodules https://github.com/fauzymadani/E-Learning.git
cd E-Learning

2. Setup Database

untuk guide lebih lengkap, pertimbangakn mengunjungi dokumentasi PostgreSQL resmi. atau https://wiki.archlinux.org/title/PostgreSQL

# Login ke PostgreSQL
sudo -u postgres psql

# Buat database dan user
CREATE DATABASE elearning_db;
CREATE USER elearning_user WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE elearning_db TO elearning_user;
\q

# Import schema database
psql -U elearning_user -d elearning_db -f elearning.sql

3. Setup Backend

# Install dependencies
go mod download

# Setup notification service
cd microservices/notification-service
go mod download
cd ../..

# Generate protobuf (jika ada perubahan)
cd proto
protoc --go_out=. --go-grpc_out=. notification.proto
cd ..

4. Setup Frontend

cd frontend

# Install dependencies dengan Bun
bun install

# Atau dengan npm
# npm install

cd ..

Konfigurasi

Backend Configuration

Buat file config.yaml atau setup environment variables:

cp .env.example .env

Notification Service Configuration

Buat file config.yaml di microservices/notification-service/:

cp .env.example .env

Menjalankan Aplikasi

Menggunakan Podman/Docker Compose

# Build dan jalankan semua service
podman-compose up -d

# Atau dengan docker-compose
docker-compose up -d

# Lihat logs
podman-compose logs -f

# Stop semua service
podman-compose down

Penggunaan Makefile

# Overview perintah Makefile:
Usage: make [target]

Targets:
  help     Show this help
  build    Build binary into ./bin
  run      Build and run
  test     Run unit tests
  fmt      gofmt (via go fmt)
  vet      go vet
  lint     run golangci-lint (must be installed)
  deps     download modules
  clean    remove build artifacts
  
# Build dan jalankan aplikasi
make build
make run
make test # TODO: implementasi test unit

3. Jalankan Frontend

# Di terminal baru
cd frontend
bun run dev

Aplikasi akan berjalan di:

Struktur Proyek

.
├── cmd/
│   └── api/
│       └── main.go              # Entry point aplikasi
├── internal/
│   ├── config/                  # Konfigurasi aplikasi
│   ├── domain/                  # Domain models & entities
│   ├── handler/                 # HTTP handlers (controllers)
│   ├── middleware/              # Custom middlewares
│   ├── repository/              # Database access layer
│   ├── router/                  # Route definitions
│   └── service/                 # Business logic layer
├── pkg/
│   ├── grpcclient/             # gRPC client utilities
│   ├── hash/                    # Password hashing
│   ├── logger/                  # Logging utilities
│   ├── storage/                 # File storage (GCS/local)
│   └── token/                   # JWT utilities
├── proto/                       # Protocol buffer definitions
├── microservices/
│   └── notification-service/    # Microservice notifikasi
│       ├── cmd/server/
│       ├── internal/
│       └── proto/
├── frontend/                    # React application
│   ├── src/
│   │   ├── api/                # API client
│   │   ├── components/         # React components
│   │   ├── context/            # React context
│   │   ├── dashboard/          # Dashboard components
│   │   ├── hooks/              # Custom hooks
│   │   ├── pages/              # Page components
│   │   └── router/             # Route configuration
│   └── public/
├── uploads/                     # Upload directory
│   ├── avatars/
│   ├── files/
│   └── videos/
├── logs/                        # Application logs
├── docker-compose.yml
├── Dockerfile
├── elearning.sql               # Database schema
└── README.md

API Documentation

Authentication Endpoints

POST   /api/auth/login          # Login user
POST   /api/auth/register       # Register user baru
POST   /api/auth/logout         # Logout user
GET    /api/auth/me             # Get user profile

User Management Endpoints

GET    /api/users               # List semua users (Admin only)
GET    /api/users/:id           # Get user by ID
PUT    /api/users/:id           # Update user
DELETE /api/users/:id           # Delete user (Admin only)
POST   /api/users               # Create user (Admin only)

Course Endpoints

GET    /api/courses             # List semua courses
GET    /api/courses/:id         # Get course detail
POST   /api/courses             # Create course (Teacher/Admin)
PUT    /api/courses/:id         # Update course (Owner)
DELETE /api/courses/:id         # Delete course (Owner)
GET    /api/courses/my          # Get my courses

Lesson Endpoints

GET    /api/lessons             # List lessons by course
GET    /api/lessons/:id         # Get lesson detail
POST   /api/lessons             # Create lesson
PUT    /api/lessons/:id         # Update lesson
DELETE /api/lessons/:id         # Delete lesson
POST   /api/lessons/:id/upload  # Upload lesson material

Enrollment Endpoints

POST   /api/enrollments         # Enroll ke course
GET    /api/enrollments         # Get my enrollments
DELETE /api/enrollments/:id     # Unenroll dari course

Progress Endpoints

GET    /api/progress            # Get my progress
POST   /api/progress            # Update progress
GET    /api/progress/course/:id # Get course progress

Dashboard Endpoints

GET    /api/dashboard/stats     # Get dashboard statistics
GET    /api/dashboard/recent    # Get recent activities

Notification Endpoints

GET    /api/notifications       # Get my notifications
PUT    /api/notifications/:id   # Mark as read
DELETE /api/notifications/:id   # Delete notification
POST   /api/notifications/broadcast # Broadcast notification (Admin)

Deployment

Production Build

Backend

# Build binary
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o bin/api cmd/api/main.go

# Build notification service
cd microservices/notification-service
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o bin/server cmd/server/main.go

Frontend

cd frontend
bun run build
# Output akan ada di folder dist/

Deploy dengan Docker/Podman

# Build images
podman-compose build
podman-compose up -d 

# Liat log
podman-compose logs -f backend

Troubleshooting

Database Connection Error

  • Pastikan PostgreSQL sudah running
  • Cek kredensial database di config
  • Pastikan database sudah di-create

Port Already in Use

# Cek port yang digunakan
sudo lsof -i :8080
sudo lsof -i :50051
sudo lsof -i :5173

# Kill process jika perlu
kill -9 <PID>

gRPC Connection Failed

  • Pastikan notification service sudah running
  • Cek konfigurasi gRPC URL di config
  • Cek firewall rules

File Upload Failed

  • Cek folder uploads/ memiliki permission yang benar
  • Pastikan max file size sudah dikonfigurasi
  • Cek disk space

Lisensi

Proyek ini dibuat untuk keperluan Uji Kompetensi Keahlian (UKK) SMK Jurusan Rekayasa Perangkat Lunak.

Ucapan Terima Kasih

  • Guru pembimbing dan penguji UKK
  • Claude, ChatGPT atas bantuannya dalam pengembangan kode, refactoring, dan implementasi GRPC ke backend.
  • Open source community atas tools dan libraries yang digunakan

Referensi

Catatan: Dokumentasi ini akan terus diperbarui seiring dengan perkembangan proyek.

Untuk pertanyaan dan bug report, silakan buat issue di repository ini.

About

project UKK, am i cooked? i don't care about your comment whether if this project is over engineered because there's a microservice.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published