Skip to content

Latest commit

 

History

History
315 lines (272 loc) · 11.1 KB

File metadata and controls

315 lines (272 loc) · 11.1 KB

Project Structure Overview

📁 Complete Directory Structure

aiprs/
│
├── database/                          # Database files
│   ├── schema.sql                    # Database schema (3NF normalized)
│   └── seed_data.sql                 # Sample test data
│
├── backend/                          # PHP Backend (Pure PHP + MySQLi)
│   │
│   ├── api/                          # REST API endpoints
│   │   ├── auth.php                  # Authentication (login, register, logout)
│   │   ├── courses.php               # Course CRUD operations
│   │   ├── enrollments.php           # Enrollment management
│   │   ├── recommendations.php       # AI recommendations
│   │   └── analytics.php             # Analytics and reporting
│   │
│   ├── config/                       # Configuration files
│   │   ├── database.php              # Database connection class
│   │   └── constants.php             # Application constants
│   │
│   ├── models/                       # Data models (CRUD)
│   │   ├── User.php                  # User management
│   │   ├── Course.php                # Course operations
│   │   ├── Module.php                # Module operations
│   │   ├── Lesson.php                # Lesson operations
│   │   ├── Enrollment.php            # Enrollment tracking
│   │   ├── Assignment.php            # Assignment management
│   │   ├── Submission.php            # Submission handling
│   │   ├── Quiz.php                  # Quiz operations
│   │   ├── Forum.php                 # Forum posts
│   │   ├── Notification.php          # Notifications
│   │   ├── Recommendation.php        # Recommendations storage
│   │   └── Analytics.php             # Analytics data
│   │
│   ├── controllers/                  # Business logic
│   │   ├── AuthController.php        # Authentication logic
│   │   └── RecommendationEngine.php  # AI recommendation algorithm
│   │
│   ├── includes/                     # Shared templates (future)
│   │
│   ├── uploads/                      # User uploads
│   │   ├── profiles/                 # Profile images
│   │   ├── assignments/              # Assignment files
│   │   ├── courses/                  # Course materials
│   │   └── lessons/                  # Lesson content
│   │
│   ├── reports/                      # Generated reports
│   │   └── .gitkeep
│   │
│   ├── logs/                         # Error and analytics logs
│   │   └── .gitkeep
│   │
│   └── .htaccess                     # Apache configuration
│
├── frontend/                         # React Frontend
│   │
│   ├── public/                       # Static files
│   │   ├── index.html                # HTML template
│   │   └── manifest.json             # PWA manifest
│   │
│   ├── src/                          # Source code
│   │   │
│   │   ├── components/               # Reusable components
│   │   │   └── Layout.js             # Main layout with navigation
│   │   │
│   │   ├── pages/                    # Page components
│   │   │   ├── Login.js              # Login page
│   │   │   ├── Register.js           # Registration page
│   │   │   │
│   │   │   ├── student/              # Student pages
│   │   │   │   ├── Dashboard.js      # Student dashboard
│   │   │   │   ├── Courses.js        # Course list
│   │   │   │   ├── CourseDetail.js   # Course details
│   │   │   │   ├── Assignments.js    # Assignments page
│   │   │   │   └── Quizzes.js        # Quizzes page
│   │   │   │
│   │   │   ├── teacher/              # Teacher pages
│   │   │   │   └── Dashboard.js      # Teacher dashboard
│   │   │   │
│   │   │   └── admin/                # Admin pages
│   │   │       └── Dashboard.js      # Admin dashboard
│   │   │
│   │   ├── context/                  # React Context
│   │   │   ├── AuthContext.js        # Authentication state
│   │   │   ├── ThemeContext.js       # Theme (dark/light)
│   │   │   └── LanguageContext.js    # Multi-language support
│   │   │
│   │   ├── hooks/                    # Custom hooks (future)
│   │   │
│   │   ├── utils/                    # Utility functions
│   │   │   └── translations.js       # Language translations
│   │   │
│   │   ├── assets/                   # Images, icons (future)
│   │   │
│   │   ├── App.js                    # Main app component
│   │   ├── index.js                  # Entry point
│   │   └── index.css                 # Global styles
│   │
│   ├── package.json                  # Dependencies
│   └── package-lock.json             # Lock file
│
├── .gitignore                        # Git ignore rules
├── README.md                         # Complete documentation
├── QUICKSTART.md                     # Quick start guide
└── PROJECT_STRUCTURE.md              # This file

🔑 Key Components

Backend Architecture

Models (Data Layer)

  • Purpose: Handle database operations (CRUD)
  • Pattern: Each model represents a database table
  • Features: Prepared statements, input validation, error handling

Controllers (Business Logic)

  • AuthController: User authentication, session management
  • RecommendationEngine: AI-powered learning recommendations

API Endpoints (Interface)

  • RESTful design: GET, POST, PUT, DELETE
  • JSON responses: Consistent format
  • CORS enabled: Cross-origin requests

