Skip to content
Dinus-Open-Source-CommunityPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

369 Commits

Folders and files

Repository files navigation

Doscom Web Platform (Dinus Open Source Community)

A full-stack learning management system built with Next.js + Go + PostgreSQL. This platform enables course creation, enrollment management, and payment processing for online education.


πŸ“‹ Table of Contents


🎯 Project Overview

Doscom Web is a comprehensive learning management system featuring:

  • User Management: Registration, authentication (JWT + OAuth Google), user profiles & avatars
  • Course Management: Create, manage, and organize courses with modules and lessons
  • Enrollment System: Students can enroll in courses and track progress
  • Course Reviews: Students can review and rate courses
  • Responsive Design: Modern UI with Tailwind CSS

πŸ›  Tech Stack

Frontend

Backend

  • Language: Go 1.25.1
  • Framework: Gin Web Framework
  • Database: PostgreSQL 15
  • ORM: GORM
  • Authentication: JWT + Google OAuth
  • API Documentation: Swagger/OpenAPI

Infrastructure

  • Containerization: Docker & Docker Compose
  • Database Admin: Adminer (Web UI for PostgreSQL)

πŸ“ Project Structure

web-DU/
β”œβ”€β”€ frontend/                    # Next.js frontend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/               # Next.js app directory
β”‚   β”‚   β”‚   β”œβ”€β”€ globals.css
β”‚   β”‚   β”‚   β”œβ”€β”€ layout.tsx
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   └── components/        # Reusable React components
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ tsconfig.json
β”‚   └── Dockerfile
β”‚
β”œβ”€β”€ backend/                     # Go backend application
β”‚   β”œβ”€β”€ internal/
β”‚   β”‚   β”œβ”€β”€ database/          # PostgreSQL connection & migrations
β”‚   β”‚   β”œβ”€β”€ handler/           # HTTP request handlers & middleware
β”‚   β”‚   β”‚   β”œβ”€β”€ middleware/    # JWT, CORS, auth middleware
β”‚   β”‚   β”‚   └── routes/        # API route definitions
β”‚   β”‚   β”œβ”€β”€ model/             # Data models
β”‚   β”‚   β”‚   β”œβ”€β”€ dto/           # Data Transfer Objects
β”‚   β”‚   β”‚   └── entity/        # Database entities
β”‚   β”‚   β”œβ”€β”€ service/           # Business logic
β”‚   β”‚   └── utils/             # Helper functions (bcrypt, payments)
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   └── uploads/           # User uploads (avatars, course images)
β”‚   β”œβ”€β”€ docs/                  # Swagger API documentation
β”‚   β”œβ”€β”€ main.go
β”‚   β”œβ”€β”€ go.mod
β”‚   └── Dockerfile
β”‚
β”œβ”€β”€ docker-compose.yml         # Docker Compose configuration
└── README.md                  # This file

πŸ“¦ Prerequisites

Ensure you have the following installed:

  • Docker (v20+) & Docker Compose (v2+)
  • Git
  • (Optional) Go (v1.25+) for local backend development
  • (Optional) Node.js (v18+) & npm for local frontend development

πŸš€ Getting Started

1. Clone the Repository

git clone https://github.com/Dinus-Open-Source-Community/web-DU.git
cd web-DU

2. Environment Variables

Create a .env file in the root directory with the following variables:

# Database
DB_HOST=db
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=your_password
DB_NAME=doscom
DB_SSLMODE=disable
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_password
POSTGRES_DB=doscom

# Backend
BASE_URL=http://localhost:8080
JWT_SECRET_KEY=your_jwt_secret_key

# Google OAuth
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret

# Encryption
AES_KEY=your_aes_key_32_chars_long

HMAC_KEY=your_hmac_key

# Frontend
NEXT_PUBLIC_API_URL=http://localhost:8080

3. Run with Docker Compose or Podman Compose

Build and start with Docker Compose:

docker-compose up --build

Build and start with Podman Compose:

podman-compose build
podman-compose up -d

This will start all services:

4. Stop the Project

