-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.txt
112 lines (68 loc) · 3.98 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
API backend for managing posts using FastAPI and Tortoise ORM(async) and uvicorn server. The project involves a role-based authorization with three main roles: Admin, Ordinary User, and Public. In the SQLite database, there are two users predefined:
COMMAND uvicorn main:app --reload
The database as at now contains posts and two users
Admin User:
Username: admin
Password: admin123
Privileges: Create, View, Update, Delete, and React to posts
Ordinary User:
Username: johndoe
Password: test123
Privileges: View and React to posts
Public:
Privileges: View posts (no ability to react to or update posts)
Also includes Oauth2 based authentication
Includes Requets Throtting to a maximum of 10 requests per minute in base endpoint(/) and get_posts endpoint (/posts/) limiting and CSRF protection
Includes unit tests for the main endpoints in auth and posts subapps
Includes CSRF protection
content-app/
│
├── auth/
│ ├── models.py (Database models for authentication)
│ ├── crud.py (CRUD operations for authentication)
│ └── schemas.py (Pydantic schemas for authentication)
│
├── posts/
│ ├── models.py (Database models for posts)
│ ├── crud.py (CRUD operations for posts)
│ └── schemas.py (Pydantic schemas for posts)
│
├── main.py (Main FastAPI application file)
│
├── conftest.py (Configuration for pytest)
│
├── settings.py (Application configuration settings)
│
├── database.sqlite (SQLite database file)
│
├── test_auth.py (Unit tests for authentication)
│
├── test_posts.py (Unit tests for posts)
│
├── README.txt (Project README documentation)
│
├── .env (Environment configuration file)
│
├── utils/
│ └── rate_limiter.py (Utility for rate limiting)
│
└── requirements.txt (List of project dependencies)
Descriptions:
auth/models.py: Contains database models related to authentication, such as User models.
auth/crud.py: Implements CRUD (Create, Read, Update, Delete) operations for authentication, including user creation and retrieval.
auth/schemas.py: Contains Pydantic schemas for authentication, which define data structures for user input and output.
posts/models.py: Contains database models related to posts, including Post models.
posts/crud.py: Implements CRUD operations for managing posts, including creation, retrieval, and deletion of posts.
posts/schemas.py: Contains Pydantic schemas for posts, defining data structures for creating and displaying posts.
main.py: The main FastAPI application file where you define routes, middleware, and the main application instance.
conftest.py: Configuration for pytest, enabling unit tests for your application.
settings.py: Application configuration settings, including database configurations, security settings, and more.
database.sqlite: The SQLite database file where your application's data is stored.
test_auth.py: Unit tests specific to the authentication functionality.
test_posts.py: Unit tests for testing the posts management functionality.
README.txt: Documentation file providing information about your project, how to set it up, and how to use it.
.env: Environment configuration file for storing environment-specific settings or secrets.
utils/rate_limiter.py: A utility module for implementing rate limiting in your application.
requirements.txt: A file listing all project dependencies for easy installation using tools like pip.
This project structure allows you to organize your FastAPI CMS backend neatly, separating authentication and posts management concerns while also including necessary utilities and testing infrastructure.
This structure reflects your use of Tortoise ORM for async CRUD operations, async-pytest for pytest compatibility with Tortoise ORM, and FastAPI OAuth 2.0 for authentication. It maintains the separation of concerns between authentication and posts management, includes unit tests compatible with async-pytest, and provides a clear project organization.