Skip to content

ashwinikarke/License-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License Management System

A comprehensive full-stack application for managing licenses, subscriptions, and customers. Built with React (TypeScript + Vite) frontend and Node.js/Express backend with PostgreSQL database.

🚀 Features

Admin Features

  • Dashboard: System overview with metrics and recent activities
  • Customer Management: CRUD operations for customer accounts
  • Subscription Pack Management: Create and manage subscription plans
  • Subscription Management: Approve/reject requests, assign/unassign subscriptions
  • JWT Authentication: Secure admin authentication

Customer Features

  • Registration & Login: Account creation and authentication
  • Dashboard: Personal subscription overview
  • Subscription Management: Request new subscriptions, view current plan
  • Profile Management: View and manage account information
  • Subscription History: Track past subscriptions

SDK APIs

  • API Key Authentication: Separate authentication for mobile/desktop SDKs
  • Subscription Operations: Get current subscription, request new, deactivate
  • History Access: Retrieve subscription history with pagination

🏗️ Architecture

Tech Stack

  • Frontend: React 18, TypeScript, Vite, TailwindCSS, React Query, React Router
  • Backend: Node.js, Express.js, TypeScript, Sequelize ORM
  • Database: PostgreSQL
  • Authentication: JWT for frontend, API Keys for SDK
  • Development: Docker, Docker Compose

Project Structure

├── backend/                 # Express.js API server
│   ├── src/
│   │   ├── config/         # Database and logger configuration
│   │   ├── models/         # Sequelize models
│   │   ├── routes/         # API route handlers
│   │   ├── middleware/     # Authentication and validation middleware
│   │   ├── scripts/        # Database seeding scripts
│   │   └── server.ts       # Main server file
│   ├── Dockerfile
│   ├── docker-compose.yml
│   └── package.json
├── frontend/               # React application
│   ├── src/
│   │   ├── components/     # Reusable components
│   │   ├── pages/          # Page components
│   │   ├── contexts/       # React contexts
│   │   ├── api/           # API client functions
│   │   ├── lib/           # Utilities and helpers
│   │   └── types/         # TypeScript type definitions
│   ├── package.json
│   └── vite.config.ts
└── PROJECT_README.md       # This file

🛠️ Setup Instructions

Prerequisites

  • Node.js 18+ and npm
  • PostgreSQL 15+
  • Docker and Docker Compose (optional)

Option 1: Docker Setup (Recommended)

  1. Clone the repository

    git clone <repository-url>
    cd license-management-system
  2. Start with Docker Compose

    cd backend
    docker-compose up -d
  3. Seed the database

    docker-compose exec api npm run seed
  4. Setup frontend

    cd ../frontend
    npm install
    cp env.example .env
    npm run dev

The application will be available at:

Option 2: Manual Setup

Backend Setup

  1. Install dependencies

    cd backend
    npm install
  2. Setup PostgreSQL database

    # Create database
    createdb license_management
  3. Configure environment

    cp env.example .env
    # Edit .env with your database credentials
  4. Build and start server

    npm run build
    npm start
    
    # For development with auto-reload
    npm run dev
  5. Seed database with sample data

    npm run seed

Frontend Setup

  1. Install dependencies

    cd frontend
    npm install
  2. Configure environment

    cp env.example .env
    # Edit .env with your API URL
  3. Start development server

    npm run dev

🔐 Sample Login Credentials

After running the seed script, you can use these credentials:

Admin

Customers

📋 Completed Customer Flow

Customer Login → View Profile → Request Subscription

  1. Customer Registration/Login

  2. Dashboard Overview

    • View current subscription status
    • See account statistics
    • Quick access to subscription management
  3. Profile Management

    • View personal information
    • Account activity statistics
    • Edit profile (placeholder)
  4. Subscription Request Flow

    • Browse available subscription plans
    • Select desired plan
    • Submit subscription request
    • Request sent to admin for approval
  5. Subscription Management

    • View current active subscription
    • Deactivate subscription if needed
    • Access subscription history

🔧 API Documentation

The API follows the OpenAPI 3.0 specification provided in openapi.yaml. Key endpoints include:

Frontend APIs (JWT Authentication)

  • POST /api/admin/login - Admin authentication
  • POST /api/customer/login - Customer authentication
  • POST /api/customer/signup - Customer registration
  • GET /api/v1/admin/dashboard - Admin dashboard data
  • GET /api/v1/customer/subscription - Customer's current subscription

SDK APIs (API Key Authentication)

  • POST /sdk/auth/login - SDK authentication (returns API key)
  • GET /sdk/v1/subscription - Current subscription via SDK
  • POST /sdk/v1/subscription - Request subscription via SDK
  • DELETE /sdk/v1/subscription - Deactivate subscription via SDK

🧪 Testing

Backend Tests

cd backend
npm test

Frontend Tests

cd frontend
npm test

🚀 Production Deployment

Backend

  1. Build the application: npm run build
  2. Set production environment variables
  3. Deploy using Docker or process manager (PM2)
  4. Configure reverse proxy (nginx)
  5. Setup SSL certificates

Frontend

  1. Build for production: npm run build
  2. Deploy static files to CDN or web server
  3. Configure environment variables for production API

🌟 Key Features Implemented

Authentication & Security

  • ✅ JWT authentication for frontend APIs
  • ✅ API key authentication for SDK APIs
  • ✅ Role-based access control (Admin/Customer)
  • ✅ Route guards and protected routes
  • ✅ Password hashing with bcrypt
  • ✅ Input validation and sanitization

Business Logic

  • ✅ Single active subscription per customer rule
  • ✅ Subscription lifecycle management (requested → approved → active → inactive/expired)
  • ✅ Soft delete for customers and subscription packs
  • ✅ Automatic subscription expiry calculation

User Experience

  • ✅ Responsive design with TailwindCSS
  • ✅ Toast notifications for user feedback
  • ✅ Loading states and error handling
  • ✅ Intuitive navigation and routing
  • ✅ Form validation with helpful error messages

API Integration

  • ✅ Axios interceptors for token management
  • ✅ React Query for efficient data fetching and caching
  • ✅ Consistent error handling across the application
  • ✅ Pagination support for list endpoints

📚 Additional Features for Production

While this implementation provides a solid foundation, consider these enhancements for production:

  1. Enhanced Security

    • Rate limiting per user
    • CSRF protection
    • Input sanitization
    • API versioning
  2. Advanced Features

    • Email notifications
    • Payment integration
    • Advanced analytics
    • Audit logging
  3. Monitoring & DevOps

    • Application monitoring
    • Log aggregation
    • Performance metrics
    • CI/CD pipeline
  4. Scalability

    • Database optimization
    • Caching layer (Redis)
    • Load balancing
    • Microservices architecture

🐛 Troubleshooting

Common Issues

  1. Database Connection Error

    • Ensure PostgreSQL is running
    • Check database credentials in .env file
    • Verify database exists
  2. Frontend API Calls Failing

    • Check backend server is running on port 8080
    • Verify CORS configuration
    • Check network proxy settings
  3. Authentication Issues

    • Clear browser localStorage
    • Check JWT_SECRET in backend .env
    • Verify token expiration settings

Logs

  • Backend logs: backend/logs/
  • Browser console for frontend errors
  • Docker logs: docker-compose logs api

📞 Support

For questions or issues, please refer to:

  • API documentation in openapi.yaml
  • System design in README.md
  • Code comments and TypeScript types

License Management System - A modern, scalable solution for subscription and license management.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published