A secure, intelligent chatbot system designed to facilitate communication between parents and schools, providing access to student information, grades, attendance, and schedules.
- JWT-based authentication for parents
- Password hashing with bcrypt
- Rate limiting to prevent abuse
- Session management for chat conversations
- Data privacy compliance for student information
- Natural language processing for parent queries
- Context-aware conversations
- Structured responses with formatting
- Multi-topic support (attendance, grades, schedules, etc.)
- Help system with usage examples
- Attendance Records: Monthly statistics, absence tracking
- Academic Performance: Grades, test scores, subject-wise performance
- Class Schedules: Timetables, teacher assignments, room information
- Teacher Information: Contact details, subject mappings
- Responsive web interface
- Real-time chat functionality
- Mobile-friendly design
- Typing indicators and message formatting
- Secure login/logout system
- Backend: Python FastAPI
- Database: SQLite with secure schema design
- Authentication: JWT tokens with python-jose
- Frontend: HTML5, CSS3, JavaScript (Vanilla)
- Security: bcrypt via passlib, SlowAPI rate limiting, CORS protection
- Docker and Docker Compose installed
# Clone the repository
git clone https://github.com/chethanmp6/schoolprincipal.git
cd schoolprincipal
# Start the application
docker-compose up -d
# The application will be available at http://localhost:8000# Use the development helper script
chmod +x scripts/docker-dev.sh
# Build the application
./scripts/docker-dev.sh build
# Start the application
./scripts/docker-dev.sh up
# View logs
./scripts/docker-dev.sh logs
# Stop the application
./scripts/docker-dev.sh down
# Clean rebuild
./scripts/docker-dev.sh rebuild- Python 3.8+
- pip package manager
git clone https://github.com/chethanmp6/schoolprincipal.git
cd schoolprincipal
pip install -r requirements.txt# Create .env file with your configuration
JWT_SECRET_KEY=your-super-secret-jwt-key-change-this-in-production
DATABASE_URL=sqlite:///data/school.dbNote: FastAPI automatically handles development mode and debug settings through uvicorn, so no additional environment variables are needed for development.
python scripts/seed_data.pypython main.pyThe application will be available at http://localhost:8000
FastAPI Features:
- Interactive API Documentation: Available at
http://localhost:8000/docs - ReDoc Documentation: Available at
http://localhost:8000/redoc - High Performance: Async support and automatic validation
- Type Safety: Pydantic models for request/response validation
After running the seed script, you can use these credentials:
- Email: john.johnson@email.com, Password: password123 (Student ID: 12345)
- Email: mary.wilson@email.com, Password: password123 (Student ID: 12346)
- Email: james.davis@email.com, Password: password123 (Student ID: 12347)
- Email: linda.brown@email.com, Password: password123 (Student ID: 12348)
- Email: carlos.garcia@email.com, Password: password123 (Student ID: 12349)
- Parents log in with their registered email and password
- System creates a secure chat session
- Parents provide student ID for verification
- Chatbot provides personalized responses
- Attendance: "Show me attendance for this month"
- Grades: "What are the latest test scores?"
- Schedule: "What's the class schedule for today?"
- Teachers: "Who is the math teacher?"
- School Info: "What is the school's fee policy?"
POST /api/auth/login- Parent loginPOST /api/chat/session- Create chat session
GET /api/student/info- Get student detailsGET /api/student/attendance- Get attendance recordsGET /api/student/grades- Get academic performanceGET /api/student/schedule- Get class schedule
POST /api/chat/message- Send message to chatbot
- Password hashing with bcrypt
- JWT token-based authentication
- Rate limiting (5 login attempts per minute)
- Session-based chat management
- Input validation and sanitization
- Parents can only access their own child's data
- Student ID verification required
- Secure data storage and transmission
- Audit trail for all data access
- Graceful error responses
- Logging for security events
- Protection against common attacks
- Safe failure modes
- students: Student information and parent associations
- teachers: Teacher details and subject assignments
- attendance: Daily attendance records
- grades: Test scores and academic performance
- class_schedule: Timetables and room assignments
- parent_auth: Authentication and authorization
- chat_sessions: Conversation history and context
- Attendance Queries: Monthly statistics, absence tracking
- Academic Performance: Grades, averages, subject-wise performance
- Schedule Information: Class timetables, exam schedules
- Teacher Information: Contact details, subject mappings
- School Policies: Rules, fees, events, general information
- Structured markdown formatting
- Emoji indicators for better readability
- Tabular data for schedules and grades
- Contextual help and suggestions
- Error handling with helpful messages
SchoolPrincipal/
├── main.py # Main FastAPI application
├── Dockerfile # Docker image configuration
├── docker-compose.yml # Development Docker setup
├── docker-compose.prod.yml # Production Docker setup
├── nginx.conf # Nginx configuration for production
├── .dockerignore # Docker ignore file
├── models/
│ ├── database.py # Database models and operations
│ ├── schemas.py # Pydantic models for validation
│ └── __init__.py
├── auth/
│ ├── auth.py # Authentication utilities
│ └── __init__.py
├── chatbot/
│ ├── school_bot.py # Chatbot logic and NLP
│ └── __init__.py
├── templates/
│ └── index.html # Web interface
├── scripts/
│ ├── seed_data.py # Database seeding
│ ├── docker-entrypoint.sh # Docker startup script
│ ├── docker-dev.sh # Development helper script
│ └── __init__.py
├── data/ # SQLite database storage
├── requirements.txt # Python dependencies
├── .env # Environment variables
└── README.md
# Run the application in development mode
python main.py
# Test API endpoints
curl -X POST http://localhost:8000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "john.johnson@email.com", "password": "password123"}'
# Access interactive API documentation
# Open http://localhost:8000/docs in your browser
# Run tests
pytest# Build and start with Docker
docker-compose up -d
# View logs
docker-compose logs -f
# Run tests in container
docker-compose exec schoolbot pytest
# Access the application
# Open http://localhost:8000 in your browser# Quick start
docker-compose up -d
# With rebuild
docker-compose up -d --build
# Stop services
docker-compose down# Start production services
docker-compose -f docker-compose.prod.yml up -d
# Includes:
# - SchoolBot application
# - PostgreSQL database
# - Redis cache
# - Nginx reverse proxy- Multi-stage build: Optimized image size
- Non-root user: Enhanced security
- Health checks: Automatic service monitoring
- Volume persistence: Data survives container restarts
- Development tools: Helper scripts for common tasks
- Production ready: Nginx, PostgreSQL, Redis integration
- Fork the repository
- Create a feature branch
- Implement your changes
- Add tests for new functionality
- Submit a pull request
MIT License - see LICENSE file for details
For support and questions:
- Check the documentation above
- Review the code comments
- Create an issue in the repository
- Contact the development team
Note: This is a defensive security system designed to protect student data. All security measures should be regularly reviewed and updated according to current best practices.