Commit Graph

290 Commits

Author SHA1 Message Date
Felipe Cardoso
9e7bc35a2f Remove unused frontend_dev_modules volume from dev config
The `frontend_dev_modules` volume was redundant and is no longer being used in the development workflow. This change simplifies the `docker-compose.dev.yml` file by eliminating unnecessary configuration.
2025-03-05 10:31:46 +01:00
Felipe Cardoso
eba94f981c Update font to Inter and add Providers to RootLayout
Some checks failed
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Has been skipped
Build and Push Docker Images / build-frontend (push) Failing after 43s
Replaced Geist fonts with Inter for better design consistency. Integrated a Providers component into RootLayout to manage app-wide context. Updated metadata to reflect the branding of "EventSpace - Family Celebrations".
2025-03-05 10:30:38 +01:00
Felipe Cardoso
eaa2561a46 Update node_modules mount path in docker-compose.dev.yml
Replaces the named volume `frontend_dev_modules` with a direct path `/app/node_modules`. This change simplifies development setup and ensures consistency across environments.
2025-03-05 10:30:16 +01:00
Felipe Cardoso
4525dd21be Add global providers for react-query, theming, and auth
Introduce a new Providers component to manage global contexts including react-query, theme switching, and authentication. Added necessary dependencies: `@tanstack/react-query-devtools` and `next-themes`, and configured default options for react-query.
2025-03-05 10:17:29 +01:00
Felipe Cardoso
c61ad52331 Refactor auto-generated schemas and types formatting
Some checks failed
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Has been skipped
Build and Push Docker Images / build-frontend (push) Failing after 42s
Updated the formatting for auto-generated schemas, types, and related files to adhere to consistent coding standards (e.g., double quotes, indentation). No functional changes were made, ensuring behavior remains identical.
2025-03-05 10:13:33 +01:00
Felipe Cardoso
ffa3f2ffd3 Add auto-generated API client and schema files
Some checks failed
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Has been skipped
Build and Push Docker Images / build-frontend (push) Failing after 42s
Integrated auto-generated TypeScript client and schemas using @hey-api/openapi-ts for API communication. Includes type definitions, API endpoint handlers, and React Query integration for enhanced type safety and developer experience.
2025-03-05 10:09:48 +01:00
Felipe Cardoso
a7504f6876 Add authentication context and provider for user management
Introduce `AuthContext` with login, logout, and token management. Includes protected route handling, token refresh logic, and user session persistence via React Context API. Prepares the app for authentication workflows.
2025-03-05 10:09:19 +01:00
Felipe Cardoso
761254f940 Add OpenAPI TypeScript config and update dependencies
Introduced `openapi-ts.config.ts` to generate client code from the OpenAPI spec. Updated several dependencies to enable OpenAPI integration, including `@hey-api` plugins, `axios`, and `@tanstack/react-query`. These changes set up the project for streamlined API access using autogenerated TypeScript clients.
2025-03-05 10:09:14 +01:00
Felipe Cardoso
b019511a1f Add operation_id to all API route handlers
This commit adds the `operation_id` parameter to all relevant API endpoints in the `auth` routes. These identifiers enhance API documentation and make routes easier to distinguish in tools like Swagger or OpenAPI. No functionality is altered, but these additions improve clarity and maintainability.
2025-03-05 09:16:27 +01:00
Felipe Cardoso
4f06c95eda Refactor tests to remove redundant user validation cases.
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 51s
Build and Push Docker Images / build-frontend (push) Has been skipped
Removed tests for missing `first_name` and `last_name` in `test_user` as database integrity constraints already ensure these validations. This reduces duplication and simplifies the test suite.
2025-03-04 19:11:13 +01:00
Felipe Cardoso
a88ebd40a7 Add database initialization for first superuser setup
All checks were successful
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Successful in 51s
Build and Push Docker Images / build-frontend (push) Has been skipped
Introduced a script to create the initial superuser during app startup if none exists. Updated the entrypoint to call this script and added stricter logging for passlib. Adjusted .env.template for a stronger default superuser password.
2025-03-04 18:54:00 +01:00
Felipe Cardoso
67f1dfbd9d Make last_name optional and add default for first_name.
Updated the schemas and models to make `last_name` optional and set a default value of "user" for `first_name`. This change enhances flexibility for user data handling and ensures proper defaults when values are not provided.
2025-03-04 18:53:49 +01:00
Felipe Cardoso
7d9f4ee4b2 Add CRUD operations for users with tests and fixtures
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 54s
Build and Push Docker Images / build-frontend (push) Has been skipped
Implemented user CRUD operations including creation, retrieval, updating, and deletion through a generic CRUD base class. Enhanced user schemas with additional attributes and created tests to verify functionality, covering edge cases such as duplicates and pagination. Updated the test suite with new fixtures and methods to support the tests.
2025-03-04 18:33:33 +01:00
Felipe Cardoso
c6fe040f21 Add authentication routes and tests for API
Some checks failed
Build and Push Docker Images / build-frontend (push) Blocked by required conditions
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Has been cancelled
Implemented comprehensive authentication endpoints including user registration, login, token refresh, password change, and user info retrieval. Added extensive test cases for these endpoints to ensure functionality and error handling.
2025-03-04 18:33:16 +01:00
Felipe Cardoso
5ddf5cab6d Remove unused token schemas from the backend.
Eliminated redundant token-related schemas to simplify the codebase. These models were not actively utilized and their removal helps improve maintainability and reduce clutter in the project.
2025-03-04 18:08:05 +01:00
Felipe Cardoso
f2851bcb7a Refactor phone number validation and enhance test coverage
All checks were successful
Build and Push Docker Images / changes (push) Successful in 6s
Build and Push Docker Images / build-backend (push) Successful in 54s
Build and Push Docker Images / build-frontend (push) Has been skipped
Improved phone number validation logic with stricter rules and better error messages in `UserBase`. Updated access token expiration to 1 day in config. Added extensive tests for phone number validation, including valid and invalid cases across different formats.
2025-03-04 17:34:15 +01:00
Felipe Cardoso
b6006d5218 Refactor auth dependencies and add comprehensive tests
All checks were successful
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Successful in 52s
Build and Push Docker Images / build-frontend (push) Has been skipped
Moved `auth` module from `dependencies.py` to `dependencies/auth.py` for better organization. Added extensive unit tests for authentication services and API dependencies to ensure robust verification of users, tokens, and permissions.
2025-03-02 11:08:06 +01:00
Felipe Cardoso
cd92cd9780 Remove token revocation logic and unused dependencies
Eliminated the `RevokedToken` model and associated logic for managing token revocation. Removed unused files, related tests, and outdated dependencies in authentication modules. Simplified token decoding, user validation, and dependency injection by streamlining the flow and enhancing maintainability.
2025-03-02 11:04:12 +01:00
Felipe Cardoso
453016629f Refactor and enhance token decoding error handling
Improved the `decode_token` function to clarify and extend error handling for token validation and decoding. Enhanced error messages for invalid tokens, added checks for missing claims, and ensured clear differentiation of failure scenarios. Updated imports and added a `scope` field to token response for completeness.
2025-02-28 19:05:08 +01:00
Felipe Cardoso
0bc9263d24 Refactor and enhance token decoding error handling
Improved the `decode_token` function to clarify and extend error handling for token validation and decoding. Enhanced error messages for invalid tokens, added checks for missing claims, and ensured clear differentiation of failure scenarios. Updated imports and added a `scope` field to token response for completeness.
2025-02-28 18:12:39 +01:00
Felipe Cardoso
8814dc931f Add token revocation mechanism and support for logout APIs
This commit introduces a system to revoke tokens by storing their `jti` in a new `RevokedToken` model. It includes APIs for logging out (revoking a current token) and logging out from all devices (revoking all tokens). Additionally, token validation now checks revocation status during the decode process.
2025-02-28 17:45:33 +01:00
Felipe Cardoso
aa77752981 Refactor imports and remove unused code in test_security.py
Cleaned up unused imports including `timezone` and `ExpiredSignatureError`. Streamlined the import structure to improve readability and maintainability. These changes do not affect functionality but enhance code clarity.
2025-02-28 17:39:39 +01:00
Felipe Cardoso
af53b52c0c Refactor token creation logic and fix datetime usage
Adjusted `datetime.utcnow` to `datetime.now` for consistency and refactored token creation functions for cleaner structure. Removed duplicated `create_access_token` and `create_refresh_token` definitions by consolidating them into a single location.
2025-02-28 17:32:20 +01:00
Felipe Cardoso
3912537477 Handle additional JWT and JOSE error cases in token validation.
Expanded exception handling to cover more specific JWT and JOSE-related errors, including signature verification failures and malformed tokens. This ensures better error messaging and robustness in token validation.
2025-02-28 17:01:57 +01:00
Felipe Cardoso
548880b468 Refactor token handling and introduce token revocation logic
Updated `decode_token` for stricter validation of token claims and explicit error handling. Added utilities for token revocation and verification, improving
2025-02-28 16:57:57 +01:00
Felipe Cardoso
c3a55b26c7 Add tests for auth dependencies and security utilities
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 49s
Build and Push Docker Images / build-frontend (push) Has been skipped
Introduced unit tests for `get_current_user`, `get_current_active_user`, and security functions like token creation and decoding. Also refactored imports for consistency and cleaned up unused or misplaced code to improve maintainability.
2025-02-28 16:34:59 +01:00
Felipe Cardoso
43df9d73b0 Add foundational user authentication and registration system
Introduces schemas for user management, token handling, and password hashing. Implements routes for user registration, login, token refresh, and user info retrieval. Sets up authentication dependencies and integrates the API router with the application.
2025-02-28 16:18:03 +01:00
Felipe Cardoso
290d91d395 Add MediaType and MediaPurpose to model exports
MediaType and MediaPurpose have been added to the `__all__` exports in the `models` module. This ensures they are properly exposed for import and use throughout the application.
2025-02-28 16:17:44 +01:00
Felipe Cardoso
1fd1144bc1 Add and extend test coverage for models and their methods
All checks were successful
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 49s
Build and Push Docker Images / build-frontend (push) Has been skipped
Enhanced test coverage includes `repr` methods, model functionality, and validation logic for key models like `GiftItem`, `GiftCategory`, `EventMedia`, `RSVP`, and `GiftPurchase`. Refactored and added fixtures to support comprehensive testing scenarios. Addresses validation for gift reordering and updates `EventMedia` representation format for consistency.
2025-02-28 15:57:32 +01:00
Felipe Cardoso
c15c55d691 Add tests for EmailTemplate and NotificationLog models
Introduced comprehensive unit tests for EmailTemplate and NotificationLog, including creation, field validation, and custom methods. Added relevant test fixtures to support these models and expanded `conftest.py` for reusability. Validates functionality and maintains model integrity.
2025-02-28 15:16:23 +01:00
Felipe Cardoso
b8c7d63d91 Add ActivityLog fixtures and tests for logging activities
Introduce a new pytest fixture for creating ActivityLog entries. Add comprehensive tests to verify ActivityLog creation and logging functionality, including user, event, and guest activities. Ensure proper test coverage for key methods and representations.
2025-02-28 15:06:50 +01:00
Felipe Cardoso
d442182ed0 Add tests for Guest model and corresponding fixtures
Introduce unit tests for the Guest model covering properties, methods, and behaviors such as creation, status updates, and permissions. Add `guest_fixture` in `conftest.py` to streamline reusable test setup for Guest instances.
2025-02-28 15:01:13 +01:00
Felipe Cardoso
0bbd74ff50 Add tests and fixture for EventTheme model
Introduce a new pytest fixture for creating EventTheme instances and add comprehensive unit tests covering its properties, relationships, and behaviors. These changes improve test coverage and ensure the EventTheme model functions as expected.
2025-02-28 14:59:35 +01:00
Felipe Cardoso
97155f4b6b Add validation for display_order and EventMedia tests
Introduce a `validate_display_order` method to ensure a default value of 0 for `display_order`. Extend testing infrastructure with fixtures and unit tests for `EventMedia` to validate properties, metadata, and default behaviors.
2025-02-28 14:55:59 +01:00
Felipe Cardoso
841bb7f56d Add unit tests for RSVP model
This commit introduces comprehensive unit tests for the RSVP model, including creation, status updates, attendance checks, unique constraints, and dietary requirements handling. These tests ensure the RSVP model
2025-02-28 14:41:53 +01:00
Felipe Cardoso
38d5ac7c63 Add unit tests for GiftItem, GiftCategory, and GiftPurchase models
Introduced comprehensive test coverage for GiftItem, GiftCategory, and GiftPurchase models to validate core functionality such as creation, updates, deletions, and derived properties. Also updated the `total_gifts` method in `GiftCategory` to calculate the total requested quantity rather than the count of gifts.
2025-02-28 14:41:43 +01:00
Felipe Cardoso
712f1ddcb2 Add tests 2025-02-28 14:25:49 +01:00
Felipe Cardoso
180c4c2c09 Add tests for Event model and new mock_user fixture
All checks were successful
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Successful in 51s
Build and Push Docker Images / build-frontend (push) Has been skipped
Introduce comprehensive tests for the Event model, covering creation, updates, deletions, relationships, defaults, and constraints. Added the `mock_user` fixture to streamline user-related test setups and ensure proper linkage between users and events. Improves test coverage and ensures model behavior consistency.
2025-02-28 14:25:00 +01:00
Felipe Cardoso
82e0f192b1 Add pytest fixture for database session in tests
Introduce a `db_session` pytest fixture to provide a fresh SQLite in-memory database for each test function. This ensures isolated and consistent database state across tests by setting up and tearing down the database automatically.
2025-02-28 14:19:58 +01:00
Felipe Cardoso
1d51e2ad20 Add pytest fixture for database session in tests
Introduce a `db_session` pytest fixture to provide a fresh SQLite in-memory database for each test function. This ensures isolated and consistent database state across tests by setting up and tearing down the database automatically.
2025-02-28 14:19:39 +01:00
Felipe Cardoso
4155d9f8a6 Add comprehensive test cases for User model
All checks were successful
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Successful in 52s
Build and Push Docker Images / build-frontend (push) Has been skipped
This commit introduces multiple test cases for the User model, covering creation, updating, deletion, unique constraints, required fields, default values, string representation, and handling of complex JSON preferences. These tests help ensure the model behaves as
2025-02-28 12:31:47 +01:00
Felipe Cardoso
5f9a63dd07 Refactor database module and add testing utilities
Simplify database module by re-organizing engine creation, session handling, and removing redundant methods. Introduce SQLite compatibility for testing and add a utility module for test database setup and teardown. Integrate initial unit tests for user models and update dependencies for security and testing.
2025-02-28 12:31:10 +01:00
Felipe Cardoso
5cd38c82e0 Refactor relationships in Event and User models
Clarify and fix relationship definitions by specifying foreign keys explicitly in User model. Add new relationships for gift categories and email templates to the Event model, and comment out unused EventUpdate relationship. These changes ensure better structure and future maintainability.
2025-02-28 12:30:25 +01:00
Felipe Cardoso
28656d6233 Refactor database handling and enhance connection management.
Introduced robust database connection configuration with PostgreSQL-specific tuning, connection pooling, and performance metrics logging. Added utility functions to manage database health checks, initialization, and cleanup at application lifecycle stages. Improved error handling with logging support for transactions and slow queries.
2025-02-28 11:22:42 +01:00
Felipe Cardoso
b3689fd6c4 Rename metadata fields for clarity and specificity
Updated `metadata` field names to `media_metadata` and `notification_metadata` in the eventspace ER schema. This improves clarity by providing more context-specific naming for better understanding and maintainability.
2025-02-28 09:58:50 +01:00
Felipe Cardoso
636e278db7 Rename metadata fields for clarity and specificity
Updated `metadata` field names to `media_metadata` and `notification_metadata` in the eventspace ER schema. This improves clarity by providing more context-specific naming for better understanding and maintainability.
2025-02-28 09:35:02 +01:00
Felipe Cardoso
fd676f850b Add initial models and database tables
All checks were successful
Build and Push Docker Images / changes (push) Successful in 5s
Build and Push Docker Images / build-backend (push) Successful in 47s
Build and Push Docker Images / build-frontend (push) Has been skipped
This migration introduces all initial database models and their respective tables, relationships, and constraints. It includes entities such as users, events, guests, themes, media, and various related entities to support application functionality. This serves as a foundational schema for the project.
2025-02-28 09:22:20 +01:00
Felipe Cardoso
a60eb045b4 Refactor Alembic setup and add migration helper script.
Updated Alembic configuration and folder structure to reference the `app` module. Introduced a new `migrate.py` script to manage migrations efficiently with commands for generating, applying, and inspecting migrations. Adjusted `env.py` to ensure proper model imports and use environment-driven database URLs.
2025-02-28 09:22:05 +01:00
Felipe Cardoso
dfeb10c351 Refactor config and database handling.
Move configuration logic to a more modular structure and enhance database URL generation using individual components from environment variables. Adjust database initialization to utilize the updated settings for improved maintainability and clarity.
2025-02-28 09:21:48 +01:00
Felipe Cardoso
632330b4ac Refactor models to improve consistency and relationships
Updated `Base` import to use centralized `app.core.database.Base` for consistency. Enhanced `TimestampMixin` and `UUIDMixin` with docstrings for clarity. Fixed metadata reference in `guest_gifts` table and added relationships in `email_template`.
2025-02-28 09:21:02 +01:00