Skip to content

Commit 3e55c7e

Browse files
authored
Update README.md
- 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
1 parent 1dbf87d commit 3e55c7e

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

README.md

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ poetry run uvicorn app.main:app --reload
325325
326326
### 4.3 Creating the first superuser
327327
#### 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+
328332
If you are using docker compose, you should uncomment this part of the docker-compose.yml:
329333
```
330334
# #-------- uncomment to create first superuser --------
@@ -379,7 +383,11 @@ poetry run python -m scripts.create_first_superuser
379383
```
380384

381385
### 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`.
383391

384392
### 4.4 Database Migrations
385393
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
407415
└── src # Source code directory.
408416
├── __init__.py # Initialization file for the src package.
409417
├── alembic.ini # Configuration file for Alembic (database migration tool).
410-
├── poetry.lock
418+
├── poetry.lock # Poetry lock file specifying exact versions of dependencies.
411419
├── pyproject.toml # Configuration file for Poetry, lists project dependencies.
412420
413421
├── app # Main application directory.
@@ -419,13 +427,15 @@ First, you may want to take a look at the project structure and understand what
419427
│ │ ├── __init__.py
420428
│ │ ├── dependencies.py # Defines dependencies that can be reused across the API endpoints.
421429
│ │ ├── 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.
423431
│ │ │
424432
│ │ └── v1 # Version 1 of the API.
425433
│ │ ├── __init__.py
426434
│ │ ├── login.py # API routes related to user login.
427435
│ │ ├── posts.py # API routes related to posts.
436+
│ │ ├── rate_limits.py # API routes for rate limiting features.
428437
│ │ ├── tasks.py # API routes related to background tasks.
438+
│ │ ├── tiers.py # API routes for handling different user tiers.
429439
│ │ └── users.py # API routes related to user management.
430440
│ │
431441
│ ├── 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
434444
│ │ ├── config.py # Application configuration settings.
435445
│ │ ├── database.py # Database connectivity and session management.
436446
│ │ ├── exceptions.py # Contains core custom exceptions for the application.
447+
│ │ ├── logger.py # Logging utilities.
437448
│ │ ├── models.py # Base models for the application.
438449
│ │ ├── queue.py # Utilities related to task queues.
450+
│ │ ├── rate_limit.py # Rate limiting utilities and configurations.
439451
│ │ ├── security.py # Security utilities like password hashing and token generation.
440452
│ │ └── setup.py # File defining settings and FastAPI application instance definition.
441453
│ │
442454
│ ├── crud # CRUD operations for the application.
443455
│ │ ├── __init__.py
444456
│ │ ├── crud_base.py # Base CRUD operations class that can be extended by other CRUD modules.
445457
│ │ ├── crud_posts.py # CRUD operations for posts.
458+
│ │ ├── crud_rate_limit.py # CRUD operations for rate limiting configurations.
459+
│ │ ├── crud_tier.py # CRUD operations for user tiers.
446460
│ │ ├── crud_users.py # CRUD operations for users.
447461
│ │ └── helper.py # Helper functions for CRUD operations.
448462
│ │
449463
│ ├── models # ORM models for the application.
450464
│ │ ├── __init__.py
451465
│ │ ├── post.py # ORM model for posts.
466+
│ │ ├── rate_limit.py # ORM model for rate limiting configurations.
467+
│ │ ├── tier.py # ORM model for user tiers.
452468
│ │ └── user.py # ORM model for users.
453469
│ │
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.
459480
460481
├── migrations # Directory for Alembic migrations.
461482
│ ├── 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
467488
468489
├── scripts # Utility scripts for the project.
469490
│ ├── __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.
471493
472494
└── tests # Directory containing all the tests.
473495
├── __init__.py # Initialization file for the tests package.
474496
├── conftest.py # Configuration and fixtures for pytest.
475497
├── helper.py # Helper functions for writing tests.
476498
└── test_user.py # Tests related to the user model and endpoints.
477-
478499
```
479500

480501
### 5.2 Database Model
@@ -1037,6 +1058,9 @@ And a `pro` tier:
10371058

10381059
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`.
10391060

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+
10401064
1 request every hour (3600 seconds) for the free tier:
10411065

10421066
<p align="left">

0 commit comments

Comments
 (0)