chore: update project structure and add testing framework

This commit is contained in:
Davidson Gomes
2025-04-28 20:41:10 -03:00
parent 7af234ef48
commit e7e030dfd5
49 changed files with 1261 additions and 619 deletions

View File

@@ -17,9 +17,16 @@
```
src/
├── api/
│ ├── routes.py # API routes definition
│ ├── auth_routes.py # Authentication routes (login, registration, etc.)
── admin_routes.py # Protected admin routes
│ ├── __init__.py # Package initialization
│ ├── admin_routes.py # Admin routes for management interface
── agent_routes.py # Routes to manage agents
│ ├── auth_routes.py # Authentication routes (login, registration)
│ ├── chat_routes.py # Routes for chat interactions with agents
│ ├── client_routes.py # Routes to manage clients
│ ├── contact_routes.py # Routes to manage contacts
│ ├── mcp_server_routes.py # Routes to manage MCP servers
│ ├── session_routes.py # Routes to manage chat sessions
│ └── tool_routes.py # Routes to manage tools for agents
├── config/
│ ├── database.py # Database configuration
│ └── settings.py # General settings
@@ -30,18 +37,21 @@ src/
│ └── models.py # SQLAlchemy models
├── schemas/
│ ├── schemas.py # Main Pydantic schemas
│ ├── chat.py # Chat schemas
│ ├── user.py # User and authentication schemas
│ └── audit.py # Audit logs schemas
├── services/
│ ├── agent_service.py # Business logic for agents
│ ├── agent_runner.py # Agent execution logic
│ ├── auth_service.py # JWT authentication logic
│ ├── audit_service.py # Audit logs logic
│ ├── client_service.py # Business logic for clients
│ ├── contact_service.py # Business logic for contacts
│ ├── mcp_server_service.py # Business logic for MCP servers
│ ├── tool_service.py # Business logic for tools
│ ├── user_service.py # User and authentication logic
│ ├── auth_service.py # JWT authentication logic
│ ├── email_service.py # Email sending service
── audit_service.py # Audit logs logic
── mcp_server_service.py # Business logic for MCP servers
│ ├── session_service.py # Business logic for chat sessions
│ ├── tool_service.py # Business logic for tools
│ └── user_service.py # User management logic
├── templates/
│ ├── emails/
│ │ ├── base_email.html # Base template with common structure and styles
@@ -49,7 +59,21 @@ src/
│ │ ├── password_reset.html # Password reset template
│ │ ├── welcome_email.html # Welcome email after verification
│ │ └── account_locked.html # Security alert for locked accounts
├── tests/
│ ├── __init__.py # Package initialization
│ ├── api/
│ │ ├── __init__.py # Package initialization
│ │ ├── test_auth_routes.py # Test for authentication routes
│ │ └── test_root.py # Test for root endpoint
│ ├── models/
│ │ ├── __init__.py # Package initialization
│ │ ├── test_models.py # Test for models
│ ├── services/
│ │ ├── __init__.py # Package initialization
│ │ ├── test_auth_service.py # Test for authentication service
│ │ └── test_user_service.py # Test for user service
└── utils/
├── logger.py # Logger configuration
└── security.py # Security utilities (JWT, hash)
```
@@ -63,6 +87,15 @@ src/
- Code examples in documentation must be in English
- Commit messages must be in English
### Project Configuration
- Dependencies managed in `pyproject.toml` using modern Python packaging standards
- Development dependencies specified as optional dependencies in `pyproject.toml`
- Single source of truth for project metadata in `pyproject.toml`
- Build system configured to use setuptools
- Pytest configuration in `pyproject.toml` under `[tool.pytest.ini_options]`
- Code formatting with Black configured in `pyproject.toml`
- Linting with Flake8 configured in `.flake8`
### Schemas (Pydantic)
- Use `BaseModel` as base for all schemas
- Define fields with explicit types
@@ -136,6 +169,28 @@ src/
- Indentation with 4 spaces
- Maximum of 79 characters per line
## Commit Rules
- Use Conventional Commits format for all commit messages
- Format: `<type>(<scope>): <description>`
- Types:
- `feat`: A new feature
- `fix`: A bug fix
- `docs`: Documentation changes
- `style`: Changes that do not affect code meaning (formatting, etc.)
- `refactor`: Code changes that neither fix a bug nor add a feature
- `perf`: Performance improvements
- `test`: Adding or modifying tests
- `chore`: Changes to build process or auxiliary tools
- Scope is optional and should be the module or component affected
- Description should be concise, in the imperative mood, and not capitalized
- Use body for more detailed explanations if needed
- Reference issues in the footer with `Fixes #123` or `Relates to #123`
- Examples:
- `feat(auth): add password reset functionality`
- `fix(api): correct validation error in client registration`
- `docs: update API documentation for new endpoints`
- `refactor(services): improve error handling in authentication`
## Best Practices
- Always validate input data
- Implement appropriate logging
@@ -163,6 +218,7 @@ src/
## Useful Commands
- `make run`: Start the server
- `make run-prod`: Start the server in production mode
- `make alembic-revision message="description"`: Create new migration
- `make alembic-upgrade`: Apply pending migrations
- `make alembic-downgrade`: Revert last migration
@@ -170,3 +226,8 @@ src/
- `make alembic-reset`: Reset database to initial state
- `make alembic-upgrade-cascade`: Force upgrade removing dependencies
- `make clear-cache`: Clean project cache
- `make seed-all`: Run all database seeders
- `make lint`: Run linting checks with flake8
- `make format`: Format code with black
- `make install`: Install project for development
- `make install-dev`: Install project with development dependencies