Sobes.tech
Junior — Middle

Share your experience of implementing your projects and tell about the key decisions you made.

sobes.tech AI

Answer from AI

In my projects, I often use a modular approach and follow SOLID principles for maintainable code. For example, in one of my Python projects, I implemented a REST API using Flask and SQLAlchemy.

Key decisions:

  • Using Blueprints to separate logic into modules.
  • Setting up database migrations with Alembic for easy schema management.
  • Implementing JWT for user authentication and authorization.
  • Logging and error handling with custom handlers.

Example code for creating a JWT token:

import jwt
from datetime import datetime, timedelta

def create_token(user_id, secret_key):
    payload = {
        'user_id': user_id,
        'exp': datetime.utcnow() + timedelta(hours=1)
    }
    token = jwt.encode(payload, secret_key, algorithm='HS256')
    return token

This approach made the project scalable and easy to maintain.