How contacthachami/2pi_teacher_dashboard works
Project type and purpose
• This is a full-stack web application (“2pi Dashboard”) that provides teachers with an interactive math quiz platform.
• Frontend: React-based SPA (Vite, TailwindCSS, React Context, React Router).
• Backend: Laravel REST API (Eloquent models, controllers, Sanctum authentication).
File structure
• Top-level directories:
• FrontEnd/ — React project directories (public, src/components, src/context, src/services, src/hooks, src/pages, src/translations)
• BackEnd/ — Laravel project directories (app/Http/Controllers, app/Models, config/, database/migrations & seeders, routes/, resources/, storage/)
• Patterns:
• Backend uses MVC: Controllers ←→ Models → Database (migrations/seeders).
• Frontend uses component-based UI + Context providers for cross-cutting state (Auth, Theme, Language, Notifications, Loading).
• RESTful routes (api.php) exposed by Laravel, consumed via Axios in src/services/api.js.
• Config & deployment: .env.example files, webpack/Vite config (vite.config.js), Tailwind configuration, public/index.html (FE), public/index.php (BE).
README for additional insights
• Key features: Quiz creation, levels, question types, progress tracking, internationalization, theming.
• Tech stack details: React18, Vite6, Laravel, Sanctum, MySQL/PostgreSQL.
• Data flows: Auth flow, quiz creation flow, management flow, user settings flow.
a. Main components
• Frontend SPA (React app hosted via Vite/public)
• API Gateway (Laravel controllers exposed under /api)
• Business Logic (Laravel services, Controllers)
• Data Layer (Eloquent Models → MySQL/PostgreSQL)
• Stateless Auth (Sanctum issuing & validating tokens)
• Storage (Laravel storage/app for assets, logs)
• External Services (SMTP for password reset emails, optional analytics/monitoring)
b. Relationships & interactions
• Browser → React SPA → Axios HTTP calls → Laravel API
• API Controllers → Eloquent Models → Database
• AuthContext in front → /api/login, /api/register, token storage in localStorage → subsequent API calls with Bearer token
• Quiz flows: Create/Read/Update/Delete via POST/GET/DELETE endpoints
• Notification flow: Polling or push via GET/POST notification endpoints
c. Architectural patterns & principles
• Separation of concerns: Presentation (React components) vs. API (Laravel controllers) vs. Data (models & migrations)
• Component-based UI + Context for global state
• RESTful design for CRUD operations
• MVC on backend, SPA on frontend
• Environment-driven configuration (.env)
d. Relevant technologies/frameworks
• Frontend: React, Vite, TailwindCSS, Axios, React Router, Zod, react-hot-toast, framer-motion
• Backend: Laravel, Sanctum, Eloquent ORM, MySQL/PostgreSQL, PHPUnit for tests, Mailer for emails