Skip to content

sujaldeshmukh1012/pinguo-app

Repository files navigation

Pinguo Dashboard Backend

The Pinguo Dashboard Backend powers the core functionality of the teacher-side admin interface in the Pinguo language learning platform. Built using Django and Django REST Framework, this backend handles content creation, test management, media storage, JWT authentication, and integration with a React frontend dashboard.


πŸš€ Key Features

  • πŸ“š Course & Lesson Management
  • πŸ—£οΈ Dialogue Groups with Audio & Image Modals
  • 🧠 Custom Test Cards with Multiple Answer Types
  • πŸ” JWT-Based Authentication
  • 🌍 Cloud Media Storage (DigitalOcean Spaces via S3)
  • πŸ“€ REST API Endpoints for Frontend Integration
  • 🧩 Dynamic Drag & Drop Item Management
  • πŸŽ›οΈ Admin Interface via Django + Jazzmin

🧱 Project Structure


dashboard\_backend/
β”œβ”€β”€ dashboard\_backend/       # Project settings & root config
β”œβ”€β”€ course/                  # Lessons, metadata & course-related models
β”œβ”€β”€ dialogue/                # Dialogue, Balloons, Images, Test Cards
β”œβ”€β”€ word\_card/               # Word flashcards or related resources
β”œβ”€β”€ dictionary/              # Dictionary entries and utilities
β”œβ”€β”€ alerts/                  # Notification & alert system
β”œβ”€β”€ authorization/           # JWT Auth & User profile extensions
└── media/ / static/         # (Optional) Local storage fallback


πŸ§‘β€πŸ« Functional Overview

πŸ“˜ Dialogue Module

Handles conversational data:

  • DialogueGroup: A container for dialogues in a lesson
  • Dialogue: Contains audio, image, and text balloon entries
  • Ballon: Holds text + audio + ideogram + pronunciation
  • ImageModal: Hints-based image cards for visual learning
  • TestCard and TestAnswer: Custom quiz system per dialogue

πŸ§ͺ Test System

Each TestCard belongs to a DialogueGroup, referencing:

  • Dialogue
  • Related Balloon
  • Answers (ideogram, pinyin, or meaning type)

Includes automatic linking in the dialogue arrangement list.


βš™οΈ Setup Instructions

πŸ” Prerequisites

  • Python 3.10+
  • Django 4.1+
  • PostgreSQL / SQLite
  • pipenv or venv for environment management

πŸ“¦ Installation

git clone https://github.com/your-org/pinguo-dashboard-backend.git
cd pinguo-dashboard-backend

# Create virtual env
python -m venv venv
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Set environment variables (use .env file)
cp .env.example .env

πŸ› οΈ Environment Variables (.env)

SECRET_KEY=your_secret_key
DEBUG=True

# AWS S3 (DigitalOcean Spaces or other)
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_STORAGE_BUCKET_NAME=...
AWS_S3_ENDPOINT_URL=...
AWS_LOCATION=static
AWS_MEDIA_LOCATION=media

πŸ—„οΈ Migrations & Superuser

python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser

πŸ”„ Run Server

python manage.py runserver

πŸ§ͺ API Auth Test

Use JWT via /api/token/ and /api/token/refresh/ endpoints. Headers for authenticated routes:

Authorization: Bearer <your_access_token>

☁️ Cloud Storage

Uses DigitalOcean Spaces (or any S3-compatible service) for:

  • Media: MEDIA_URL
  • Static files: STATIC_URL

Uses Django's storages and boto3.


πŸ”’ Security

  • JWT Authentication via rest_framework_simplejwt
  • CORS open to all (CORS_ORIGIN_ALLOW_ALL=True) β€” restrict in production

🧰 Admin Panel

Powered by Jazzmin, for an enhanced Django Admin UI.


πŸ§ͺ API Stack

  • rest_framework
  • rest_framework_simplejwt
  • corsheaders
  • decouple for config
  • storages + boto3 for file hosting

🧠 Models Snapshot

Dialogue Content Models

  • DialogueGroup β†’ Dialogue β†’ Ballon, ImageModal
  • TestCard β†’ TestAnswer
  • DGItemListMain β†’ handles drag-n-drop ordering & dynamic updates

🐳 Docker Support

1. Dockerfile

# Dockerfile
FROM python:3.10-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set working directory
WORKDIR /app

# Install dependencies
COPY requirements.txt .
RUN pip install --upgrade pip && pip install -r requirements.txt

# Copy project files
COPY . .

# Collect static files (if needed)
RUN python manage.py collectstatic --noinput

# Expose port
EXPOSE 8000

# Run the app
CMD ["gunicorn", "dashboard_backend.wsgi:application", "--bind", "0.0.0.0:8000"]

2. docker-compose.yml

version: "3.9"

services:
  web:
    build: .
    command: gunicorn dashboard_backend.wsgi:application --bind 0.0.0.0:8000
    ports:
      - "8000:8000"
    volumes:
      - .:/app
    env_file:
      - .env
    depends_on:
      - db

  db:
    image: postgres:14
    environment:
      POSTGRES_DB: pinguo
      POSTGRES_USER: rootuser
      POSTGRES_PASSWORD: rootuser9683
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

3. .dockerignore

__pycache__/
*.pyc
*.pyo
*.pyd
*.sqlite3
env/
venv/
*.env
/media
/static

πŸ” GitHub Actions CI/CD

.github/workflows/deploy.yml

name: Django CI/CD

on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest

    services:
      postgres:
        image: postgres:14
        env:
          POSTGRES_DB: pinguo
          POSTGRES_USER: rootuser
          POSTGRES_PASSWORD: rootuser9683
        ports:
          - 5432:5432
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

    env:
      DEBUG: 0
      SECRET_KEY: ${{ secrets.SECRET_KEY }}
      DB_NAME: pinguo
      DB_USER: rootuser
      DB_PASSWORD: rootuser9683
      DB_HOST: localhost

    steps:
      - uses: actions/checkout@v3

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt

      - name: Run migrations
        run: |
          python manage.py makemigrations
          python manage.py migrate

      - name: Run tests
        run: |
          python manage.py test

πŸ”’ Store sensitive variables (e.g., SECRET_KEY, DB creds) in GitHub repo secrets.


🧾 License

This project is private and proprietary to the Pinguo development team. Unauthorized use or distribution is prohibited.


πŸ‘¨β€πŸ’» Contributors

Maintained by the SUJAL DATTARAO BHAKARE.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors