A comprehensive behavioral assessment platform implementing the Strengths and Difficulties Questionnaire (SDQ) with AI-powered conversational testing and professional review capabilities.
This platform allows children (11-17), parents, teachers, and psychologists to participate in a multi-perspective behavioral assessment process. The system uses conversational AI to guide users through the SDQ questionnaire, analyzes responses from multiple perspectives, and provides professional psychological reviews.
- Multi-Role Assessment: Children, parents, teachers, and psychologists each have tailored interfaces
- Conversational AI Testing: Natural language processing for intuitive questionnaire completion
- Intent Classification: Smart response interpretation with follow-up questions
- Vector Embeddings: Advanced response analysis using sentence transformers
- Professional Review System: Psychologist dashboard for comprehensive assessment review
- Real-time Scoring: Automated SDQ scoring with subscale analysis
- Secure Data Management: MongoDB-based data storage with role-based access
backend/
βββ backend_api/ # API endpoints
β βββ auth.py # Authentication & user management
β βββ chat.py # Conversational testing logic
β βββ child.py # Child registration & management
β βββ review.py # Psychologist review system
β βββ score.py # SDQ scoring algorithms
β βββ test.py # Test management & submission
βββ core/ # Core business logic
β βββ context_tracker.py # Conversation context management
β βββ prompt_builder.py # AI prompt construction
βββ db/ # Database layer
β βββ mongo_handler.py # MongoDB operations
β βββ vector_store.py # Vector embedding storage
βββ services/ # External services
β βββ llm_chat.py # Gemini AI integration
β βββ llm_score.py # AI-powered scoring
βββ utils/ # Utilities
β βββ intent_classifier.py # User intent detection
βββ main.py # FastAPI application entry
frontend/
βββ src/
β βββ components/ # Reusable UI components
β β βββ Chatbox.js # Conversational interface
β β βββ Header.js # Navigation header
β β βββ Login.js # Authentication component
β β βββ Navbar.js # Navigation bar
β βββ pages/ # Page components
β β βββ Home.js # Landing page
β β βββ Test.js # Assessment interface
β β βββ ChildDashboard.js # Child-specific dashboard
β β βββ ParentTeacherDash.js # Parent/teacher dashboard
β β βββ PsychDash.js # Psychologist dashboard
β β βββ Results.js # Assessment results
β β βββ Review.js # Professional review interface
β βββ App.js # Main application routing
- Python 3.8+
- Node.js 16+
- MongoDB (local installation or MongoDB Atlas)
- Gemini API Key (Google AI Studio)
-
Clone the repository
git clone <repository-url> cd sdq-assessment-platform
-
Set up Python environment
cd backend python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install Python dependencies
pip install -r requirements.txt
-
Set up environment variables Create a
.envfile in thebackend/directory:# LLM Configuration LLM_BACKEND=gemini GEMINI_API_KEY=your_gemini_api_key_here GEMINI_MODEL=gemini-2.0-flash # Database Configuration (if using MongoDB Atlas) MONGODB_URI=mongodb://localhost:27017 DATABASE_NAME=sdq_test_db
-
Start MongoDB
- Local MongoDB: Start MongoDB service
- MongoDB Atlas: Ensure your connection string is correct in the code
-
Run the backend server
uvicorn main:app --reload --host 0.0.0.0 --port 8000
The API will be available at
http://localhost:8000
-
Navigate to frontend directory
cd frontend -
Install dependencies
npm install
-
Start the development server
npm start
The application will be available at
http://localhost:3000
The application will automatically create the required collections:
users- User authentication datachildren- Child registration informationtests- Assessment responses and scoresreviews- Professional review documentsvector_responses- Embedded response vectors
graph TD
A[User Visits Home Page] --> B{Select User Role}
B --> B1[Child] & B2[Parent] & B3[Teacher] & B4[Psychologist]
B1 & B2 & B3 & B4 --> C[Login/Signup]
C --> D{Authentication Success?}
D -->|Yes| E{Check User Role}
E -->|Child| H[Child Registration/Dashboard]
E -->|Parent/Teacher| G[Dashboard]
E -->|Psychologist| F[Professional Dashboard]
-
Child Registration
- Child (or adult) registers with basic information
- System generates unique sharing code
- Code shared with parent and teacher
-
Multi-Perspective Testing
- Each party (child β₯11, parent, teacher) completes assessment
- Conversational AI guides through 25 SDQ questions
- Responses analyzed with intent classification
- Vector embeddings stored for detailed analysis
-
Professional Review
- Once all parties complete testing, review is generated
- AI creates preliminary summary
- Psychologist reviews comprehensive data
- Professional recommendations provided
-
Results Access
- All parties can access results after professional review
- Detailed scores and recommendations displayed
The platform uses sophisticated NLP to make assessments more natural:
graph TD
START[User Input] --> INTENT[Intent Classifier]
INTENT --> DECISION{Intent Type}
DECISION -->|direct_answer| EXTRACT[Extract Option]
DECISION -->|confirmation| STORE[Store & Next Question]
DECISION -->|confused| EXPLAIN[Provide Explanation]
DECISION -->|sharing_experience| ANALYZE[LLM Analysis]
ANALYZE --> SUGGEST[Suggest Response Option]
SUGGEST --> CONFIRM[User Confirmation]
CONFIRM --> STORE
POST /auth/signup- User registrationPOST /auth/login- User authentication
POST /child/register- Register new child or login existingPOST /child/login- Login with sharing codeGET /child/{child_id}- Get child detailsGET /child/code/{code}- Validate sharing code
POST /chat/start- Initialize assessment sessionPOST /chat/respond- Process user responses with AIPOST /chat/confirm-option- Confirm response selection
POST /test/submit- Submit completed assessmentGET /test/summary- User dashboard dataGET /test/results/{child_id}- Access resultsGET /test/score/{test_id}- Get calculated scores
GET /reviews/pending- Pending reviews for psychologistsGET /reviews/completed- Completed reviewsGET /reviews/{child_id}- Comprehensive review dataPOST /reviews/submit- Submit professional review
The system classifies user intents to provide appropriate responses:
direct_answer- Clear SDQ option choiceconfirmation- Agreement with suggestioncorrection- Disagreement or clarificationconfused- Needs explanationsharing_experience- Contextual informationunclear- Ambiguous response
- Uses SentenceTransformer (
all-MiniLM-L6-v2) for response analysis - Stores conversation context for professional review
- Enables semantic similarity analysis
- Gemini 2.0 Flash for conversational responses
- Dynamic prompt building based on user role and age
- Context-aware question explanations
- Ages 2-4: Simplified behavioral descriptors
- Ages 5-10: Standard SDQ questions
- Ages 11-17: Age-appropriate phrasing
- Standard Questions: Not True (0), Somewhat True (1), Certainly True (2)
- Reverse Scored: Questions 7, 14, 20, 21, 25 (reversed)
- Subscales: Emotional, Conduct, Hyperactivity, Peer Problems, Prosocial
- Total Score: Sum of all subscales (excluding Prosocial)
- 0-15: Normal range
- 16-19: Slightly raised
- 20-40: High/Very high (clinical concern)
- Role-based Access Control: Users only access appropriate data
- Data Encryption: Sensitive information protected
- Authentication Required: All endpoints secured except public routes
- Child Protection: Special handling for minor data
-
MongoDB Connection Error
Check MongoDB service is running Verify connection string in mongo_handler.py -
Gemini API Error
Verify GEMINI_API_KEY in .env file Check API quota and billing -
Vector Embedding Issues
Install sentence-transformers: pip install sentence-transformers Check model download (happens on first run) -
Frontend API Connection
Ensure backend is running on port 8000 Check CORS settings in main.py
- Hot Reload: Both frontend and backend support hot reloading
- Database Reset: Drop collections in MongoDB to reset data
- API Testing: Use
/docsendpoint for FastAPI interactive documentation - Logging: Check console output for detailed error messages
// users
{
email: String,
password_hash: String,
role: String, // "child", "parent", "teacher", "psychologist"
created_at: Date
}
// children
{
child_id: String,
name: String,
age: Number,
gender: String,
code: String, // sharing code
email: String
}
// tests
{
test_id: String,
child_id: String,
respondent_type: String,
confirm_options: Array, // SDQ responses
vector_responses: Array, // embeddings
scores: Object, // calculated scores
submitted: Boolean
}
// reviews
{
child_id: String,
ai_generated_summary: String,
psychologist_review: String,
status: String, // "pending", "reviewed"
scores: Object // all perspective scores
}- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue in the repository
- Check the troubleshooting section above
- Review API documentation at
http://localhost:8000/docs
Note: This is a behavioral assessment tool designed for educational and research purposes. Always consult qualified mental health professionals for clinical decisions.