You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The API will be available at http://localhost:8000/api/
66
66
67
+
## Setup Integration Script
68
+
69
+
To simplify the integration of the Supabase template into your existing Python project, you can use the provided setup script. This script will copy all necessary files and configurations from the template into your project.
70
+
71
+
### Features
72
+
73
+
-**Copies all necessary files and folders** from the template to your project
74
+
-**Merges Pipfiles** if both your project and the template have them
75
+
-**Preserves existing files** in your project while adding new ones
76
+
-**Handles configuration files** like `.env`, `docker-compose.yml`, etc.
77
+
78
+
### Usage
79
+
80
+
1.**Run the Setup Script**:
81
+
After cloning the repository, navigate to the project directory and run the script:
This will copy all files and directories (except the script itself) to your project, including:
88
+
89
+
-`.env.example` as `.env`
90
+
-`docker-compose.yml`
91
+
-`config` folder (for Prometheus)
92
+
-`database` folder
93
+
-`docker` folder (containing Dockerfile)
94
+
- All other necessary files
95
+
96
+
2.**Pipfile Merging**:
97
+
We suggest using Pipfile to manage dependencies in your project. If your existing project has a `Pipfile` and the template also has one, the script will attempt to merge them, preserving your existing dependencies while adding the ones required by the template.
98
+
99
+
3.**Follow the Remaining Setup Steps**:
100
+
After running the script, follow the remaining setup steps in the README to configure your project.
101
+
102
+
67
103
## Authentication Flow
68
104
69
105
1. Users authenticate through Supabase (OAuth, email/password, OTP)
@@ -74,10 +110,201 @@ The API will be available at http://localhost:8000/api/
74
110
## API Rate Limiting & Credit System
75
111
76
112
The template includes:
113
+
77
114
- Per-user rate limiting via Django REST Framework throttling
78
115
- Credit-based usage tracking for premium features
79
116
- API endpoints to check remaining credits
80
117
118
+
## Managing Credits for API Endpoints
119
+
120
+
### Using CreditUsageRate
121
+
122
+
The `CreditUsageRate` model allows administrators to define credit costs for different API endpoints. Here's how to use it:
123
+
124
+
1.**Create a New Credit Usage Rate**:
125
+
You can create a new credit usage rate for an endpoint in the Django shell or through the admin interface:
126
+
127
+
```python
128
+
from apps.credits.models import CreditUsageRate
129
+
130
+
new_rate = CreditUsageRate.objects.create(
131
+
endpoint_path='/api/resource/', # The API endpoint
132
+
credits_per_request=5, # Set the number of credits for this endpoint
133
+
description='Cost for accessing the resource endpoint',
134
+
is_active=True# Set to True to make it active
135
+
)
136
+
```
137
+
138
+
2.**Update Existing Credit Usage Rates**:
139
+
If you need to change the credit cost for an existing endpoint, fetch the instance and update it:
0 commit comments