Skip to content

This project is a web application that manages organizations as vendors providing products. The application includes features such as subscriptions, user management, and integration with Stripe for payment processing.

Notifications You must be signed in to change notification settings

haitham911/organization-management-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Organization Management App

This project is a web application that manages organizations as vendors providing products. The application includes features such as subscriptions, user management, and integration with Stripe for payment processing.

Business Logic

    • Subscribe to Products: Organizations can subscribe to products and manage their subscriptions.
    • User Creation: When a new user is created, the system first checks if the associated organization has enough subscription capacity. The user is then created and linked to the organization and the relevant Stripe subscription.
  1. Subscription Creation: When an organization subscribes to a product, a subscription is created in Stripe. The subscription details, including the quantity, are stored in the database.

  2. Subscription Validation: Before adding a new user to an organization, the system checks if the organization can add more subscriptions based on the quantity of the existing subscriptions.

  3. Payment Handling: Payment methods are attached to organizations when subscriptions are created. Stripe webhooks are used to handle events such as payment successes and subscription updates.

  4. Product Access Check: The system validates if users within an organization have access to a product based on their subscriptions.

  5. Stripe Integration:

    • Creating Products with Pre-set Price Models: Products are created in Stripe with predefined price models. This allows organizations to subscribe to these products with a fixed pricing structure. For more information on Stripe's pricing models, refer to the Stripe Pricing Models Documentation.
    • Adding Stripe Webhook Endpoints: Webhook endpoints are added to handle Stripe events such as payment successes, subscription updates, and more. This ensures that the application stays in sync with the latest payment and subscription statuses from Stripe. Webhook endpoints :baser_url/api/webhook 8 . User Roles: The system includes different user roles, such as Admin and User. Admins have additional permissions like managing products and subscriptions for the organization.

Features

  • Subscribe to Products: Organizations can subscribe to products and manage their subscriptions.
  • User Management: Users can be added to organizations, and their subscriptions are managed.
  • Subscription Validation: Checks if organizations can add more subscriptions based on their current subscription limits.
  • Stripe Integration: Seamless integration with Stripe for handling payments and subscriptions.

Technologies Used

  • Frontend: React, Stripe Elements
  • Backend: Golang, Gin, GORM, PostgreSQL, Stripe API
  • Database: PostgreSQL

Prerequisites

  • Node.js
  • Go
  • PostgreSQL
  • Stripe Account

Setup

Backend

  1. Clone the repository:

    git clone https://github.com/your-username/organization-management-app.git
    cd organization-management-app
  2. Install dependencies:

    go mod download
  3. Setup PostgreSQL database:

    Create a database and update the database configuration in config/config.go.

  4. Run the backend:

    go run main.go

Frontend

  1. Navigate to the frontend directory:

    cd src/frontend
  2. Install dependencies:

    npm install
  3. Start the frontend:

    npm start

API Endpoints

Subscriptions

  • Create Subscription: POST /api/subscriptions
    • Request Body:
      {
        "organization_id": 1,
        "product_id": 1,
        "price_id": "price_123",
        "quantity": 1,
        "payment_method_id": "pm_card_visa"
      }
    • Response:
      {
        "subscriptionId": "sub_123"
      }

Organization

  • Check if Organization Can Add More Subscriptions: POST /api/organizations/can-add-subscriptions

    • Request Body:
      {
        "organization_id": 1,
        "stripe_subscription_id": "sub_123"
      }
    • Response:
      {
        "can_add_more_subscriptions": true
      }
  • Check if Users Have Subscription to Product: POST /api/organizations/users-have-subscription

    • Request Body:
      {
        "organization_id": 1,
        "product_id": 1
      }
    • Response:
      {
        "has_subscription": true
      }

Users

  • Create User: POST /api/users
    • Request Body:
      {
        "name": "User Name",
        "email": "[email protected]",
        "password": "password123",
        "organization_id": 1,
        "stripe_subscription_id": "sub_123"
      }
    • Response:
      {
        "id": 1,
        "name": "User Name",
        "email": "[email protected]"
      }

Architecture Diagram

graph TD
    A[Frontend React]
    B[Backend Golang]
    C[PostgreSQL Database]
    D[Stripe API]
    
    A -->|API Requests| B
    B -->|Database Queries| C
    B -->|Payment Processing| D
    C -->|Data Storage| B
    D -->|Payment Events| B
Loading

About

This project is a web application that manages organizations as vendors providing products. The application includes features such as subscriptions, user management, and integration with Stripe for payment processing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published