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
- warn to make sure DB and tables are created before running create_superuser and create_tier scripts
- remind to pass "api/v1/..." in the path for rate_limiter
- add "..._first_..." in the name name for scripts
Copy file name to clipboardExpand all lines: README.md
+34-10Lines changed: 34 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -325,6 +325,10 @@ poetry run uvicorn app.main:app --reload
325
325
326
326
### 4.3 Creating the first superuser
327
327
#### 4.3.1 Docker Compose
328
+
329
+
> **Warning**
330
+
> Make sure DB and tables are created before running create_superuser (db should be running and the api should run at least once before)
331
+
328
332
If you are using docker compose, you should uncomment this part of the docker-compose.yml:
329
333
```
330
334
# #-------- uncomment to create first superuser --------
@@ -379,7 +383,11 @@ poetry run python -m scripts.create_first_superuser
379
383
```
380
384
381
385
### 4.3.3 Creating the first tier
382
-
To create the first tier it's similar, you just replace `create_superuser` for `create_tier`. If using `docker compose`, do not forget to uncomment the `create_tier` service in `docker-compose.yml`.
386
+
387
+
> **Warning**
388
+
> Make sure DB and tables are created before running create_tier (db should be running and the api should run at least once before)
389
+
390
+
To create the first tier it's similar, you just replace `create_superuser` for `create_tier` service or `create_first_superuser` to `create_first_tier` for scripts. If using `docker compose`, do not forget to uncomment the `create_tier` service in `docker-compose.yml`.
383
391
384
392
### 4.4 Database Migrations
385
393
While in the `src` folder, run Alembic migrations:
@@ -407,7 +415,7 @@ First, you may want to take a look at the project structure and understand what
407
415
└── src # Source code directory.
408
416
├── __init__.py # Initialization file for the src package.
409
417
├── alembic.ini # Configuration file for Alembic (database migration tool).
410
-
├── poetry.lock
418
+
├── poetry.lock# Poetry lock file specifying exact versions of dependencies.
411
419
├── pyproject.toml # Configuration file for Poetry, lists project dependencies.
412
420
│
413
421
├── app # Main application directory.
@@ -419,13 +427,15 @@ First, you may want to take a look at the project structure and understand what
419
427
│ │ ├── __init__.py
420
428
│ │ ├── dependencies.py # Defines dependencies that can be reused across the API endpoints.
421
429
│ │ ├── exceptions.py # Contains custom exceptions for the API.
422
-
│ │ ├── paginated.py #Provides utilities for paginated responses in APIs
430
+
│ │ ├── paginated.py #Utilities for paginated responses in APIs.
423
431
│ │ │
424
432
│ │ └── v1 # Version 1 of the API.
425
433
│ │ ├── __init__.py
426
434
│ │ ├── login.py # API routes related to user login.
427
435
│ │ ├── posts.py # API routes related to posts.
436
+
│ │ ├── rate_limits.py # API routes for rate limiting features.
428
437
│ │ ├── tasks.py # API routes related to background tasks.
438
+
│ │ ├── tiers.py # API routes for handling different user tiers.
429
439
│ │ └── users.py # API routes related to user management.
430
440
│ │
431
441
│ ├── core # Core utilities and configurations for the application.
@@ -434,28 +444,39 @@ First, you may want to take a look at the project structure and understand what
│ │ ├── crud_tier.py # CRUD operations for user tiers.
446
460
│ │ ├── crud_users.py # CRUD operations for users.
447
461
│ │ └── helper.py # Helper functions for CRUD operations.
448
462
│ │
449
463
│ ├── models # ORM models for the application.
450
464
│ │ ├── __init__.py
451
465
│ │ ├── post.py # ORM model for posts.
466
+
│ │ ├── rate_limit.py # ORM model for rate limiting configurations.
467
+
│ │ ├── tier.py # ORM model for user tiers.
452
468
│ │ └── user.py # ORM model for users.
453
469
│ │
454
-
│ └── schemas # Pydantic schemas for data validation.
455
-
│ ├── __init__.py
456
-
│ ├── job.py # Schemas related to background jobs.
457
-
│ ├── post.py # Schemas related to posts.
458
-
│ └── user.py # Schemas related to users.
470
+
│ ├── schemas # Pydantic schemas for data validation.
471
+
│ │ ├── __init__.py
472
+
│ │ ├── job.py # Schemas related to background jobs.
473
+
│ │ ├── post.py # Schemas related to posts.
474
+
│ │ ├── rate_limit.py # Schemas for rate limiting configurations.
475
+
│ │ ├── tier.py # Schemas for user tiers.
476
+
│ │ └── user.py # Schemas related to users.
477
+
│ │
478
+
│ └── logs # Directory for log files.
479
+
│ └── app.log # Application log file.
459
480
│
460
481
├── migrations # Directory for Alembic migrations.
461
482
│ ├── README # General info and guidelines for migrations.
@@ -467,14 +488,14 @@ First, you may want to take a look at the project structure and understand what
467
488
│
468
489
├── scripts # Utility scripts for the project.
469
490
│ ├── __init__.py
470
-
│ └── create_first_superuser.py # Script to create the first superuser in the application.
491
+
│ ├── create_first_superuser.py # Script to create the first superuser in the application.
492
+
│ └── create_first_tier.py # Script to create the first user tier in the application.
471
493
│
472
494
└── tests # Directory containing all the tests.
473
495
├── __init__.py # Initialization file for the tests package.
474
496
├── conftest.py # Configuration and fixtures for pytest.
475
497
├── helper.py # Helper functions for writing tests.
476
498
└── test_user.py # Tests related to the user model and endpoints.
477
-
478
499
```
479
500
480
501
### 5.2 Database Model
@@ -1037,6 +1058,9 @@ And a `pro` tier:
1037
1058
1038
1059
Then I'll associate a `rate_limit` for the path `api/v1/tasks/task` for each of them, I'll associate a `rate limit` for the path `api/v1/tasks/task`.
1039
1060
1061
+
> **Warning**
1062
+
> Do not forget to add `api/v1/...` or any other prefix to the beggining of your path. For the structure of the boilerplate, `api/v1/<rest_of_the_path>`
1063
+
1040
1064
1 request every hour (3600 seconds) for the free tier:
0 commit comments