PortuguΓͺs: DocumentaΓ§Γ£o em PortuguΓͺs
A modern, full-stack event management system for the CodeCraft Summit 2025, featuring user subscriptions, referral tracking, and real-time rankings. Built with cutting-edge technologies and designed for scalability and performance.
CodeCraft Summit 2025 is a comprehensive event management platform that enables seamless user registration and referral tracking. The system features a sophisticated invitation-based referral system where participants can earn points by inviting others, compete in rankings, and track their statistics in real-time.
- π« Smart Registration System - Streamlined user subscription with form validation
- π Referral Program - Invite tracking with unique referral links and click analytics
- π Real-time Rankings - Dynamic leaderboard showing top referrers
- π Personal Analytics - Individual statistics dashboard for each subscriber
- π± Responsive Design - Mobile-first approach with beautiful UI components
- π Type-Safe APIs - Fully typed backend with Zod validation
- β‘ High Performance - Fast database queries with optimized caching
This project follows a modern monorepo structure with clear separation between frontend and backend:
devstage-events/
βββ web/ # Next.js 16 frontend application
β βββ src/
β β βββ app/ # App Router pages and layouts
β β βββ components/ # Reusable UI components
β β βββ http/ # API client with generated types
β β βββ assets/ # Static assets and images
β βββ orval.config.ts # OpenAPI client generation config
βββ server/ # Fastify backend API
β βββ src/
β β βββ routes/ # API endpoint definitions
β β βββ functions/ # Business logic functions
β β βββ drizzle/ # Database schema and migrations
β β βββ redis/ # Redis client configuration
β βββ env.ts # Environment variable validation
βββ docs/ # Documentation
- Framework: Next.js 16 with App Router
- Language: TypeScript 5.0+
- Styling: Tailwind CSS 4.1 with custom design system
- UI Components: Custom component library with Lucide React icons
- Forms: React Hook Form with Zod validation
- HTTP Client: Auto-generated from OpenAPI spec using Orval
- Linting: Biome for code formatting and linting
- Framework: Fastify 5.6 with Zod type provider
- Language: TypeScript 5.9+
- Database: PostgreSQL with Drizzle ORM
- Cache: Redis for performance optimization
- API Documentation: OpenAPI 3.0 with Swagger UI
- Validation: Zod schemas for request/response validation
- Code Quality: Biome for consistent code formatting
- Package Manager: npm
- Build Tools: tsup for backend, Next.js for frontend
- Development: tsx for hot reloading during development
- Database Migrations: Drizzle Kit
- Environment: Environment variable validation with Zod
- Containerization: Docker Compose for database services (PostgreSQL & Redis)
Before running this project, ensure you have the following installed:
- Node.js 18.0 or higher
- PostgreSQL 13 or higher (or use Docker)
- Redis 6 or higher (or use Docker)
- npm (comes with Node.js)
- Docker (optional, for database services)
- Docker Compose (optional, for database services)
The easiest way to get PostgreSQL and Redis running is using Docker Compose:
# Start database services (PostgreSQL and Redis)
cd server
docker compose up -d
# View logs
docker compose logs -f
# Stop database services
docker compose downgit clone https://github.com/MiguelMachado-dev/devstage-events.git
cd devstage-events# Install backend dependencies
cd server
npm install
# Install frontend dependencies
cd ../web
npm installCreate environment files for both services:
Backend Environment (server/.env):
PORT=3333
POSTGRES_URL=postgresql://docker:docker@localhost:5432/connect
REDIS_URL=redis://localhost:6379
WEB_URL=http://localhost:3000Frontend Environment (web/.env.local):
NEXT_PUBLIC_API_URL=http://localhost:3333If you're using Docker Compose for database services, the databases are already configured. Just run migrations:
cd server
npx drizzle-kit pushIf you prefer to use local database installations, update the POSTGRES_URL and REDIS_URL in your .env file accordingly.
Run both services in separate terminals:
# Terminal 1: Start backend server
cd server
npm run dev
# Terminal 2: Start frontend server
cd web
npm run devThe application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:3333
- API Documentation: http://localhost:3333/docs
- Home Page: Users access the landing page with event information
- Registration: Fill out the subscription form with name and email
- Referral Link: Receive a unique referral link after successful registration
- Share & Track: Share the referral link and track invitations
- Rankings: View real-time rankings and personal statistics
The API provides the following endpoints:
POST /subscriptions- Register a new subscriberGET /invites/{subscriberId}- Access invite link (redirects to main site)GET /subscribers/{subscriberId}/ranking/clicks- Get click count for referralsGET /subscribers/{subscriberId}/ranking/count- Get referral countGET /subscribers/{subscriberId}/ranking/position- Get ranking positionGET /ranking- Get top referrers ranking
- Hot Reloading: Both frontend and backend support hot reloading during development
- Type Safety: Full TypeScript support with generated API types
- API Documentation: Interactive Swagger UI available at
/docs - Database Migrations: Drizzle Kit for schema management
- Code Formatting: Automatic code formatting with Biome
The project uses PostgreSQL as the primary database. The connection is configured through environment variables:
// server/env.ts
const envSchema = z.object({
POSTGRES_URL: z.url(),
// ... other variables
})Redis is used for caching and performance optimization:
// server/src/redis/client.ts
import Redis from 'ioredis'
export const redis = new Redis(process.env.REDIS_URL)The backend automatically generates OpenAPI documentation. Access it at:
- Swagger UI: http://localhost:3333/docs
- OpenAPI JSON: http://localhost:3333/docs/json
This project uses Biome for code formatting and linting:
# Format code
npx biome format --write .
# Check code quality
npx biome check .To manage database schema changes:
# Generate migrations
npx drizzle-kit generate
# Apply migrations
npx drizzle-kit push
# View migrations
npx drizzle-kit studioThe frontend API client is automatically generated from the OpenAPI spec:
cd web
npx orval# Build backend
cd server
npm run build
# Build frontend
cd ../web
npm run build- Ensure all environment variables are set in production
- Run database migrations before starting the application
- Configure proper CORS settings for the frontend domain
- Set up Redis for production caching
- Consider using CDN for static assets
- Use HTTPS and configure SSL certificates
- Set up proper monitoring and logging
- Configure backup strategies for PostgreSQL
The project includes Docker Compose configuration for easy database setup:
- service-pg: PostgreSQL database (port 5432)
- service-redis: Redis cache (port 6379)
# Database (PostgreSQL)
POSTGRES_USER=docker
POSTGRES_PASSWORD=docker
POSTGRES_DB=connect
# Redis
ALLOW_EMPTY_PASSWORD=yes# Start database services
cd server
docker compose up -d
# View logs
docker compose logs -f
# Stop services
docker compose downThe API provides built-in health checks. Monitor:
- Database connectivity
- Redis connection status
- API response times
The application uses console logging in development. For production:
- Implement structured logging
- Set up log aggregation
- Monitor error rates and performance metrics
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and linting (
npx biome check .) - 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 licensed under the ISC License - see the LICENSE file for details.
For support and questions:
- Create an issue in the repository
- Check the API documentation at
/docs - Review the code comments and type definitions
Built with β€οΈ for the CodeCraft Summit 2025 community