Project Structure
For best practices, here's the recommended folder structure for a Fenrir project:
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 | my_fenrir_app/
│
├── app.py # Main application file
├── requirements.txt # Python dependencies
├── README.md # Project documentation
├── .gitignore # Git configuration
│
├── templates/ # HTML templates folder
│ ├── index.html # Home page
│ ├── base.html # Base template (for inheritance)
│ ├── 404.html # Custom 404 page
│ ├── 500.html # Custom 500 page
│ └── blog/ # Subfolder for specific templates
│ ├── list.html
│ └── detail.html
│
├── static/ # Static files folder
│ ├── css/
│ │ └── style.css
│ ├── js/
│ │ └── script.js
│ ├── images/
│ └── favicon.ico
│
├── routes/ # Routes organization
│ ├── __init__.py
│ ├── users.py
│ ├── products.py
│ └── api.py
│
├── models/ # Pydantic models
│ ├── __init__.py
│ ├── user.py
│ └── product.py
│
├── utils/ # Utility functions
│ ├── __init__.py
│ ├── validators.py
│ └── helpers.py
│
├── tests/ # Test cases
│ ├── __init__.py
│ ├── test_routes.py
│ ├── test_models.py
│ └── conftest.py # Pytest configuration
│
└── uploads/ # File uploads (optional)
|
Structure Explanation:
- app.py: Main file containing Fenrir application initialization
- templates/: All Jinja2 HTML files stored here
- static/: CSS, JavaScript, and images stored here
- routes/: Blueprints and route handlers organized in separate files
- models/: Pydantic models for data validation
- utils/: Helper functions and custom validators
- tests/: Unit tests and integration tests
- uploads/: Folder for storing user-uploaded files
Example requirements.txt:
| fenrir-framework>=4.4.0
pydantic>=2.0.0
jinja2>=3.0.0
asteri>=3.0.0
pytest>=7.4.0
pytest-asyncio>=0.21.0
python-multipart>=0.0.18
|