A modern, production-ready subscription management application built with Next.js 14, TypeScript, and Tailwind CSS. This frontend provides a comprehensive interface for users to track subscriptions, monitor renewals, and analyze spending across different categories.
- Overview
- Features
- Technology Stack
- Getting Started
- Project Structure
- UI Design Principles
- Backend Connectivity
- Authentication Flow
- Component Architecture
- API Integration
- Responsive Design
- Error Handling
- Development Guidelines
- Deployment
- License
- Contributing
- Support
This frontend application is a full-featured subscription management system that enables users to:
- Track Subscriptions: Add, view, edit, and delete subscriptions with detailed information
- Monitor Renewals: Get insights on upcoming renewals and expiration dates
- Analyze Spending: View total monthly costs and category breakdowns
- Manage Account: Update profile information and preferences
- Secure Authentication: JWT-based authentication with secure token management
The application follows modern web development best practices, including server-side rendering, client-side interactivity, responsive design, and comprehensive error handling.
- User registration with email and password validation
- Secure login with JWT token management
- Session management via localStorage and cookies for client/server compatibility
- Protected routes with server-side authentication guards
- Automatic redirection based on authentication status
- Summary cards: Total subscriptions, active subscriptions, upcoming renewals (next 7 days)
- Total monthly cost calculation (normalized across all billing frequencies)
- Category breakdown visualization
- Comprehensive subscriptions table with sorting and filtering
- Quick actions to add new subscriptions
- Create: Name, price, currency (Rs/USD), billing frequency (daily/weekly/monthly/yearly), category, payment method, start date
- View: List and detail views with renewal date calculations and reminder previews
- Edit: Update any subscription field
- Delete: Remove subscriptions with confirmation dialog
- View account information (name, email, creation date)
- Profile settings management
- Secure logout functionality
- Light/dark mode toggle
- Persistent theme preferences in localStorage
- System-wide theme application
- High visibility design for optimal readability
- Next.js 14.0.4: React framework with App Router, SSR, Server Components, and built-in optimizations
- React 18.2.0: UI library with hooks, component composition, and Context API
- TypeScript 5.3.3: Type safety with strict type checking and interface definitions
- Tailwind CSS 3.4.0: Utility-first CSS framework with responsive design, dark mode support, and custom color palette
- PostCSS 8.4.32: CSS processing and transformation
- Autoprefixer 10.4.16: Automatic vendor prefixing
- clsx 2.0.0: Conditional class name utility
- tailwind-merge 2.2.0: Intelligent Tailwind class merging
- Node.js 18.0 or higher
- npm 9.0 or higher (or yarn/pnpm)
- Backend API running on
http://localhost:5500(or configure via environment variable)
-
Navigate to the frontend directory:
cd frontEnd -
Install dependencies:
npm install
-
Configure environment variables (optional):
Create a
.env.localfile in the root directory:NEXT_PUBLIC_API_URL=http://localhost:5500
-
Start the development server:
npm run dev
-
Open your browser:
Navigate to http://localhost:3000
npm run build
npm startfrontEnd/
├── app/ # Next.js App Router pages
│ ├── layout.tsx # Root layout with navigation
│ ├── page.tsx # Home page (redirects to dashboard)
│ ├── globals.css # Global styles and CSS variables
│ ├── dashboard/ # Dashboard page
│ ├── login/ # Login page
│ ├── signup/ # Registration page
│ ├── logout/ # Logout handler
│ ├── profile/ # User profile page
│ ├── subscriptions/ # Subscription management pages
│ │ ├── page.tsx # Subscriptions list
│ │ ├── new/ # Add subscription
│ │ └── [id]/ # Subscription details and edit
│ ├── error.tsx # Global error boundary
│ ├── not-found.tsx # 404 page
│ └── loading.tsx # Loading UI
│
├── components/ # React components
│ ├── navigation.tsx # Main navigation bar
│ ├── dashboard-content.tsx # Dashboard content
│ ├── subscriptions-list.tsx # Subscriptions table
│ ├── subscription-details.tsx # Subscription detail view
│ ├── add-subscription-form.tsx # Create subscription form
│ ├── edit-subscription-form.tsx # Edit subscription form
│ ├── profile-content.tsx # Profile page content
│ └── ui/ # Reusable UI components
│ ├── error-boundary.tsx # Error boundary component
│ ├── error-message.tsx # Error display component
│ ├── empty-state.tsx # Empty state component
│ ├── loading-skeleton.tsx # Loading skeleton components
│ ├── status-badge.tsx # Status badge component
│ └── delete-confirmation-dialog.tsx # Delete confirmation modal
│
├── lib/ # Utility libraries
│ ├── api.ts # API client and request utilities
│ ├── auth.ts # Authentication utilities (server-side)
│ ├── date-utils.ts # Date formatting utilities
│ └── utils.ts # General utilities (cn function)
│
├── public/ # Static assets
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── tailwind.config.ts # Tailwind CSS configuration
├── next.config.js # Next.js configuration
└── postcss.config.js # PostCSS configuration
The application follows modern SaaS design principles with focus on:
- Clarity: Clean, uncluttered interfaces with clear information hierarchy
- Consistency: Uniform design patterns across all pages and components
- Accessibility: WCAG-compliant components with proper ARIA labels and keyboard navigation
- Responsiveness: Mobile-first design that works seamlessly across all device sizes
- User Feedback: Clear loading states, error messages, and success indicators
Light Theme:
- Primary Background:
#ffffff - Secondary Background:
#f9fafb - Primary Text:
#000000(high visibility) - Secondary Text:
#1f2937 - Borders:
#e5e7eb
Dark Theme:
- Primary Background:
#111827 - Secondary Background:
#1f2937 - Primary Text:
#f9fafb - Secondary Text:
#d1d5db - Borders:
#374151
- Font Family: Inter (Google Fonts)
- Headings: Semibold, hierarchical sizing with
tracking-tight - Body Text: Regular weight, readable sizes (base: 16px, sm: 14px)
- Line Height: Comfortable spacing for readability
- Cards: Rounded corners (
rounded-lg), subtle shadows, clear borders - Buttons: Clear hierarchy with consistent styling and hover states
- Forms: Consistent input styling with labels above inputs, inline validation
- Tables: Alternating row colors, hover states, clickable rows
- Badges: Color-coded status indicators with semantic meanings
- Mobile:
< 640px(sm) - Tablet:
640px - 1024px(md) - Desktop:
> 1024px(lg)
The frontend connects to a Node.js/Express backend API. Configuration is managed via environment variable:
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:5500";The application uses JWT (JSON Web Tokens) for authentication:
- Token Storage:
localStoragefor client-side components, cookies for server-side components - Token Transmission: Sent as
Authorization: Bearer <token>header - Automatic Injection: Tokens automatically included in all API requests via
apiRequestfunction
Authentication:
POST /api/v1/auth/sign-up- User registrationPOST /api/v1/auth/sign-in- User login
User Management:
GET /api/v1/user/me- Get current authenticated user
Subscription Management:
GET /api/v1/subscription/user/:userId- Get all user subscriptionsPOST /api/v1/subscription- Create new subscriptionPUT /api/v1/subscription/:id- Update subscriptionDELETE /api/v1/subscription/:id- Delete subscription
The frontend handles backend data inconsistencies:
- ID mapping: Converts MongoDB
_idtoidfor consistency - Typo handling: Normalizes
renewaltDatetorenewalDate - Date formatting: Converts ISO date strings to user-friendly formats
- User fills out registration form with name, email, and password
- Frontend validates password strength and matching
- POST request to
/api/v1/auth/sign-up - Backend returns JWT token
- Token stored in
localStorageand cookie - User redirected to
/dashboard
- User enters credentials on login page
- POST request to
/api/v1/auth/sign-in - Backend validates credentials and returns JWT token
- Token stored in
localStorageand cookie - User redirected to
/dashboard
- Server Component calls
requireAuth() requireAuth()checks for token in cookies- If token exists, validates with backend
/api/v1/user/me - If valid, returns user data; if invalid/missing, redirects to
/login
- User clicks logout button
- Token removed from
localStorageand cookie cleared - User redirected to
/login
Used for data fetching, authentication checks, and initial page rendering:
app/dashboard/page.tsxapp/subscriptions/page.tsxapp/profile/page.tsx
Used for user interactions, state management, and browser APIs:
components/add-subscription-form.tsxcomponents/edit-subscription-form.tsxcomponents/navigation.tsxapp/login/page.tsxapp/signup/page.tsx
Located in components/ui/:
- ErrorBoundary: Catches and displays React errors
- ErrorMessage: Displays error messages to users
- EmptyState: Shows empty state when no data
- LoadingSkeleton: Loading placeholders (CardSkeleton, TableSkeleton)
- StatusBadge: Color-coded status indicators
- DeleteConfirmationDialog: Confirmation modal for deletions
The API client (lib/api.ts) provides a unified interface:
// GET request
const data = await api.get<ResponseType>("/endpoint");
// POST request
const data = await api.post<ResponseType>("/endpoint", payload);
// PUT request
const data = await api.put<ResponseType>("/endpoint", payload);
// DELETE request
const data = await api.delete<ResponseType>("/endpoint");- Automatic token injection in Authorization header
- Error handling with meaningful error messages
- Type safety with generic types for response data
- Automatic JSON content-type headers
try {
const response = await api.post("/endpoint", data);
} catch (err) {
if (err instanceof ApiException) {
// Handle API error with status code
console.error(err.message, err.status);
}
}All components are designed mobile-first, then enhanced for larger screens:
- Mobile (
< 640px): Single column layouts, stacked elements - Tablet (
640px - 1024px): Two-column grids, side-by-side elements - Desktop (
> 1024px): Multi-column layouts, optimal spacing
- Grid Layouts:
grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 - Typography:
text-2xl sm:text-3xl - Spacing:
p-4 sm:p-6 lg:p-8 - Forms: Stacked inputs on mobile, side-by-side on desktop
React Error Boundaries catch component errors:
- Global error boundary catches errors in page components
- Component-level boundaries for specific error handling
- API Errors: Extracted from backend responses with user-friendly messages
- Validation Errors: Displayed inline in forms with proper ARIA attributes
- Network Errors: User-friendly fallback messages
- 404 Errors: Custom not-found page
- Skeletons: Placeholder content during loading
- Spinners: Loading indicators for actions
- Disabled States: Prevent multiple submissions
- TypeScript: Strict mode enabled
- Components: Functional components with hooks
- Naming: PascalCase for components, camelCase for functions
- File Structure: Co-located components and utilities
- Server vs Client Components: Use Server Components by default, Client Components only when needed
- Data Fetching: Fetch data in Server Components when possible
- Error Handling: Always handle errors gracefully with proper user feedback
- Accessibility: Include ARIA labels, keyboard navigation, and proper semantic HTML
- Performance: Use Next.js optimizations (Image, Link, Script)
Create .env.local:
NEXT_PUBLIC_API_URL=http://localhost:5500npm run buildThis creates an optimized production build in .next/ directory.
npm startSet NEXT_PUBLIC_API_URL to your production backend URL in your deployment platform's environment variables.
This project is part of a subscription management system. All rights reserved.
When contributing to this project:
- Follow TypeScript best practices and maintain type safety
- Maintain consistent component structure and naming conventions
- Add proper error handling and user feedback
- Ensure responsive design works across all breakpoints
- Test on multiple devices and browsers
- Update documentation for any significant changes
For issues or questions, please refer to the project documentation or contact:
- Email: nethminaappdevelopment1@gmail.com
- LinkedIn: [http://www.linkedin.com/in/neth-band]
Built with Next.js, React, and TypeScript