DEV Community

Cover image for I developed a Smart Frontend Application for Personality Assessment
Muhammad Usman
Muhammad Usman

Posted on

I developed a Smart Frontend Application for Personality Assessment

How Our Personality Assessment Application Works

Table of Contents

  1. Overview
  2. Architecture
  3. User Flow
  4. Technical Components
    • 4.1 HTML Structure
    • 4.2 CSS Implementation
    • 4.3 JavaScript Logic
  5. Question Structure
  6. Scoring System
  7. Result Calculation
  8. Special Features
  9. Third-Party Integrations

Link to actual frontend application:
Click: Personality Assessment Test

Here is the source code, you can use it however you like:
And checkout your personality, and share it with your social media, if you like it.

1. Overview of the Personality Assessment Application

This personality assessment is a frontend web-based application that check user personality traits by asking 21 multiple-choice questions.
It provides:

  • Real-time progress tracking
  • Interactive question presentation
  • Visual result representation
  • Personality type classification
  • Social sharing capabilities

2. Architecture of this Personality Assessment Application

Personality Welcome Screen

A Three-screen single-page application:

  1. 1st is Welcome Screen
  2. 2nd is Test Screen
  3. Third and final is Results Screen

3. User Flow: How the Application works for the User?

Welcome Screen β†’ Start Test β†’ Answer Questions β†’ View Results β†’ (Share/Retake)
Enter fullscreen mode Exit fullscreen mode

4. Technical Components of the Application

4.1 HTML Structure

Three main sections:

<!-- Welcome Screen -->
<div class="screen welcome-screen active">...</div>

<!-- Test Screen -->
<div class="screen test-screen">...</div>

<!-- Results Screen -->
<div class="screen results-screen">...</div>
Enter fullscreen mode Exit fullscreen mode

4.2 CSS Implementation

Key features:

  • CSS Variables for theme management
  • GSAP-powered animations
  • Responsive grid layouts
  • Dynamic gradient effects
  • Progress ring animation
  • Neo-morphism design elements

4.3 JavaScript Logic for the Test

Core class: PersonalityAssessment

class PersonalityAssessment {
  constructor() { /* Initializes all components */ }
  initializeProgressCircle() { /* SVG progress ring setup */ }
  calculateTraitFrequencies() { /* Normalization data */ }
  renderQuestion() { /* Dynamic question display */ }
  handleAnswer() { /* Score calculation */ }
  calculateResults() { /* Trait percentage conversion */ }
  setPersonalityType() { /* Type classification */ }
}
Enter fullscreen mode Exit fullscreen mode

5. Questions Structure

Each question object in the application contains:

{
  question: "How do you prefer to spend your free time?",
  options: [
    { text: "Reading alone πŸ“–", trait: "introvert", emoji: "πŸ“–" },
    // ... other options
  ],
  category: "Social"
}
Enter fullscreen mode Exit fullscreen mode

6. Scoring System

  • 16 personality traits tracked
  • Each option adds +5 to its trait
  • Maximum possible score per trait: (number_of_questions * 5)
  • Normalization formula:
(traitScore / (traitFrequency * 5)) * 100
Enter fullscreen mode Exit fullscreen mode

7. Result Calculation for the Personality Test

Personality Results Screen

  • Convert raw scores to percentages
  • Sort traits by percentage
  • Determine primary trait
  • Generate personality description
  • Create visual chart (Graph)

8. Special Features

  • Dynamic Color Scheme: Primary color changes based on strongest trait
  • Confetti Animation: Canvas-confetti integration
  • Progress Ring: SVG-based circular progress indicator
  • Social Sharing: Platform-specific share URLs (LinkedIn, Facebook, Pinterest, Reddit, Twitter, WhatsApp)
  • GSAP Animations: Screen transitions and element animations

9. Third-Party Integrations

  • Chart.js: Radar chart visualization
  • GSAP: Smooth animations
  • Canvas-confetti: Result celebration effect
  • Google Fonts: Poppins typeface

For Technical Users who wants to enhance this application

Key Algorithms

Trait Normalization

value = Math.min(100, Math.round(
  (traitScore / (traitFrequency * 5)) * 100
))
Enter fullscreen mode Exit fullscreen mode

Personality Type Mapping

const typeMap = {
  Extrovert: {
    title: "The Social Catalyst",
    desc: "You thrive in group settings..."
  },
  // ... other types
}
Enter fullscreen mode Exit fullscreen mode

Color Scheme Animation

gsap.to(":root", {
  "--primary-hue": hueMap[trait] || 250,
  duration: 1.5,
  ease: "power2.out"
});
Enter fullscreen mode Exit fullscreen mode

Performance Considerations

  • Preloading: CSS/JS files preloaded
  • Lazy Loading: Chart.js loaded on demand
  • DOM Recycling: Question elements reused
  • GPU Acceleration: GSAP animations use transforms

Security Aspects

  • Content Security Policy (CSP) compatible
  • XSS protection through textContent
  • URL encoding for share links
  • Sanitized DOM manipulation

Extension Points

  • Add new questions while maintaining trait frequencies
  • Expand typeMap with additional personality types
  • Integrate with backend API for result storage
  • Add localization support
  • Implement question randomization

Keep supporting, keep sharing, and let’s grow together! πŸš€

πŸ“ Find me on: LinkedIn | Medium | Bluesky | Hackernoon

Top comments (2)

Collapse
 
madhurima_rawat profile image
Madhurima Rawat

Great ideaπŸ’‘ The UI is so beautiful and smooth.

Keep up the good work ✨️

Collapse
 
web_dev-usman profile image
Muhammad Usman

Thanks!