Wesley Ajavon

How I Built YouCode — A Modern, AI-Driven Learning Platform
1 - Introduction
What is YouCode?
YouCode is the project where I explore how modern web technologies and AI can reshape the way we learn and create. What began as a simple idea has grown into a complete learning management system powered by AI-assisted lesson generation, structured course spaces, and a smooth experience for both students and administrators. This article walks through how the platform works today, the architecture behind it, and the principles that guide its evolution.
YouCode is my modern learning environment: a complete LMS where I can create courses, generate AI-assisted lessons, and track learner progress across dedicated student and admin dashboards. Its dual identity—education at the core, enhanced by AI—has guided every design and technical decision.
A meaningful lesson learned from this project or a quote from someone you worked with.
2 - The Technical Stack
I built YouCode with Next.js and TypeScript to combine hybrid rendering with type-safe development, using Tailwind CSS for clean, responsive UI components.
Prisma interfaces with PostgreSQL, while AI capabilities run through the Groq API (Llama 3, Mixtral). Around that, I integrated a Node.js foundation with Redis caching, Upstash rate limiting, and NextAuth to orchestrate authentication across the entire system.



3 - Architecture
Frontend Experience
On the UI side, YouCode uses the Next.js App Router to clearly separate admin, user, and public layouts, each with its own middleware and component structure. Critical pages benefit from SSR/ISR, while client components—modals, Markdown editors, SmartChat widgets—handle live interactions stored in src/components.
AI & SmartChat

The SmartChat module relies on two main routes, /api/ai/context and /api/ai/assistant, which extract browser context, cache it via Redis, and orchestrate the AI response pipeline. A caching middleware and success-rate monitor supervise operations in real time. The lesson generator builds on /api/admin/courses/[courseId]/lessons/generate, where I customize Groq prompts before launching the Markdown editor with the model’s output.
Data & Services
All writes go through Prisma (src/lib/prisma.ts) and dedicated query layers in src/lib/queries. Authentication and role logic are centralized in src/lib/auth.ts, while caching (contexts, courses, user preferences) is handled by src/lib/cache.ts and cache-middleware.ts.
This modularity lets me combine event-driven invalidations, scheduled expirations, and role-specific caching strategies.
4 - Challenge
One of the biggest hurdles was learning how to correctly balance server components and client components in Next.js. Since YouCode is my first large Next.js project, understanding when logic belongs on the server, when it should move to the client, and how both layers communicate took real experimentation. Features like SmartChat, Markdown editing, and role-based routing forced me to rethink old habits from traditional React development. Choosing the wrong side often caused hydration mismatches, broken states, or unnecessary client-side complexity—and I had to refactor several modules to align with the framework’s best practices.
Beyond the framework learning curve, synchronizing AI flows with human interactions introduced a second major challenge. When lesson generation takes time, the UI must stay consistent, retry failed requests intelligently, respect rate limits, and enforce access control. I addressed this with batching strategies, UX-level alerts, and detailed instrumentation around Groq and Upstash operations to ensure everything feels responsive even under load.
5 - Database
The PostgreSQL schema revolves around users, roles, courses, lessons, and SmartChat history. Successive migrations (role tables, lesson cascade deletes, cleanup of nested elements) ensure that deleting a course automatically purges related lessons and user progress.
Targeted indexing keeps search performance high when querying session history or archived content.
6 - Security
Access control is powered by NextAuth: only ADMIN users can reach editing routes or AI generation tools, while students are restricted to their assigned content.
Every endpoint is validated with Zod, secrets are isolated in environment variables, and both global and role-based rate limits prevent overload—especially around SmartChat and content generation.
7 - Deployment & Infrastructure

I deploy the Next.js interface on Vercel to leverage automatic optimizations, while hosting the API, Redis, and PostgreSQL on managed services (Railway and Upstash) for continuous metrics and observability. PNPM scripts cover local development, cache/rate-limit testing, and predictable production deployments.
Lessons Learned

Misplacing logic between server and client components can break a whole feature; understanding that boundary became a turning point in YouCode’s design.
These insights pushed me to document each layer so the platform is reproducible, debuggable, and easy to maintain.
Conclusion
YouCode has grown into a full LMS backed by a reliable AI assistant and a robust cache/rate-limiting architecture. By sharing these design choices, I want to show that educational storytelling and technical rigor can coexist—and form a solid foundation for everything that comes next.
Wesley Ajavon
wesleyajavon2203@hotmail.com



