A full-stack referral and Q&A system built for events, featuring intelligent agents for automated question-answering and a comprehensive ranking system for referrals.
NLW Agents is a comprehensive platform that combines event registration with referral tracking and AI-powered Q&A functionality. Users can subscribe to events, invite others through referral links, and interact with AI agents to get answers to their questions.
- Event Subscription System - Register users for events with email validation
- Referral Program - Track invitations and maintain referral rankings
- AI-Powered Q&A - Create rooms for questions and get AI-generated responses
- Audio Recording - Record audio questions for enhanced interaction
- Real-time Ranking - Live leaderboard for referral performance
- REST API - Complete backend API with Swagger documentation
- Real-time Data - Redis-backed ranking and caching system
- Database Management - PostgreSQL with Drizzle ORM
- Modern Frontend - React 19 with TypeScript and TailwindCSS
- Container Support - Docker Compose for easy deployment
- Runtime: Node.js with TypeScript
- Framework: Fastify
- Database: PostgreSQL with Drizzle ORM
- Cache: Redis
- Validation: Zod
- Authentication: JWT
- Documentation: Swagger/OpenAPI
- Framework: React 19
- Language: TypeScript
- Styling: TailwindCSS
- State Management: TanStack React Query
- Routing: React Router DOM
- UI Components: Radix UI + Shadcn/ui
- Forms: React Hook Form with Zod validation
- Icons: Lucide React
- Containerization: Docker Compose
- Code Quality: Biome (linting & formatting)
- Build Tool: Vite (frontend) + tsup (backend)
โโโ backend/ # API server
โ โโโ src/
โ โ โโโ drizzle/ # Database schema and migrations
โ โ โโโ functions/ # Business logic
โ โ โโโ routes/ # API endpoints
โ โ โโโ redis/ # Redis client configuration
โ โ โโโ server.ts # Server entry point
โ โโโ docker-compose.yml # Infrastructure services
โ โโโ package.json
โ
โโโ frontend/ # React application
โ โโโ src/
โ โ โโโ components/ # React components
โ โ โโโ pages/ # Page components
โ โ โโโ http/ # API client and types
โ โ โโโ lib/ # Utilities
โ โ โโโ main.tsx # App entry point
โ โโโ package.json
โ
โโโ README.md # This file
- Node.js 18+
- Docker and Docker Compose
- npm or yarn
-
Clone the repository
git clone <repository-url> cd nlw-agents-rocketseat-25
-
Start the infrastructure services
cd backend docker-compose up -d -
Set up the backend
# Install dependencies npm install # Set up environment variables cp .env.example .env # Edit .env with your configuration # Run database migrations npm run db:migrate # Start development server npm run dev
-
Set up the frontend
cd ../frontend # Install dependencies npm install # Start development server npm run dev
Create a .env file in the backend directory:
# Server
PORT=3333
# Database
DATABASE_URL=postgresql://docker:docker@localhost:5432/connect
# Redis
REDIS_URL=redis://localhost:6379
# URLs
API_URL=http://localhost:3333
WEB_URL=http://localhost:5173The backend provides several key endpoints:
POST /subscriptions- Subscribe to eventsGET /ranking- Get referral rankingsGET /invites/:subscriberId- Access referral linksGET /subscribers/:id/ranking/*- Get subscriber metrics
/- Home page with room listing/create-room- Create new Q&A rooms/room/:roomId- Q&A room interface/room/:roomId/audio- Audio recording interface
Backend Development
cd backend
npm run dev # Start with hot reload
npm run db:generate # Generate database migrations
npm run db:migrate # Run migrations
npm run build # Build for productionFrontend Development
cd frontend
npm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build- Users can invite others through unique referral links
- Referrals are tracked and scored using Redis
- Real-time ranking system shows top referrers
- Automatic scoring when referrals are successful
- Create rooms for organized question sessions
- AI-powered responses to user questions
- Audio recording capabilities for enhanced interaction
- Real-time question management
subscriptionstable for user management- Redis for high-performance ranking data
- Drizzle ORM for type-safe database operations
Once running, visit http://localhost:3333/docs to access the interactive Swagger documentation.
The project includes Docker Compose configuration for easy infrastructure setup:
cd backend
docker-compose up -d # Starts PostgreSQL and Redis- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is part of the NLW (Next Level Week) event by Rocketseat.
This project was developed during NLW Agents event by Rocketseat, demonstrating modern web development practices with intelligent agents and real-time systems.




