How matttrann/ndis_web_application works
Main Components
• Frontend – Represented by the Next.js “app” directory. This includes UI pages, layouts (separated into public parts such as marketing and docs, protected parts such as dashboards, and authentication screens). Also include static assets (in assets and public folders) and components that manage presentation and user interaction.
• Backend/API – Captured under “app/api” where various endpoints are defined (for admin-client management, authentication, story generation, video requests, webhooks for Stripe etc.). The “lib” folder also includes shared utilities, services (for video generation, database, session management, and Stripe integrations), and custom validations.
• Database – Shown by the “prisma” directory and associated migrations. It uses PostgreSQL (as indicated by the requirements in the README) to store user data, subscriptions, questionnaires, video request information, etc.
• External Services –
◦ Authentication providers (Google OAuth, GitHub OAuth) integrated in NextAuth.
◦ Payment gateway (Stripe) with API keys and webhooks (endpoint at /api/webhooks/stripe).
◦ Video generation / AI services using Google TTS, AssemblyAI, and Replicate (referenced in environment variables and some actions).
◦ Email service via Resend (see the emails directory).
◦ AWS S3 and CloudFront for storage and CDN services.
• Mobile Components – There are “android” and “ios” directories indicating potential mobile app counterparts or hybrid approaches if relevant.
Relationships and Interactions
• The client (web browser or mobile app) interacts with the Next.js frontend.
• Frontend pages call backend API routes to handle user authentication, data retrieval, and actions such as updating user details or generating content.
• The server-side code interacts with the PostgreSQL database (mediated by Prisma) to store and retrieve persistent data.
• The backend also connects to external services:
◦ Authentication flows reach out to OAuth providers.
◦ Payment requests and subscriptions talk to Stripe, with asynchronous notifications via webhook endpoints.
◦ Video generation requests are passed to external AI services (Google TTS, AssemblyAI, Replicate).
◦ Email notifications are sent through the Resend API.
◦ Files (videos or images) are stored in AWS S3 and served via AWS CloudFront.
• The “remotion” code in the “src/remotion” folder indicates modules involved in video composition/rendering, which might integrate with the video-generation logic.
Key Architectural Patterns and Design Principles
• Modular Design and Separation of Concerns – with clear boundaries between frontend (UI), backend business logic, and integrations with external services.
• API-driven Architecture – Next.js API routes provide endpoints for actions and external webhooks for services like Stripe.
• Server-side rendering and dynamic routing using Next.js’s “app” directory structure.
• Use of a centralized database (PostgreSQL via Prisma) that supports multiple types of data (users, subscriptions, video requests, questionnaires).
• Extensive testing – the __tests__ folder indicates unit and integration tests for different functionalities (authentication, payments, UI components).
Relevant Technologies, Frameworks, and Libraries
• Next.js and React (with a modern “app” directory modular structure)
• Prisma for ORM and database migrations
• Jest and Cypress for testing
• Tailwind CSS for styling (tailwind.config.ts)
• External integrations: Stripe SDK, AWS SDK, OAuth SDKs, and external AI/ML APIs (Replicate, AssemblyAI, Google TTS)
• Remotion for video rendering
• Standard tools such as ESLint, Prettier, Husky for code quality and commit management
Attention to Detail
• External integrations and show configuration data paths (highlighting environment variables sourced from .env.example and the README prerequisite setup).