Best Practices

Recommended patterns and practices for fastappkit projects.

Project Organization

App Design

  1. One app per feature/domain
  2. Keep apps focused on a single responsibility
  3. Group related functionality together
  4. Use clear, descriptive names

  5. Clear boundaries

  6. Keep app boundaries clear
  7. Minimize cross-app dependencies
  8. Use internal apps for tightly coupled features

  9. External apps for reusability

  10. Design external apps to be reusable
  11. Keep dependencies minimal
  12. Document requirements clearly

Migration Strategies

Internal Apps

  1. Keep migrations focused
  2. One migration per logical change
  3. Clear migration messages
  4. Review migrations before applying

  5. Use migration order when needed

  6. Only if internal apps have dependencies
  7. Document dependencies clearly

  8. Test migrations

  9. Test upgrades in development
  10. Test downgrades to ensure reversibility
  11. Review SQL with fastappkit migrate preview

External Apps

  1. Version migrations
  2. Include migrations in package
  3. Version migrations with app version
  4. Document migration requirements

  5. Test independently

  6. Test migrations in external app project
  7. Test integration with core project
  8. Ensure compatibility

Settings Management

  1. Use environment variables
  2. Never hardcode sensitive values
  3. Use .env for development
  4. Use environment variables in production

  5. Validate settings

  6. Use Pydantic validators
  7. Provide clear error messages
  8. Set appropriate defaults

  9. Document custom settings

  10. Document all custom settings
  11. Explain purpose and usage
  12. Provide examples

Testing Strategies

  1. Test apps independently
  2. Test external apps in isolation
  3. Test internal apps with core
  4. Test integration

  5. Use validation

  6. Run fastappkit app validate regularly
  7. Fix validation errors immediately
  8. Review warnings

  9. Test migrations

  10. Test upgrades and downgrades
  11. Test in development first
  12. Backup before production migrations

Performance Considerations

  1. Lazy loading
  2. Apps are loaded on startup
  3. Minimize startup overhead
  4. Use async where appropriate

  5. Database connections

  6. Use connection pooling
  7. Configure appropriately for your database
  8. Monitor connection usage

  9. Route organization

  10. Keep routes organized
  11. Use appropriate prefixes
  12. Avoid deep nesting

Security

  1. Settings security
  2. Never commit .env files
  3. Use secure secret management
  4. Rotate secrets regularly

  5. Dependency management

  6. Update dependency versions regularly
  7. Pin versions for production
  8. Review security advisories

  9. Input validation

  10. Validate all inputs
  11. Use Pydantic models
  12. Sanitize user input

Learn More