urembo-hub-api
    Preparing search index...

    urembo-hub-api

    Urembo Hub API

    A comprehensive NestJS API for the Urembo Hub beauty services and e-commerce platform, migrated from Supabase with Prisma and PostgreSQL.

    • Multi-role User Management: Client, Vendor, Retailer, Manufacturer, Admin roles
    • E-commerce: Products, services, orders, and order management
    • Appointment System: Service bookings with scheduling
    • Commission System: Automated commission tracking and payments
    • Payment Processing: Paystack integration for payments
    • Support System: Tickets and conversations for customer support
    • Shipping Management: Order tracking and delivery management
    • CMS: Content management settings and configuration
    • Authentication: JWT-based authentication with role-based access control
    • Framework: NestJS
    • Database: PostgreSQL with Prisma ORM
    • Authentication: JWT with Passport
    • Validation: Class-validator and class-transformer
    • Environment: ConfigModule for environment management

    The application includes the following main entities:

    • Profiles: User profiles with role-based access
    • Products: E-commerce products from retailers/manufacturers
    • Services: Beauty services from vendors
    • Orders: Order management with items and appointments
    • Appointments: Service booking system
    • Commission Settings: Configurable commission rates by role
    • Commission Transactions: Real-time commission tracking
    • Payment Methods: Stored payment methods for business users
    • Payment Provider Settings: Multi-provider payment configuration
    • Tickets: Customer support ticket system
    • Ticket Categories: Organized support categories
    • Staff Assignments: Role-based staff permissions
    • Audit Logs: Comprehensive audit trail
    • Shipments: Order delivery tracking
    • Shipment Status Updates: Real-time delivery status
    • Delivery Partners: Multiple delivery provider support
    • CMS Settings: Dynamic content management
    • Admin Currency Settings: Multi-currency support
    • Vendor Schedule Slots: Dynamic appointment scheduling
    • Node.js (v18 or higher)
    • PostgreSQL database
    • npm or yarn package manager
    1. Clone and navigate to the project:

      cd urembo-hub-api
      
    2. Install dependencies:

      npm install
      
    3. Environment Configuration:

      cp env.example .env
      

      Update the .env file with your configuration:

      # Database
      DATABASE_URL="postgresql://username:password@localhost:5432/urembo_hub?schema=public"
      
      # JWT
      JWT_SECRET="your-super-secret-jwt-key-here"
      JWT_EXPIRES_IN="7d"
      
      # Application
      PORT=3000
      NODE_ENV=development
      
      # External Services
      PAYSTACK_SECRET_KEY="your-paystack-secret-key"
      PAYSTACK_PUBLIC_KEY="your-paystack-public-key"
      RESEND_API_KEY="your-resend-api-key"
      
      # Email
      FROM_EMAIL="noreply@urembohub.com"
      FROM_NAME="Urembo Hub"
      
    4. Database Setup:

      # Create the database (run this in your PostgreSQL client)
      CREATE DATABASE urembo_hub;

      # Run migrations
      npx prisma migrate dev --name init

      # Generate Prisma client
      npx prisma generate
    5. Start the application:

      # Development mode
      npm run start:dev

      # Production mode
      npm run start:prod
    • POST /auth/login - User login
    • POST /auth/register - User registration
    • GET /auth/profile - Get user profile (protected)
    • GET /users - Get all users (with pagination and filtering)
    • GET /users/:id - Get user by ID
    • PUT /users/profile - Update user profile (protected)
    • PATCH /users/:id/verify - Verify user (admin only)
    • DELETE /users/:id - Delete user (admin only)
    • GET /products - Get all products (with pagination and filtering)
    • GET /products/:id - Get product by ID
    • POST /products - Create product (retailers/manufacturers only)
    • PUT /products/:id - Update product (owner/admin only)
    • DELETE /products/:id - Delete product (owner/admin only)
    • GET /products/my/products - Get user's products (protected)
    • GET /services - Get all services (with pagination and filtering)
    • GET /services/:id - Get service by ID
    • POST /services - Create service (vendors only)
    • PUT /services/:id - Update service (owner/admin only)
    • DELETE /services/:id - Delete service (owner/admin only)
    • GET /services/my/services - Get user's services (protected)
    • GET /orders - Get all orders (with pagination and filtering)
    • GET /orders/:id - Get order by ID
    • POST /orders - Create order (guest users)
    • POST /orders/authenticated - Create order (authenticated users)
    • PUT /orders/:id - Update order (owner/admin/related business users)
    • GET /orders/my/orders - Get user's orders (protected)
    • GET /appointments - Get all appointments
    • POST /payments/process - Process payment
    • GET /tickets - Get all tickets
    • GET /commission/settings - Get commission settings
    • GET /cms/settings - Get CMS settings

    This NestJS application was created by analyzing the existing Supabase application and migrating the database schema and business logic. The migration includes:

    1. Schema Migration: All tables, relationships, and constraints from Supabase
    2. Business Logic: Core functionality from Supabase Edge Functions
    3. Authentication: JWT-based auth replacing Supabase Auth
    4. API Structure: RESTful endpoints matching Supabase API patterns
    1. Authentication: Uses JWT instead of Supabase Auth
    2. Database Access: Prisma ORM instead of direct Supabase client
    3. Serverless Functions: NestJS controllers instead of Edge Functions
    4. Real-time: No built-in real-time subscriptions (can be added with WebSockets)
    5. Storage: No built-in file storage (can be integrated with AWS S3, etc.)
    npm run start:dev
    
    # View database in Prisma Studio
    npx prisma studio

    # Reset database
    npx prisma migrate reset

    # Deploy migrations
    npx prisma migrate deploy
    # Unit tests
    npm run test

    # E2E tests
    npm run test:e2e

    # Test coverage
    npm run test:cov
    1. Environment Setup: Configure production environment variables
    2. Database: Set up production PostgreSQL database
    3. Migrations: Run npx prisma migrate deploy
    4. Build: npm run build
    5. Start: npm run start:prod
    1. Fork the repository
    2. Create a feature branch
    3. Make your changes
    4. Add tests if applicable
    5. Submit a pull request

    This project is licensed under the MIT License.

    For support and questions, please contact the development team or create an issue in the repository.