docker-compose down

πŸ“š API Documentation

The API documentation is available via Swagger/OpenAPI:

URL: http://localhost:8080/swagger/index.html

Main API Endpoints

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • GET /api/auth/google - Google OAuth callback
  • POST /api/auth/refresh - Refresh JWT token

Users

  • GET /api/users/:id - Get user profile
  • PUT /api/users/:id - Update user profile
  • POST /api/users/:id/avatar - Upload user avatar

Courses

  • GET /api/courses - List all courses
  • POST /api/courses - Create new course (instructor only)
  • GET /api/courses/:id - Get course details
  • PUT /api/courses/:id - Update course (instructor only)
  • DELETE /api/courses/:id - Delete course (instructor only)

Enrollments

  • POST /api/enrollments - Enroll in a course
  • GET /api/enrollments - List user enrollments
  • GET /api/enrollments/:id - Get enrollment details

Payments

  • POST /api/payments - Create payment
  • GET /api/payments/:id - Get payment status

Lessons & Modules

  • GET /api/modules/:id/lessons - Get lessons in a module
  • POST /api/lessons/:id/complete - Mark lesson as complete

πŸ—„ Database

PostgreSQL Setup

The PostgreSQL database is automatically initialized via Docker Compose. The database includes the following main tables:

  • users - User accounts with roles (student/instructor)
  • courses - Course information
  • enrollments - Student course enrollments
  • modules - Course modules
  • lessons - Course lessons
  • payments - Payment records
  • course_reviews - Student course reviews
  • course_announcements - Course announcements

Access Database

Adminer UI: http://localhost:8012

  • Server: db
  • User: postgres
  • Password: (from .env POSTGRES_PASSWORD)
  • Database: (from .env POSTGRES_DB)

🌱 Database Seeder

The project includes a database seeder to automatically populate the database with sample data for development and testing.

Seeder Features

The seeder creates:

  • 3 Users: 1 admin + 2 students with different roles

  • 5 Courses: Premium and free courses with realistic pricing

    • Golang Fundamentals (Rp 299.000)
    • Web Development dengan Next.js (Rp 349.000)
    • Database Design dan SQL (Free)
    • REST API Development (Rp 299.000)
    • DevOps Essentials (Rp 329.000)
  • Multiple Modules: 2-3 modules per course (~15 total)

  • Multiple Lessons: 2-3 lessons per module (~35 total)

Running the Seeder

Seeder runs only through the dedicated seed binary. Backend startup never seeds.

Local Development

cd backend
go build -o bin/seed ./cmd/seed
./bin/seed

Using Docker Compose

docker compose exec backend ./seed

Expected logs:

[Seed CLI] Mode incremental β€” data yang sudah ada TIDAK dihapus
[Seeder] Memulai proses seeding database...
[Success] User Admin User berhasil dibuat
...
[Seeder] Seeding database selesai!

Seeder Configuration

  • Safety: The seeder uses idempotent operations, so it can be run multiple times without creating duplicate data
  • No env toggle: SEED is no longer read; run the seed binary when you need seeding

Seeder Details

The seeder is implemented in backend/internal/database/seeder.go with the following functions:

  • RunSeeder() - Main seeder function
  • seedUsers() - Creates user data
  • seedCourses() - Creates course data
  • seedModules() - Creates module data for each course
  • seedLessons() - Creates lesson data for each module
  • hashPassword() - Hashes passwords using bcrypt

All passwords are securely hashed using bcrypt with the default cost factor. The seeder prevents duplicate entries by checking if records already exist before insertion.


πŸ’» Development

Frontend Development

cd frontend
npm install
npm run dev

Access at http://localhost:3000

Backend Development

cd backend
go mod download
go run main.go

Backend runs on http://localhost:8080


πŸ” Authentication

JWT Token

The API uses JWT (JSON Web Tokens) for authentication. Include the token in the Authorization header:

Authorization: Bearer YOUR_JWT_TOKEN

Google OAuth

Sign in with Google account for seamless authentication. Requires valid GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET.


About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages