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.
-
- 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.
-
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.
-
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.
-
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.
-
Product Access Check: The system validates if users within an organization have access to a product based on their subscriptions.
-
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.
- 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.
- Frontend: React, Stripe Elements
- Backend: Golang, Gin, GORM, PostgreSQL, Stripe API
- Database: PostgreSQL
- Node.js
- Go
- PostgreSQL
- Stripe Account
-
Clone the repository:
git clone https://github.com/your-username/organization-management-app.git cd organization-management-app
-
Install dependencies:
go mod download
-
Setup PostgreSQL database:
Create a database and update the database configuration in
config/config.go
. -
Run the backend:
go run main.go
-
Navigate to the frontend directory:
cd src/frontend
-
Install dependencies:
npm install
-
Start the frontend:
npm start
- 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" }
- Request Body:
-
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 }
- Request Body:
-
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 }
- Request Body:
- 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]" }
- Request Body:
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