How ankitsaha00/bhasha works
Main Components
• Frontend Layer:
• The app directory is split into multiple segments:
• (marketing): For public-facing pages such as the header, footer, and basic marketing layout.
• (main): The main application for logged-in users that includes courses, learning, quests, leaderboard, and shop.
• (admin): A dedicated admin section that contains pages to create, edit, and list challenges, courses, lessons, and units.
• Additional routes: “lesson” folders for detailed lesson views.
• API Layer:
• Under app/api, there are separate endpoints for challenges, challengeOptions, courses, lessons, and units. These endpoints encapsulate the back-end business logic for handling CRUD operations and other interactions.
• Actions & State Management:
• The “actions” folder contains functions (e.g., challenge-progress.ts and user-progress.ts) that likely trigger state updates or API calls.
• The “store” directory manages UI states for modal components (exit, hearts, and practice modals).
• Database & Data Layer:
• The “db” folder alongside files like drizzle.config.ts and schema/queries show that the project uses drizzle ORM for managing database state.
• Utility & Library Modules:
• The “lib” folder includes helper files for admin operations, Stripe integration, and other utilities.
• Components & UI:
• A large “components” folder contains reusable UI components (such as custom-loading, feeds, sidebars, modal dialogs, and UI primitives) that are likely tied to shadcn/ui and Tailwind CSS.
Relationships and Data Flow
• Users interact with the Frontend via different routes:
• Marketing pages for brand introduction.
• Main app pages for learning, course management, quests, and shop functions.
• Lesson pages that provide a dedicated view for interactive lessons.
• Admin pages that allow content editors/administrators to manage challenges and courses.
• Frontend-to-API Communication:
• Frontend components (buttons, lists, cards, etc.) make requests to the corresponding API endpoints (located in app/api/*) to fetch or update data (courses, challenges, lessons, units).
• API-to-Database Interaction:
• The API routes interact with the database using drizzle (as seen in the “db” directory) for data persistence.
• External Integrations:
• Authentication is managed via Clerk.
• Payment or subscription features might be managed via Stripe (lib/stripe.ts).
• Modular Actions & State:
• “Actions” scripts are used to update challenge and user progress.
• “Store” files hold state information for various modal dialogs and UI feedback components.
Architectural Patterns & Design Principles
• Next.js Routing and App Folder Structure:
• The project leverages Next.js’s file-based routing with segmented folders (for marketing, main, admin, lesson, etc.) which helps in separating concerns among different user flows.
• Separation of Concerns:
• UI components, business logic (API endpoints and actions), and data access (database schema and queries) are neatly separated.
• Micro-Organized Modules:
• Different features (e.g., courses, lessons, challenges) have their own subdirectories under both the app and admin sections, indicating a modular organization.