Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

202 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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
  • Payment Integration: Seamless payment processing via Tripay gateway
  • Course Reviews: Students can review and rate courses
  • Responsive Design: Modern UI with Tailwind CSS

🛠 Tech Stack

Frontend

Backend

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

# Tripay Payment Gateway
TRIPAY_API_KEY=your_tripay_api_key
TRIPAY_PRIVATE_KEY=your_tripay_private_key
TRIPAY_MERCHANT_CODE=your_merchant_code
HMAC_KEY=your_hmac_key

# Frontend
NEXT_PUBLIC_API_URL=http://localhost:8080

3. Run with Docker Compose

docker-compose up --build

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
  • POST /api/payments/callback - Tripay webhook callback

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

Using Docker Compose

  1. Set environment variable in .env:

    SEED=true
  2. Start the application:

    docker-compose up

    The seeder will automatically run when the backend starts.

Local Development

  1. Update .env file in the backend/ directory:

    SEED=true
  2. Run the backend:

    cd backend
    go mod tidy
    go run main.go
  3. Verify in logs:

    [Seeder] Memulai proses seeding database...
    [Success] User Admin User berhasil dibuat
    ...
    [Seeder] Seeding database selesai!
    

Seeder Configuration

  • Default: SEED=false (disabled)
  • Enable: Set SEED=true in .env to run seeder on application startup
  • Safety: The seeder uses idempotent operations, so it can be run multiple times without creating duplicate data

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.


💳 Payment Integration

This project integrates with Tripay payment gateway for course payments. Features include:

  • Multiple payment methods support
  • Real-time payment status updates
  • Webhook callback handling
  • HMAC signature verification for security

Refer to Tripay Documentation for more details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages