Worklog Week 3

Week 3 Objectives: Sprint 1 - Backend Foundation (Part 1)

  • Implement Authentication with Amazon Cognito
  • Build Domain Layer (Entities)
  • Implement Repository Layer with DynamoDB
  • Create Lambda handlers for Auth endpoints
  • Setup API Gateway with Cognito authorizer

Weekly Tasks:

DayTaskStartCompleteReference
MonSetup Amazon Cognito:
- Create User Pool with email/password
- Configure password policy
- Enable Google OAuth provider
- Create App Client
- Configure hosted UI
- Test signup/login flow
23/03/202623/03/2026Cognito User Pools
TueImplement Domain Layer:
- entities/user.py - User entity with validation
- entities/flashcard.py - Flashcard entity
- entities/session.py - Session entity
- entities/scenario.py - Scenario entity
- Value objects (Email, UserId, etc.)
- Domain exceptions
24/03/202624/03/2026Domain-Driven Design
WedImplement Repository Interfaces:
- repositories/user_repository.py - Abstract interface
- repositories/flashcard_repository.py
- repositories/session_repository.py
- Define repository methods (save, find, delete, etc.)
25/03/202625/03/2026Repository Pattern
ThuImplement DynamoDB Repository & Auth Use Cases:
- infrastructure/dynamodb/user_repository_impl.py
- Implement single-table design, PK/SK mapping
- use_cases/auth/signup_user.py, login_user.py, refresh_token.py
- Business logic validation
- Unit tests
26/03/202626/03/2026boto3 DynamoDB
FriImplement Lambda Handlers & API Gateway:
- handlers/auth/signup.py, login.py, refresh.py
- Configure REST API in SAM template
- Add Cognito authorizer, CORS
- Deploy and test endpoints
27/03/202627/03/2026API Gateway with Cognito

Week 3 Results:

1. Authentication System:

  • ✅ Cognito User Pool configured with email/password + Google OAuth
  • ✅ Signup flow working: email verification, password validation
  • ✅ Login flow returns ID token, access token, refresh token
  • ✅ Token refresh mechanism working

2. Domain Layer:

  • ✅ 4 core entities implemented with full validation
  • ✅ Value objects for type safety
  • ✅ Domain exceptions for error handling
  • ✅ Unit tests coverage > 90%

3. Repository Layer:

  • ✅ Abstract repository interfaces defined
  • ✅ DynamoDB implementation with single-table design
  • ✅ CRUD operations working correctly
  • ✅ Error handling and retry logic

4. Use Cases:

  • ✅ Auth use cases implemented with business logic
  • ✅ Input validation and sanitization
  • ✅ Proper error handling
  • ✅ Unit tests with mocked repositories

5. API Endpoints:

  • ✅ 3 auth endpoints deployed and working:
    • POST /auth/signup - User registration
    • POST /auth/login - User login
    • POST /auth/refresh - Token refresh
  • ✅ Cognito authorizer protecting endpoints
  • ✅ CORS configured correctly
  • ✅ Integration tests passing

Code Structure:

src/
├── domain/
│   ├── entities/
│   │   ├── user.py
│   │   ├── flashcard.py
│   │   ├── session.py
│   │   └── scenario.py
│   ├── value_objects/
│   │   ├── email.py
│   │   └── user_id.py
│   └── exceptions.py
├── use_cases/
│   └── auth/
│       ├── signup_user.py
│       ├── login_user.py
│       └── refresh_token.py
├── repositories/
│   ├── user_repository.py (interface)
│   └── ...
├── infrastructure/
│   ├── dynamodb/
│   │   ├── user_repository_impl.py
│   │   └── connection.py
│   └── cognito/
│       └── auth_service.py
└── handlers/
    └── auth/
        ├── signup.py
        ├── login.py
        └── refresh.py

Testing Results:

Unit Tests:

  • ✅ Domain entities: 25 tests, 100% pass
  • ✅ Use cases: 18 tests, 100% pass
  • ✅ Repositories: 15 tests, 100% pass
  • Total: 58 unit tests, 0 failures

Integration Tests:

  • ✅ Signup flow: Email verification working
  • ✅ Login flow: Tokens returned correctly
  • ✅ Protected endpoints: Authorizer working
  • ✅ Error cases: Proper error responses

Challenges and Solutions:

Challenge 1: Cognito token validation in Lambda

  • Solution: Use python-jose library to verify JWT tokens

Challenge 2: DynamoDB conditional writes for duplicate prevention

  • Solution: Use ConditionExpression with attribute_not_exists

Challenge 3: Lambda cold start slowing down first request

  • Solution: Optimize imports, lazy loading for heavy libraries

Challenge 4: Type hints with Python dynamic typing

  • Solution: Use mypy strict mode, Pydantic for validation

Challenge 5: Encountered some errors during first deployment

  • Solution: Debug step by step, reference documentation and ask mentor when needed

Next Week Plan (Sprint 1 - Week 4):

  • Implement Profile management (GET/PUT /profile)
  • Implement Flashcard CRUD operations
  • Setup frontend project with Next.js
  • Create basic UI components
  • Integrate frontend with Auth APIs
  • Attend regular team meetings to review progress