Skip to content

Enhance deployment, fix APIs, and update UI components#871

Open
Mohitranag18 wants to merge 147 commits intoFOSSEE:masterfrom
Mohitranag18:semister-long-2025
Open

Enhance deployment, fix APIs, and update UI components#871
Mohitranag18 wants to merge 147 commits intoFOSSEE:masterfrom
Mohitranag18:semister-long-2025

Conversation

@Mohitranag18
Copy link
Copy Markdown

@Mohitranag18 Mohitranag18 commented Apr 27, 2026

Overview

This PR is a comprehensive modernization and re-architecture of the Yaksh Online Test Platform, with changes spanning deployment, infrastructure-as-code, API backend (Django + REST), business domain logic, and a full rewrite of the React frontend (including component-level and integration tests). It introduces robust deployment automation, deepens API feature coverage, reorganizes REST endpoints, brings testable modern React UI, and provides exhaustive developer/operator documentation.

  • Total Files Changed: 150+
  • Commits: 147
  • Additions: ~47,000 lines
  • Deletions: ~515 lines
  • Scope: Deployment, Backend API (serializers, views, tests, URLs), UI Architecture, DevOps, Testing, and Documentation
  • Design Focus: Clean separation of concerns, expanding test coverage, deployment reproducibility, developer onboarding

1. Deployment & DevOps

Patterns and Practices

  • 12-factor App: All secrets/configs are via .env/environment variables.
  • Infrastructure as Code (IAC): render.yaml describes the deployment blueprint. All infra steps are tracked and repeatable.
  • Documentation-Driven Setup:
    • COMPLETE_DEPLOYMENT_GUIDE.md, DEPLOYMENT_QUICKSTART.md, and LOCAL_SETUP_GUIDE.md provide step-by-step onboarding/deployment for local/dev/staging/prod.
    • These docs serve as source-of-truth for common tasks like troubleshooting CORS, migrations, or static collection.

Breakdown

  • Backend (Render.com)

    • Uses gunicorn for WSGI serving, whitenoise for static files, and dj-database-url for flexible DB parsing.
    • Celery support is optional—dynamically excluded if package not installed (see code in settings.py and online_test/__init__.py).
    • Extensive env var documentation and production-safe defaults, including optional Redis caching.
  • Frontend (Vercel)

    • Standard Vite/React deployment—custom VITE_API_URL env variable points to backend.
    • Frontend and backend CORS domains are automatically synchronized via .env entries and descriptive doc instructions.
  • Database

    • Uses Neon PostgreSQL (free tier explained in docs) for zero-cost but scalable DB.
  • Environment File Examples

    • .env.example with every key explained (DB, Redis, Email, Social logins).

2. API & Backend Changes

Design Patterns & Refactoring

  • Serializer Expansion (Django REST)

    • All entities (User, Profile, Course, Quiz, Question, Paper, Badge, Notification, etc.) now have explicit, well-structured serializers.
    • Patterns:
      • SerializerMethodField and computed fields for dynamic attributes.
      • Dedicated serializers for nested or related entities (e.g., badges progress, stats).
      • Split logic for student vs. teacher APIs via context and permissions.
  • API Views (CBV & FBV)

    • Class-based views for REST resource lists and details (QuizList, QuestionDetail, etc.)
    • Function-based views for complex endpoints (e.g., custom enroll flow, password reset).
    • Clear route separation for student vs. teacher vs. common APIs.
    • Grouped endpoints by role/function in api/urls.py (over 250 detailed routes).
    • New RESTful patterns: all lesson/forum/post/comment/notification APIs are consistent and discoverable.
  • API URL Design

    • Route structure is role-centric (student/teacher/common).
    • All API URLs standardized and annotated for discoverability.
  • Test Coverage

    • Heavily augmented Django REST tests—now validate core CRUD, role-specific flows, and edge cases (see api/tests.py).
    • Many tests for lifecycles, permissions, and resource state transitions.

Notable Backend Enhancements

  • Modularization
    • Clean separation of logic per domain (serializer/viewset/test).
    • Each API feature is grouped and layered (e.g., forum, notifications, grading, analytics).
  • Advanced Business Logic
    • Badge/achievement computation and tracking.
    • Granular progress computation at course/module/unit/lesson granularity.
    • Enhanced enrollment flow: request, approval, self-enrollment, and more.
  • Edge Case Handling
    • All user flows (enrollment, completion, moderation) handle missing/inactive state robustly.
  • Backward Compatibility
    • Careful URL versioning preserves legacy routes (with explanatory comments).

3. Frontend/UI Engineering (React + Vite)

