A full-stack URL shortener application built with React, Express.js, and TypeScript for the Affordmed campus hiring evaluation.
``` ├── logging-middleware/ # Reusable logging package ├── backend/ # Express.js API server ├── app/ # Next.js React frontend ├── scripts/ # Setup and testing scripts └── screenshots/ # API testing screenshots ```
- URL Shortening: Create short URLs with optional custom codes and expiry times
- Analytics: Track clicks with timestamp, referrer, and location data
- Material UI Frontend: Clean, responsive interface for URL management
- Comprehensive Logging: Integrated logging middleware for all operations
- RESTful API: Well-documented backend with proper error handling
First, update the configuration in scripts/auth-setup.js with your details:
```javascript const CONFIG = { email: 'your-email@example.com', name: 'Your Name', mobileNo: 'your-mobile-number', githubUsername: 'your-github-username', rollNo: 'your-roll-number', accessCode: 'provided-access-code' }; ```
Then run the setup:
```bash node scripts/auth-setup.js ```
```bash npm run setup ```
Option A - Start both services together: ```bash npm run dev:all ```
Option B - Start services separately: ```bash
npm run backend:dev
npm run dev ```
```bash npm run test:integration ```
Backend (http://localhost:4000)
POST /shorturls- Create short URLGET /shorturls- List all short URLsGET /:shortcode- Redirect to original URLGET /shorturls/:shortcode/stats- Get URL statistics
Frontend (http://localhost:3000)
- URL Shortener Tab: Create up to 5 short URLs with validation
- Statistics Tab: View analytics for all created URLs
Copy .env.example to .env.local and update with your values:
```env ACCESS_TOKEN=your_jwt_token NEXT_PUBLIC_ACCESS_TOKEN=your_jwt_token PORT=4000 ```
npm run dev- Start frontend development servernpm run backend:dev- Start backend development servernpm run dev:all- Start both frontend and backendnpm run build- Build frontend for productionnpm run backend:build- Build backend for productionnpm run logging:build- Build logging middlewarenpm run test:integration- Run integration tests
- TypeScript package for structured logging
- Validates inputs against allowed packages and levels
- Integrates with evaluation service logging API
- Used by both frontend and backend
- Express.js server with TypeScript
- In-memory database for URL storage
- Comprehensive error handling
- Click analytics tracking
- CORS enabled for frontend integration
- Next.js with React and TypeScript
- Material UI components (as required)
- Client-side validation
- Real-time statistics display
- Responsive design
The integration test suite verifies:
- Backend and frontend health checks
- URL shortening functionality
- Redirect behavior
- Statistics tracking
- End-to-end API integration
This project follows the Affordmed evaluation requirements:
- Repository structure matches specification
- Logging middleware integration throughout
- Material UI for frontend (no ShadCN)
- Proper error handling and validation
- Screenshots included for API testing
- No company name or personal details in repo