Design a Survey and Polling Platform
MediumReal World SystemsForm BuilderAnalyticsMultiple Question TypesSubmission Tracking
Problem Statement
Design a survey and polling platform like Google Forms or SurveyMonkey where users create surveys with multiple question types, distribute them, collect responses, and view analytics.
Requirements
Functional Requirements
- Create surveys: title, description, questions (ordered list)
- Question types: MULTIPLE_CHOICE (single select), CHECKBOX (multi-select), TEXT (free-form), RATING (1–5), YES_NO
- Question properties: text, required flag, options (for MC/Checkbox)
- Survey states: DRAFT, ACTIVE, CLOSED
- Distribute via shareable link
- Respondent submits answers (one submission per respondent by email)
- Prevent duplicate submissions from same email
- Analytics: per-question response distribution, total responses, completion rate
- Export results to CSV format (modeled as a List<List<String>>)
- Survey close: manual or auto-close on response limit
Non-Functional Requirements
- Thread-safe response submission
- Singleton SurveyService
Key Entities
- Survey: id, creator, title, description, questions, status, responseLimit, responses
- Question: id, text, type, required, options (for MC/Checkbox)
- Response: id, survey, respondentEmail, answers (Map<QuestionId, Answer>), submittedAt
- Answer: questionId, selectedOptions (for MC/Checkbox), textValue (for Text), ratingValue
- SurveyAnalytics: questionId → Map<option, count> for choice questions
Constraints
- Required questions must be answered before submission accepted
- Duplicate submission (same email) rejected
- Survey must be ACTIVE to accept responses
- Response limit: if set, auto-close survey on reaching limit
!Constraints
- Required questions must be answered
- Duplicate email submissions rejected
- Survey must be in ACTIVE state to accept responses
- Auto-close when response limit reached (if configured)
- Thread-safe: concurrent submissions must not exceed response limit
Output
Run or submit your code to see output here.