Modern React Design Patterns

  • Atomic/Flexible Componentization:

    • Pages, layouts, and atomic components (e.g., buttons, inputs, navs) conform to clear naming and responsibility.
    • Common UI/UX logic extracted to reusable hooks and shared state via Zustand.
  • Routing

    • Role-based protected routes (PrivateRoute, PublicRoute).
    • Teacher and Student areas are cleanly separated via route layouts and logic.
    • Deep-linking and parameterized routes for logical resource access.
  • State and Data Flow

    • Zustand state management for global session/auth.
    • Axios for API communication, abstracted to a shared api utility.
  • Theme and Style

    • TailwindCSS for rapid, scalable, and consistent styling.
    • ThemeSelector for user-customizable appearance.
    • Design system primitives for reusability.
  • Testing

    • Vitest + React Testing Library: Unit and integration tests for all key flows/components, including UI snapshot, form validation, API error handling, permission guards, and child component interaction.
    • Test structure mirrors app’s file/component structure, maximizing maintainability.

Key UI Features

  • Responsive & Accessible Design: All layouts adapt for mobile/web, ARIA attributes and keyboard navigation are considered.
  • User Role Awareness: Dashboard and navigation adapt dynamically for students vs teachers.
  • Interaction Enhancements:
    • Real-time feedback (toasts, loading indicators).
    • Guard-rails for routing (unauthenticated, unauthorized access).
    • UI patterns for notifications, badges, course catalog, and insights.
  • Modern Build Tooling: ESLint setup, Vite optimizations, postcss, automatic code formatting and linting.
  • Frontend Documentation: frontend/README.md for component/library standards and extension.

4. Testing & Quality

  • Unit and Integration Testing:
    • Python (Django): api/tests.py covers user, permissions, roles, and all business invariants.
    • JavaScript (React): All functional and core scenarios are tested using Vitest + Testing Library.
    • Snapshot Testing: Ensures critical components/UI regressions are caught.
  • Test Data Management: Fixtures and sample data are documented for easy setup.
  • Continuous Integration: Guides for adding CI runners and coverage checks via Render/Vercel and test scripts.

5. Patterns, Principles & Security

  • Separation of Concerns: Each domain (course, quiz, auth, notification, forum, badge) has isolated models, serializers, endpoints, and tests, making maintenance and scaling easier.
  • Environment Parity: Local/prod/staging all use identical env var-driven config; guides explain differences.
  • Security Best Practices:
    • All sensitive info in env files—never hard-coded.
    • Strict URL/host/CORS origin checks.
    • Django security settings tightened for production (SSL redirection, HSTS, secure cookies).
  • Backward Compatibility: API endpoint design and code comments explain rationale wherever an “odd” compatibility step is present.

6. Documentation Added

  • COMPLETE_DEPLOYMENT_GUIDE.md: Step-by-step with screenshots, edge cases, troubleshooting sections, and cost analysis.
  • LOCAL_SETUP_GUIDE.md: For local onboarding, covers common platform and language-agnostic issues.
  • DEPLOYMENT_QUICKSTART.md: High-level, reader-friendly checklist for quick deploys/testing.

7. Summary Table: File/Module Highlights

File/Area Change Type Design/Pattern Purpose/Example
.env.example new 12-factor env Document all config keys and usage
render.yaml new Infra-as-Code Automate deployment (Render backend)
api/serializers.py major DRF nested serializers APIs for Notifications, Badges, Lessons, UserStats, Profile, Course w/ computed fields
api/views.py major CBV + FBV, modular Grouped endpoints (student/teacher/common), new forum/badges/insights APIs
api/urls.py major Role-based URL config 250+ routes, discoverable via role prefix
api/tests.py major Full lifecycle/test Teacher quiz lifecycle, permission, CRUD
frontend/ new React (Vite) Modern UI, routing, auth, state, theme
frontend/src/__tests__ new Vitest+RTL Unit/snapshot/integration UI tests
COMPLETE_DEPLOYMENT_GUIDE.md new Deep documentation Onboarding, troubleshooting, step-by-step

8. Notable Best Practices Observed

  • “Pit of Success” Patterns: Local dev mirrors prod, onboarding is easy, deployment is automated, and testing is codified.
  • Clear, Idempotent APIs: All API endpoints have idempotent/semantic HTTP verbs; all error/edge cases are tested.
  • Robust Modularization: Each business function (notifications, badges, forum) is its own module with explicit boundaries.
  • Developer Experience: All new features/tests are discoverable and documented.

9. Reviewer Notes

  • This PR is sweeping but well-structured: Each part (deployment, backend, UI, testing) is changed in a clear, maintainable way.
  • Most important files to review: api/serializers.py, api/views.py, api/urls.py, /frontend/src/, /frontend/src/__tests__/, deployment guides.
  • API/route changes are backward-compatible: Old client flows will not break.
  • All logic is now testable: New and old flows are covered by backend and frontend test suites.
  • Reproducibility is prioritized: Any developer/operator can set up the full stack from scratch and diagnose/extend it with the new docs.

Mohitranag18 and others added 30 commits November 22, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants