Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Fireinthebellyy/ftb-web/llms.txt
Use this file to discover all available pages before exploring further.
Overview
FTB Hustle is built on Next.js 15 with the App Router, leveraging React Server Components for optimal performance. The architecture follows modern web development best practices with clear separation of concerns.Tech Stack Summary
- Framework: Next.js 15 (App Router)
- Language: TypeScript 5
- Database: PostgreSQL with Drizzle ORM
- Authentication: Better Auth
- Styling: Tailwind CSS 4
- UI Components: Radix UI primitives
Project Structure
Application Layers
1. Presentation Layer (App Router)
Theapp/ directory contains all pages and layouts using Next.js App Router:
- Route Groups: Auth-related pages use route groups for shared layouts
- Server Components: Default rendering strategy for better performance
- Client Components: Interactive components marked with
"use client" - API Routes: RESTful endpoints in
app/api/
| Route | Purpose | Protected |
|---|---|---|
/ | Homepage | No |
/login, /signup | Authentication | No |
/opportunities | Browse opportunities | Yes |
/opportunities/[id] | Opportunity details | Yes |
/internships | Internship listings | Yes |
/toolkit | Resource center | Yes |
/tracker | Application tracker | Yes |
/profile | User profile | Yes |
2. Data Layer (Database)
Database Architecture:- ORM: Drizzle ORM for type-safe database operations
- Database: PostgreSQL (Neon serverless)
- Connection: Dual drivers (HTTP for queries, WebSocket for transactions)
lib/db.ts):
lib/schema.ts):
- User tables (users, accounts, sessions)
- Opportunity tables (opportunities, applications, comments)
- Internship tables (internships, saved internships)
- Toolkit tables (toolkits, resources)
- Tracker tables (applications, tasks)
- Organized query functions in
lib/queries.tsand feature-specific query files - Use of React Query (@tanstack/react-query) for client-side state management
- Server Actions for mutations
3. Authentication Layer
Better Auth Configuration (lib/auth.ts):
- Session Management: Cookie-based sessions via
nextCookies()plugin - Email/Password: Email verification with Resend
- Social OAuth: Google and LinkedIn integration
- Database Adapter: Drizzle adapter for user storage
- Role-Based Access: Custom user roles (user, member, admin)
middleware.ts):
4. Payment Layer
Razorpay Integration (lib/razorpay.ts):
- Order creation for premium features
- Payment verification
- Webhook handling for payment events
5. File Storage Layer
Appwrite Configuration (lib/appwrite.ts):
- User avatar storage
- Opportunity document uploads
- Resume/CV storage
- Image optimization
6. UI Component Layer
Component Organization:- Base Components (
components/ui/): Radix UI primitives wrapped with Tailwind styles - Feature Components: Domain-specific components (auth, opportunity, toolkit)
- Layout Components: Navbar, Footer, BottomNav
- Form Components: React Hook Form with Zod validation
- Tailwind CSS 4 with custom configuration
- Class variance authority (CVA) for component variants
cn()utility for conditional classes- Dark mode support via
next-themes
Data Flow
Server-Side Rendering (SSR)
- User requests a page
- Next.js middleware checks authentication
- Server Component fetches data from database
- Page renders on server with data
- HTML sent to client with minimal JavaScript
Client-Side Interactions
- User interacts with Client Component
- React Query manages cache and refetching
- Server Actions handle mutations
- Optimistic updates provide instant feedback
- Background revalidation ensures data freshness
API Architecture
API routes inapp/api/ follow RESTful conventions:
- GET: Fetch resources
- POST: Create resources
- PATCH: Update resources
- DELETE: Remove resources
/api/opportunities- Opportunity CRUD/api/internships- Internship data/api/tracker- Application tracking/api/toolkits- Resource management/api/profile- User profile updates/api/auth/*- Better Auth endpoints
Security Considerations
- Authentication: Session-based auth with HTTP-only cookies
- Authorization: Role-based access control (RBAC)
- Input Validation: Zod schemas for all user input
- SQL Injection: Prevented by Drizzle ORM’s parameterized queries
- XSS Protection: React’s built-in escaping + DOMPurify for rich text
- CSRF: Next.js CSRF protection in Server Actions
- Environment Variables: Sensitive data in
.env.local(never committed)
Performance Optimizations
- Turbopack: Fast development builds
- Image Optimization:
next/imagewith remote patterns - Font Optimization:
next/fontfor web font loading - Code Splitting: Automatic with App Router
- React Server Components: Reduced client-side JavaScript
- Database Connection Pooling: Neon serverless with connection pooling
- Query Caching: React Query for client-side caching
Error Handling
- Error Boundaries:
error.tsxfiles for graceful error UI - API Errors: Structured error responses with status codes
- Database Errors: Try-catch blocks with fallback values
- Form Validation: Client-side and server-side validation with Zod
- Toast Notifications: User feedback via Sonner
Next Steps
- Explore the Tech Stack for detailed dependency information
- Review Local Setup for development environment configuration
- Check the API Reference for endpoint documentation