Configuration Overview
Tesis Rutas uses environment variables for configuration. The application can read configuration from:- Environment variables (
.envfile or system variables) - Recommended for production - local_config.json - Optional for local development
The configuration system is defined in
src/config/settings.py and uses Pydantic Settings for validation.Required Environment Variables
MongoDB Configuration
Tesis Rutas uses MongoDB for data storage.Get MongoDB connection string
You can use:
- MongoDB Atlas (cloud) - Recommended
- Local MongoDB instance
- Create a free account at mongodb.com/cloud/atlas
- Create a new cluster
- Get your connection string (format:
mongodb+srv://username:[email protected]/)
Cloudinary Configuration
Cloudinary is used for image and media storage.Create Cloudinary account
- Sign up at cloudinary.com
- Navigate to your Dashboard
- Copy your Cloud Name, API Key, and API Secret
JWT Authentication
JWT tokens are used for user authentication and authorization.Configuration File Locations
Complete Configuration Example
Frontend Configuration
The frontend needs to know where the backend API is running.Development - Update API base URL
In your frontend code (typically in
src/config/api.js or similar), set:Verify Configuration
Test your configuration to ensure everything is set up correctly:Troubleshooting
MongoDB connection timeout
MongoDB connection timeout
Problem:
ServerSelectionTimeoutError when connecting to MongoDBSolutions:- Verify your
MONGO_URIis correct - Check that your IP address is whitelisted in MongoDB Atlas (Network Access)
- Ensure your database user has proper permissions
- Check your internet connection
Configuration not loading
Configuration not loading
Problem: Application can’t find configuration variablesSolutions:
- For
.envfile: Place it in the project root directory - For
local_config.json: Place it insrc/config/directory - Verify file names are exact (case-sensitive)
- Check that environment variables are properly formatted
Cloudinary upload fails
Cloudinary upload fails
Problem: Images fail to upload to CloudinarySolutions:
- Verify all three Cloudinary credentials are set correctly
- Check that your API key and secret have no extra spaces
- Ensure your Cloudinary account is active
JWT authentication not working
JWT authentication not working
Problem: Token validation failsSolutions:
- Ensure
JWT_SECRET_KEYis set and consistent across restarts - Verify
JWT_ALGORITHMis set toHS256 - Check that tokens haven’t expired (default: 60 minutes)
Next Steps
Run locally
Start the development server:
Deploy to production
Learn how to deploy your configured application