How glenngenre/codecraft works
Project Type and Purpose
• This is a full-stack, cross-platform (mobile + web) Flutter application named “codecraft.”
• It serves as an educational coding platform with two user roles: apprentices (learners) and mentors (instructors).
• The client is built in Flutter (Dart) and leverages Firebase services (Authentication, Firestore, Cloud Functions, Cloud Messaging) plus a possible external code-execution API.
Top-Level Architectural Components
a. Client (Flutter App)
• Platforms: Android, iOS (android/…), Web (web/…)
• Presentation Layer: Screens (lib/screens/…), Widgets (lib/widgets/…)
• State Management: Provider package (lib/providers/…)
• Business Logic Services: (lib/services/…) – e.g. AuthHelper, ChallengeService, CodeClashService, QuizService, SubmissionService
• Models: Domain objects (lib/models/…)
• Utilities & I/O Abstractions: FileIO, WebIO (lib/io/…), Utils (lib/utils/…)
• Parser: HTML parser for static pages (lib/parser/…)
• Assets: Animations, videos, quizzes, markdown pages (assets/…)
b. Backend (Firebase + Serverless)
• Authentication: Email/password/Google via Firebase Auth
• Database: Firestore (collections for users, challenges, quizzes, codeClashes, submissions, organisations)
• Cloud Functions (functions/index.js): Hosted JS functions for business-critical operations (e.g. invite workflow, leaderboard calculations, code clash matchmaking)
• Security & Indexes: firestore.rules, firestore.indexes.json
• Hosting & Messaging: Web static assets + firebase-messaging-sw.js
c. External Services
• (Optional) Third-party code execution engine (invoked via CodeExecutionProvider or via a Cloud Function)
• Analytics / Crashlytics (configured in firebase.json / google-services.json)
Relationships and Data Flows
• The Flutter UI dispatches user actions to Provider controllers → calls Service layer → interacts with Firebase Auth / Firestore SDK or invokes Cloud Functions endpoints.
• Firestore triggers can invoke Cloud Functions for side-effects or data aggregation.
• Cloud Functions may coordinate with external code execution APIs and persist results back to Firestore.
• Real-time updates: Firestore snapshot listeners push live data to Providers → update UI.
• Static assets (animations, quizzes, pages) are bundled in the app or fetched via HTTP from hosting.
Architectural Patterns & Design Principles
• Layered architecture:
• Presentation (Screens & Widgets)
• State Management (Providers)
• Services/Repositories (data access, business logic)
• Data Layer (Firestore, Cloud Functions, external APIs)
• Dependency injection via provider package.
• MVVM-style separation of UI and view logic.
• Serverless microservices (each Cloud Function as a micro-endpoint).
• Assets-first: markdown pages + JSON-driven content parsed at runtime.