How alvseven/url-shortener works
Main System Components
a) Client Layer
• External clients/applications that consume the API
• Connection through HTTP/HTTPS
b) API Layer (NestJS Application)
• Main modules:
• Auth Module
• Users Module
• Links Module
• Middleware Layer (Auth Guard, Validation)
c) Database Layer
• PostgreSQL Database
• Prisma ORM as the data access layer
Detailed Component Breakdown
For each major component, represent the following:
a) Auth Module:
• AuthController: handling authentication endpoints
• AuthService: business logic for authentication
• AuthGuard: JWT validation
• UsersRepository: user data access
b) Users Module:
• CreateUserController: user registration
• CreateUserService: user creation logic
• UsersRepository: user management
c) Links Module:
• Generate Link
• Get User Links
• Redirect
• Soft Delete Link
• Update Link
• Each with its respective Controller/Service/Repository pattern
Data Flow Representation
• Client requests → API endpoints
• Inter-module communication
• Database interactions through Prisma
• Authentication flow
• URL redirection flow
Specific Design Elements
Components with distinct visual representations:
a) Infrastructure Components:
• Docker containers (one for API, one for PostgreSQL)
• Environment configuration
b) Security Layer:
• JWT authentication flow
• Password hashing (bcryptjs)
c) Database Schema:
• Users table
• Links table with relationships
Key Interactions to Highlight
• URL shortening flow
• URL redirection flow
• User authentication process
• Click tracking mechanism
Technical Details
• API_URL for redirection
• JWT authentication flow
• Prisma ORM layer
• Docker containerization
• Environment configuration
Infrastructure Layer (Docker, Environment)
This structure reflects the modular nature of the NestJS application while showing the clear separation of concerns and the interaction between different components of the system.