Wesley Ajavon

How I Built YouCode — A Modern, AI-Driven Learning Platform
1 - Introduction
YouCode is the project where I explore how modern web technologies and AI can reshape the way we learn and create. What began as a simple idea has grown into a complete learning management system powered by AI-assisted lesson generation, structured course spaces, and a smooth experience for both students and administrators. This article walks through how the platform works today, the architecture behind it, and the principles that guide its evolution.
What is YouCode?
YouCode is my modern learning environment: a complete LMS where I can create courses, generate AI-assisted lessons, and track learner progress across dedicated student and admin dashboards. Its dual identity—education at the core, enhanced by AI—has guided every design and technical decision.
A meaningful lesson learned from this project or a quote from someone you worked with.
2 - The Technical Stack
I built YouCode with Next.js and TypeScript to combine hybrid rendering with type-safe development, using Tailwind CSS for clean, responsive UI components. Prisma interfaces with PostgreSQL, while AI capabilities run through the Groq API (Llama 3, Mixtral). Around that, I integrated a Node.js foundation with Redis caching, Upstash rate limiting, and NextAuth to orchestrate authentication across the entire system.



3 - Architecture
Frontend Experience
On the UI side, YouCode uses the Next.js App Router to clearly separate admin, user, and public layouts, each with its own middleware and component structure. Critical pages benefit from SSR/ISR, while client components—modals, Markdown editors, SmartChat widgets—handle live interactions stored in src/components.
AI & SmartChat

The SmartChat module relies on two main routes, /api/ai/context and /api/ai/assistant, which extract browser context, cache it via Redis, and orchestrate the AI response pipeline. A caching middleware and success-rate monitor supervise operations in real time. The lesson generator builds on /api/admin/courses/[courseId]/lessons/generate, where I customize Groq prompts before launching the Markdown editor with the model’s output.
Data & Services
All writes go through Prisma (src/lib/prisma.ts) and dedicated query layers in src/lib/queries. Authentication and role logic are centralized in src/lib/auth.ts, while caching (contexts, courses, user preferences) is handled by src/lib/cache.ts and cache-middleware.ts. This modularity lets me combine event-driven invalidations, scheduled expirations, and role-specific caching strategies.
4 - Challenge
One of the biggest hurdles was learning how to correctly balance server components and client components in Next.js. Since YouCode is my first large Next.js project, understanding when logic belongs on the server, when it should move to the client, and how both layers communicate took real experimentation. Features like SmartChat, Markdown editing, and role-based routing forced me to rethink old habits from traditional React development. Choosing the wrong side often caused hydration mismatches, broken states, or unnecessary client-side complexity—and I had to refactor several modules to align with the framework’s best practices.
Beyond the framework learning curve, synchronizing AI flows with human interactions introduced a second major challenge. When lesson generation takes time, the UI must stay consistent, retry failed requests intelligently, respect rate limits, and enforce access control. I addressed this with batching strategies, UX-level alerts, and detailed instrumentation around Groq and Upstash operations to ensure everything feels responsive even under load.
5 - Database
The PostgreSQL schema revolves around users, roles, courses, lessons, and SmartChat history. Successive migrations (role tables, lesson cascade deletes, cleanup of nested elements) ensure that deleting a course automatically purges related lessons and user progress.
Targeted indexing keeps search performance high when querying session history or archived content.
6 - Security
Access control is powered by NextAuth: only ADMIN users can reach editing routes or AI generation tools, while students are restricted to their assigned content.
Every endpoint is validated with Zod, secrets are isolated in environment variables, and both global and role-based rate limits prevent overload—especially around SmartChat and content generation.
7 - Deployment & Infrastructure

I deploy the Next.js interface on Vercel to leverage automatic optimizations, while hosting the API, Redis, and PostgreSQL on managed services (Railway and Upstash) for continuous metrics and observability. PNPM scripts cover local development, cache/rate-limit testing, and predictable production deployments.
Lessons Learned
Misplacing logic between server and client components can break a whole feature; understanding that boundary became a turning point in YouCode’s design.
These insights pushed me to document each layer so the platform is reproducible, debuggable, and easy to maintain.
Conclusion
YouCode has grown into a full LMS backed by a reliable AI assistant and a robust cache/rate-limiting architecture. By sharing these design choices, I want to show that educational storytelling and technical rigor can coexist—and form a solid foundation for everything that comes next.
Wesley Ajavon
wesleyajavon2203@hotmail.com
864-563-3182



