How nikhil-2x/quiz-application works
1. This is a Flutter client application for a quiz product, with one shared Dart codebase targeting mobile, desktop, and web. The repository contains only the frontend; the backend service and Firebase project configuration live outside the repo.
2. The app starts in lib/main.dart, which is responsible for app bootstrap and Firebase initialization before the UI is shown. From there, the widget tree drives the full quiz flow and theming.
3. The core UX is organized into four screens under lib/screens: home_screen.dart, quiz_screen.dart, result_screen.dart, and analysis_screen.dart. These represent the main state transitions: enter user name, take the quiz, review results, and inspect AI-generated analysis.
4. lib/screens/quiz_screen.dart is the central orchestration point. It manages question progression, answer checking, wrong-answer behavior, and when to call external services for hints or completion analysis.
5. Data is modeled explicitly in lib/models using question.dart, answered_question.dart, and quiz_attempt.dart. These models form the boundary between Firestore documents, in-memory quiz state, and attempt history shown to the user.
6. Persistence is handled through lib/services/firebase_service.dart, which reads quiz questions from the Firestore questions collection and writes completed runs to quiz_attempts. Firestore is the app’s primary data source for content and history, not just a cache.
7. AI-related behavior is isolated in lib/services/ai_api_service.dart. The app calls a deployed external backend for two functions: requesting a hint after the first wrong answer, and requesting a performance report after the quiz finishes.
8. The README-defined flow is a two-system integration: Firestore provides quiz content and attempt storage, while the backend API provides dynamic AI responses. The Flutter client sits in the middle and coordinates both based on user actions.
9. lib/widgets/hint_dialog.dart is a focused UI boundary for presenting AI hints, keeping the hint interaction separate from the main quiz screen logic.
10. lib/screens/result_screen.dart is the post-quiz aggregation layer: it shows score results, recent attempts, and an entry point for AI analysis. This screen likely consumes both Firestore history and backend analysis output.
11. Platform directories under android, ios, macos, windows, linux, and web are standard Flutter host shells. They provide native launch/configuration glue, but the application logic remains in lib/.
12. Secrets and environment-specific Firebase values are externalized through secrets.json / --dart-define-from-file, which means the app is environment-configured at build time rather than hardcoding credentials in source.
13. Testing is light and centered on Flutter’s default widget test harness in test/widget_test.dart, suggesting the architecture is currently product-focused with minimal automated domain coverage.
14. The important architecture boundary is therefore: Flutter UI and client state in this repo, Firestore as the quiz datastore, and an external AI backend as a stateless service for hints and analysis.
Main entry points: quiz_screen.dart Quiz · result_screen.dart Results · main.dart App entry · firebase_service.dart Firestore service
Components 14
Flutter client
Shared Dart application logic and UI under lib/.
- App entry · Starts the app and initializes Firebase before UI render.
lib/main.dart - Home · Collects user name and begins the quiz flow.
lib/screens/home_screen.dart - Quiz · Central quiz orchestration: progression, scoring, wrong-answer handling, and service calls.
lib/screens/quiz_screen.dart - Results · Shows score summary, recent attempts, and entry points to analysis.
lib/screens/result_screen.dart - Analysis · Displays AI-generated performance analysis after completion.
lib/screens/analysis_screen.dart - Hint dialog · Dedicated UI for presenting AI hints without cluttering quiz flow.
lib/widgets/hint_dialog.dart - Question · Firestore-backed quiz question model.
lib/models/question.dart - Answered question · In-memory record of a question plus the user's answer and correctness.
lib/models/answered_question.dart - Quiz attempt · Persistent attempt history shown in results and stored in Firestore.
lib/models/quiz_attempt.dart - Firestore service · Reads questions from Firestore and writes completed quiz attempts.
lib/services/firebase_service.dart - AI API service · Calls the external backend for hints and completion analysis.
lib/services/ai_api_service.dart
Platform shells
Native host projects for mobile, desktop, and web runtime launch.
- Host apps · Native and web launch shells that embed the shared Flutter codebase.
Build config
Environment-specific and test-time repository boundaries.
- Widget test · Default Flutter widget test coverage with minimal domain-specific automation.
test/widget_test.dart - Secrets config · Externalized Firebase and environment values supplied at build time.
secrets.json.example
Connections 18
- App entry → Host apps: boots on · The shared Flutter app runs inside platform-specific shells.
- App entry → Home: shows · App bootstrap leads into the home screen.
- App entry → Firestore service: initializes · Firebase setup happens before the UI flow starts.
- Home → Quiz: starts · User name entry begins the quiz session.
- Quiz → Question: loads · Questions are materialized from Firestore content.
- Quiz → Answered question: tracks · Selected answers are accumulated as quiz state.
- Quiz → Firestore service: reads/writes · Quiz screen pulls questions and persists completed attempts.
- Quiz → AI API service: requests hint · First wrong answer can trigger an AI hint request.
- Quiz → Hint dialog: opens · Hints are presented through a dedicated dialog boundary.
- Quiz → Results: completes · Quiz completion transitions to the results screen.
- Results → Quiz attempt: shows · Results summarize stored attempt history.
- Results → Firestore service: loads history · Recent attempts come from Firestore.
- Results → AI API service: requests analysis · Post-quiz analysis is fetched from the external backend.
- Results → Analysis: opens · Analysis screen is entered from results.
- Firestore service → Question: maps · Firestore documents are converted into question models.
- Firestore service → Quiz attempt: persists · Completed runs are stored as quiz attempt documents.
- Widget test → App entry: smokes · Default widget test exercises the app harness.
- Secrets config → App entry: configures · Build-time values feed Firebase initialization and runtime setup.