abinazebinoy commited on
Commit
56364a4
·
unverified ·
1 Parent(s): 80c2253

Add backend configuration system (#1)

Browse files

- Create Settings class with Pydantic validation
- Define file processing limits (50MB max, type restrictions)
- Add CORS configuration for frontend integration
- Create .env.example template for environment setup
- Update requirements.txt with core dependencies

Why: Centralized config prevents hardcoded values and enables
environment-based configuration for dev/prod.

backend/.env.example CHANGED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Server Configuration
2
+ DEBUG=False
3
+ HOST=0.0.0.0
4
+ PORT=8000
5
+
6
+ # File Processing
7
+ MAX_FILE_SIZE_MB=50
8
+
9
+ # CORS (Update with your frontend URL)
10
+ CORS_ORIGINS=["http://localhost:3000"]
11
+
12
+ # Future: Add API keys for AI models here
13
+ # OPENAI_API_KEY=your_key_here
14
+ # HUGGINGFACE_TOKEN=your_token_here
backend/core/config.py CHANGED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Application configuration management.
3
+ Uses environment variables for security-sensitive settings.
4
+ """
5
+ from pydantic_settings import BaseSettings
6
+ from typing import Optional
7
+
8
+
9
+ class Settings(BaseSettings):
10
+ """
11
+ Application settings loaded from environment variables.
12
+
13
+ Why Pydantic? Type validation, auto-documentation, easy testing.
14
+ """
15
+ # API Settings
16
+ API_TITLE: str = "VeriFile-X API"
17
+ API_VERSION: str = "0.1.0"
18
+ API_DESCRIPTION: str = "Privacy-preserving digital forensics platform"
19
+
20
+ # Server Settings
21
+ HOST: str = "0.0.0.0"
22
+ PORT: int = 8000
23
+ DEBUG: bool = False
24
+
25
+ # File Processing Limits (privacy + performance)
26
+ MAX_FILE_SIZE_MB: int = 50
27
+ ALLOWED_IMAGE_TYPES: list = ["image/jpeg", "image/png", "image/webp"]
28
+ ALLOWED_VIDEO_TYPES: list = ["video/mp4", "video/mpeg"]
29
+ ALLOWED_DOC_TYPES: list = ["application/pdf"]
30
+
31
+ # Security
32
+ CORS_ORIGINS: list = ["http://localhost:3000"] # Frontend URLs
33
+
34
+ class Config:
35
+ env_file = ".env"
36
+ case_sensitive = True
37
+
38
+
39
+ # Singleton pattern - one instance across app
40
+ settings = Settings()
backend/requirements.txt CHANGED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Web Framework
2
+ fastapi==0.109.0
3
+ uvicorn[standard]==0.27.0
4
+
5
+ # Configuration Management
6
+ pydantic==2.5.3
7
+ pydantic-settings==2.1.0
8
+ python-dotenv==1.0.0
9
+
10
+ # File Processing
11
+ python-magic==0.4.27
12
+ python-multipart==0.0.6
13
+
14
+ # Future AI/ML dependencies (add as needed)
15
+ # opencv-python==4.9.0.80
16
+ # tensorflow==2.15.0
17
+ # numpy==1.24.3