Skip to content

Vendor-Innovate-Solutions/Vendor

Repository files navigation

Vendor ICP Application

A complete vendor management system built on the Internet Computer Protocol (ICP) with a Next.js frontend and Motoko backend.

πŸ—οΈ Architecture

  • Frontend: Next.js application with ICP integration
  • Backend: Motoko canister with complete business logic
  • Deployment: Unified DFX configuration for seamless deployment

πŸš€ Quick Start

Prerequisites

  1. DFX CLI (DFINITY SDK)

    curl -fsSL https://internetcomputer.org/install.sh | sh
  2. Node.js (v18 or higher)

    # Download from https://nodejs.org/
  3. Git (for cloning the repository)

Local Development

  1. Clone and setup

    git clone <repository-url>
    cd Vendor
  2. Run development setup

    ./dev-setup.sh
  3. Start frontend development

    cd frontend
    npm run dev
  4. Access the application

Production Deployment

Local Deployment (for testing)

./deploy.sh local

Mainnet Deployment

./deploy.sh ic

πŸ“ Project Structure

Vendor/
β”œβ”€β”€ dfx.json                    # Unified DFX configuration
β”œβ”€β”€ deploy.sh                   # Production deployment script
β”œβ”€β”€ dev-setup.sh                # Development setup script
β”œβ”€β”€ frontend/                   # Next.js frontend application
β”‚   β”œβ”€β”€ app/                    # Next.js app router pages
β”‚   β”œβ”€β”€ components/             # React components
β”‚   β”œβ”€β”€ utils/                  # ICP integration utilities
β”‚   β”‚   β”œβ”€β”€ icp-api.ts         # ICP service layer
β”‚   β”‚   β”œβ”€β”€ icp-auth.ts        # ICP authentication
β”‚   β”‚   β”œβ”€β”€ icp-config.ts      # ICP configuration
β”‚   β”‚   └── icp-service.ts     # ICP canister interface
β”‚   β”œβ”€β”€ package.json           # Frontend dependencies
β”‚   └── next.config.ts         # Next.js configuration
└── backend/                    # Motoko backend
    β”œβ”€β”€ main.mo                 # Main canister actor
    β”œβ”€β”€ models/                 # Data models
    β”œβ”€β”€ utils/                  # Utility modules
    └── Documentation.md        # Backend API documentation

πŸ”§ Configuration

Environment Variables

The application automatically configures itself based on the deployment environment:

  • Local Development: Uses local DFX replica
  • Mainnet: Uses Internet Computer mainnet

Key environment variables (auto-generated):

NEXT_PUBLIC_DFX_NETWORK=local|ic
NEXT_PUBLIC_VENDOR_BACKEND_CANISTER_ID=<canister-id>
CANISTER_ID_VENDOR_BACKEND=<canister-id>

Canister Configuration

The dfx.json file configures both frontend and backend canisters:

  • vendor_backend: Motoko canister with business logic
  • vendor_frontend: Asset canister hosting the Next.js app

🎯 Features

Frontend

  • Complete ICP Integration: No Django API dependencies
  • Web3 Authentication: Principal-based user authentication
  • Real-time Updates: Direct canister communication
  • Responsive Design: Mobile-friendly interface
  • Modern UI: Built with React and Tailwind CSS

Backend

  • Complete Business Logic: Full vendor management system
  • User Management: Registration, authentication, roles
  • Company Management: Multi-tenant architecture
  • Product Catalog: Inventory with tax compliance
  • Order Processing: Complete order lifecycle
  • Financial Management: Invoicing and payments
  • Analytics: Dashboard statistics and reports

πŸ“š API Documentation

Detailed backend API documentation is available in backend/Documentation.md.

Key Endpoints

  • Authentication: register(), login(), logout()
  • Company Management: createCompany(), getCompanies()
  • Product Management: createProduct(), getProducts()
  • Order Management: createOrder(), getOrders()
  • Invoice Management: createInvoice(), getInvoices()

πŸ”„ Development Workflow

Local Development

  1. Run ./dev-setup.sh to initialize the local environment
  2. Start frontend development with cd frontend && npm run dev
  3. Backend changes require dfx deploy vendor_backend
  4. Frontend automatically connects to local canister

Testing

# Test backend canister
dfx canister call vendor_backend health '()'

# View canister logs
dfx canister logs vendor_backend

# Check canister status
dfx canister status vendor_backend

Deployment

# Deploy to local replica (testing)
./deploy.sh local

# Deploy to mainnet (production)
./deploy.sh ic

πŸ› οΈ Troubleshooting

Common Issues

  1. DFX replica not starting

    dfx killall
    dfx start --clean --background
  2. Frontend build errors

    cd frontend
    npm run clean
    npm ci
    npm run export
  3. Canister deployment fails

    dfx canister stop --all
    dfx start --clean --background
    dfx deploy

Development Tips

  • Use dfx generate to update Candid types after backend changes
  • Check .env file for correct canister IDs
  • Use browser developer tools to debug ICP calls
  • Monitor cycles balance for mainnet deployments

🎁 Features Completed

βœ… Frontend ICP Integration

  • Complete conversion from Django API to ICP services
  • Profile management via ICP
  • Accounting dashboard with ICP backend
  • Customer/retailer management
  • Invoice creation and viewing
  • Stock management system

βœ… Backend Motoko Implementation

  • Complete Django model migration
  • Full API endpoint coverage
  • Authentication and authorization
  • Business logic preservation
  • Tax compliance features
  • Multi-tenant architecture

βœ… Deployment Ready

  • Unified DFX configuration
  • Automated deployment scripts
  • Environment auto-configuration
  • Production optimizations

πŸš€ Production Deployment URLs

After deployment, your application will be available at:

Local Development

  • Frontend: http://<frontend-canister-id>.localhost:4943
  • Backend: http://127.0.0.1:4943/?canisterId=<backend-canister-id>

Mainnet

  • Frontend: https://<frontend-canister-id>.icp0.io
  • Backend: https://<backend-canister-id>.ic0.app

πŸ“ž Support

For deployment issues or questions:

  1. Check the troubleshooting section above
  2. Review the backend documentation
  3. Use dfx --help for DFX CLI assistance
  4. Check ICP documentation at https://internetcomputer.org/docs

πŸŽ‰ Your Vendor application is now fully ICP-enabled and ready for Web3 deployment!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published