Home / Companies / Convex / Blog / January 2023

January 2023 Summaries

9 posts from Convex

Filter
Month: Year:
Post Summaries Back to Blog
Building a multiplayer game using Convex involves utilizing its features like reactive queries, transactional mutations, and backend storage to simplify synchronization logic and event systems. The game developed involves players generating an image with a prompt through Dall-E 2 by OpenAI, while others submit alternative prompts to guess the original. Points are awarded based on the accuracy of the guesses. The development process includes sketching a UX prototype, validating technical challenges, outlining game actions and states, and modeling server data. A low-fidelity prototyping approach is emphasized to focus on core functionality rather than aesthetics, using tools like Keynote for rapid iterations. The project also highlights the integration of serverless functions with zod validation, managing asynchronous tasks via scheduled jobs, and maintaining type consistency across client and server with TypeScript. The process promotes rapid development and iteration, leveraging Convex's capabilities to support the backend requirements of a scalable full-stack AI project.
Jan 31, 2023 1,386 words in the original blog post.
The blog post discusses how to build a chat application using Convex and the OpenAI API to generate images with Dall-E based on user-provided prompts. It outlines the process of setting up a Convex app and configuring the OpenAI client, including generating an API key and storing it in Convex's environment variables. The application uses OpenAI's Moderation API to ensure prompts are not offensive and generates images that are then stored in Convex File Storage for long-term access. The stored images are embedded in chat messages by converting storage IDs into URLs that can be used in <img> tags. The post highlights the importance of handling slow API response times by implementing loading indicators for a better user experience and provides insights into using Convex's functions to manage serverless operations efficiently.
Jan 31, 2023 1,500 words in the original blog post.
In a reflective and somewhat satirical narrative, Jamie Turner recounts the early 2010s enthusiasm for NoSQL databases like MongoDB, contrasting it with the enduring challenges and limitations of SQL, particularly in handling data relationships, transaction complexity, and read efficiency. Turner argues that while the initial NoSQL movement failed due to immature implementations, it highlighted developers' desire for more flexible data models that SQL could not provide. He critiques SQL's rigid data structures, cumbersome transaction processes, and unpredictable read performance, advocating for modern databases that integrate application and database types, such as Convex, which promises seamless, developer-friendly data handling without SQL's drawbacks. The narrative underscores the need for databases that align with contemporary programming models, emphasizing typed, relational documents and efficient, conflict-free transactions.
Jan 29, 2023 3,265 words in the original blog post.
Ian Macartney's post delves into implementing session storage in Convex, focusing on using sessions as a form of middleware to enhance user experiences in serverless applications. It discusses how session tracking is essential for managing data specific to user tabs or anonymous users, which is particularly useful in multiplayer experiences where logging in might not be required. The post introduces a series of helper functions and wrappers designed to facilitate the use of session-specific data, stored in a "sessions" table within the Convex backend, and accessible via custom hooks like useSessionQuery or useSessionMutation in React clients. Additionally, it explores the advantages of using sessionStorage versus localStorage, emphasizing the importance of session management on both the client and server sides to ensure seamless user interactions across multiple tabs and sessions. The article invites developers to explore Convex's capabilities for building scalable and efficient full-stack applications by providing resources and links for further reading and implementation strategies.
Jan 27, 2023 1,193 words in the original blog post.
Ian Macartney discusses the importance of function validation in production applications and introduces the use of the Zod library for input validation in Convex functions. The article highlights the limitations of relying solely on TypeScript for type enforcement, as it only aids in static analysis and not at runtime. To address this, Macartney explores how input validation can be enhanced with Zod, allowing developers to define expected types and ensure that inputs are validated before being processed by the server. He introduces a custom "withZod" wrapper to facilitate the integration of Zod into Convex functions, reducing the need for duplicate code and improving the safety of function arguments. The post emphasizes the seamless integration of Zod with TypeScript, ensuring end-to-end type safety from the data model to the client, and provides examples of how developers can implement these techniques in their projects.
Jan 24, 2023 1,430 words in the original blog post.
In a humorous take on the evolution of tech terminology, the text discusses a playful middleware concept called "Edge-to-Butt," inspired by a previous Chrome extension that replaced the term "cloud" with "butt" to mock the overuse of buzzwords. The author expresses a satirical nostalgia and parallels this to the current tech industry's fascination with "the edge," proposing a similar replacement to inject humor into Convex projects. The text details a JavaScript function that recursively finds and replaces occurrences of "edge" with "butt" in a manner that preserves case, aiming to both poke fun at and manage the hype surrounding "edge computing." The idea is presented as a light-hearted enhancement for Convex, a backend platform, to integrate this playful transformation into its query functions, showcasing the author's whimsical perspective on tech jargon while emphasizing Convex's capabilities in building scalable full-stack AI projects.
Jan 21, 2023 1,018 words in the original blog post.
Ian Macartney introduces a pattern for structuring Convex code that functions similarly to middleware by adding functionality before or after a request, but with more explicit and granular control. This approach, exemplified by the `withUser` function, aims to streamline authentication processes by wrapping functions to manage user identity checks, thereby reducing code repetition and enhancing code organization. Macartney demonstrates how this pattern can be composed with other functions, such as `withTeamAdmin`, to ensure specific user roles before executing certain actions, promoting a more modular and maintainable code structure. While acknowledging potential complexity, he argues that these wrappers offer significant advantages in controlling function behavior and maintaining a clean, concise codebase, and he encourages developers to explore these patterns to enhance their Convex projects, which include cloud functions and other backend services.
Jan 20, 2023 1,466 words in the original blog post.
In the exploration of data modeling patterns for implementing a voting feature in a sample app, the author experimented with various strategies to understand the tradeoffs of different data models. Using the Convex platform, which simplifies database structure iteration, the author began with a basic counter-based model to track votes for topics, such as quotes, but found it limited in functionality for features like user-specific voting history. This led to the exploration of three alternative models: storing user lists on each topic, storing topic lists on each user, and creating a separate votes table to manage user-topic relationships. Each model presented unique advantages and challenges, such as ease of vote counting, scalability limits, and suitability for different use cases like user-centered features or handling multiple vote types. The separate votes table model emerged as versatile, supporting various functionalities without technical limitations on user votes. This hands-on approach highlighted the importance of aligning data models with specific application requirements and potential scalability considerations.
Jan 11, 2023 4,221 words in the original blog post.
Ian Macartney discusses implementing user presence features in web applications using Convex, an accessible backend platform that facilitates real-time data updates through WebSocket reactivity and caching scalability. Presence, as defined in the post, enhances user experience by displaying the activity of other users, such as online status or cursor movements, and is illustrated through practical examples like typing indicators and facepiles. Macartney introduces utilities like the `usePresence` React hook to manage presence data effectively, highlighting how it allows partial updates and session state management. The post emphasizes the importance of efficiently handling presence data to maintain UI performance, suggesting techniques such as single-flighting for latency management, heartbeat messages for online detection, and cursor positioning for collaborative text editing. The writing underscores the social and functional benefits of implementing presence, noting that Convex's infrastructure simplifies the integration of these features, offering developers tools to build and scale their applications seamlessly.
Jan 10, 2023 1,815 words in the original blog post.