Frontend Architecture

Context Providers

  • AuthContext: User authentication state
  • ThemeContext: Dark/Light mode theming
  • LanguageContext: Multi-language support

Page Structure

  • Public pages: Login, Register
  • Student pages: Dashboard, Courses, Assignments, Quizzes
  • Teacher pages: Dashboard, Course management
  • Admin pages: Dashboard, User management, Analytics

Component Patterns

  • Layout: Consistent navigation and theming
  • Protected Routes: Role-based access control
  • Material UI: Modern, responsive components

📊 Database Schema

Core Tables

  1. users: User accounts (students, teachers, admins)
  2. courses: Course catalog
  3. modules: Course modules
  4. lessons: Individual lessons
  5. enrollments: Student-course relationships

Assessment Tables

  1. assignments: Assignment definitions
  2. submissions: Student submissions
  3. quizzes: Quiz definitions
  4. questions: Quiz questions
  5. quiz_attempts: Quiz attempts and scores

Engagement Tables

  1. forum_posts: Discussion forum
  2. recommendations: AI recommendations
  3. notifications: User notifications
  4. analytics_logs: Activity tracking

🔄 Data Flow

Student Learning Flow

1. Login → AuthContext → Protected Route
2. View Courses → API → Course Model → Database
3. Enroll → Enrollment Model → Update Database
4. Complete Lesson → Lesson Model → Update Progress
5. Take Quiz → Quiz Model → Record Attempt
6. Get Recommendations → RecommendationEngine → AI Logic

Teacher Grading Flow

1. Login → AuthContext → Teacher Dashboard
2. View Submissions → Submission Model → Database
3. Grade Assignment → Update Submission
4. Post Feedback → Notification Model → Notify Student

Admin Analytics Flow

1. Login → AuthContext → Admin Dashboard
2. View Analytics → Analytics Model → Aggregate Data
3. Generate Report → Report Controller → CSV/PDF
4. Manage Users → User Model → CRUD Operations

🎨 UI/UX Design Patterns

Material UI Components Used

  • Layout: AppBar, Drawer, Toolbar
  • Data Display: Card, Table, List, Chip
  • Input: TextField, Button, Select, Checkbox
  • Feedback: Alert, Snackbar, CircularProgress
  • Navigation: Tabs, Menu, Breadcrumbs
  • Charts: Recharts (LineChart, BarChart)

Responsive Breakpoints

  • xs: < 600px (mobile)
  • sm: 600px - 960px (tablet)
  • md: 960px - 1280px (desktop)
  • lg: 1280px - 1920px (large desktop)

🔐 Security Layers

Backend Security

  1. Authentication: password_hash, password_verify
  2. Session Management: Secure session handling
  3. Input Validation: filter_var, htmlspecialchars
  4. SQL Injection Prevention: Prepared statements
  5. File Upload Security: MIME validation, size limits
  6. RBAC: Role-based access control

Frontend Security

  1. Protected Routes: Route guards
  2. Form Validation: Client-side checks
  3. XSS Prevention: React auto-escaping
  4. HTTPS: Production deployment
  5. Token Storage: Secure cookie handling

📈 Scalability Considerations

Current Implementation

  • Single server architecture
  • File-based uploads
  • Session-based authentication

Future Enhancements

  • Load balancing
  • CDN for static assets
  • JWT token authentication
  • Microservices architecture
  • Caching layer (Redis)
  • Message queue (RabbitMQ)
  • Containerization (Docker)

🧪 Testing Strategy

Unit Tests

  • Model functions
  • Controller logic
  • Utility functions

Integration Tests

  • API endpoints
  • Database operations
  • Authentication flow

E2E Tests

  • User workflows
  • Multi-page interactions
  • Role-based scenarios

📦 Deployment Checklist

Backend

  • Update database credentials
  • Configure production paths
  • Enable error logging
  • Set file permissions
  • Configure CORS properly
  • Enable HTTPS
  • Optimize PHP settings

Frontend

  • Update API base URL
  • Run production build
  • Optimize assets
  • Configure CDN
  • Set up monitoring
  • Enable analytics
  • Test all routes

🔍 Code Navigation Tips

Finding Features

  • Authentication: backend/controllers/AuthController.php
  • Recommendations: backend/controllers/RecommendationEngine.php
  • Student Dashboard: frontend/src/pages/student/Dashboard.js
  • API Endpoints: backend/api/*.php
  • Database Models: backend/models/*.php

Modifying UI

  • Colors/Theme: frontend/src/context/ThemeContext.js
  • Translations: frontend/src/utils/translations.js
  • Layout: frontend/src/components/Layout.js
  • Routes: frontend/src/App.js

Adding Features

  1. Create model in backend/models/
  2. Add API endpoint in backend/api/
  3. Create frontend page in frontend/src/pages/
  4. Add route in App.js
  5. Update navigation in Layout.js

📚 Additional Resources


This structure supports a modular, maintainable, and scalable learning platform.