Skip to content

Commit 4fcf110

Browse files
committed
feat: enhance email and utility modules with new features
- Updated SMTP configuration in .env and docker-compose.override.yml to use MailHog for email testing - Added utils module with health check and test email endpoints - Implemented event handling for password reset requests, integrating with the email service - Improved email service to send password reset emails upon event trigger - Removed deprecated files and updated documentation to reflect new module structure These changes contribute to the ongoing development of the modular monolith architecture, enhancing email functionality and introducing utility endpoints for better service management.
1 parent df4a031 commit 4fcf110

30 files changed

Lines changed: 397 additions & 14021 deletions

.env

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ FIRST_SUPERUSER=admin@example.com
2323
FIRST_SUPERUSER_PASSWORD=SecureAdminPass123!
2424

2525
# Emails
26-
SMTP_HOST=
26+
SMTP_HOST=mailhog
2727
SMTP_USER=
2828
SMTP_PASSWORD=
2929
EMAILS_FROM_EMAIL=info@example.com
30-
SMTP_TLS=True
30+
SMTP_TLS=False
3131
SMTP_SSL=False
32-
SMTP_PORT=587
32+
SMTP_PORT=1025
3333

3434
# Postgres
35-
POSTGRES_SERVER=localhost
35+
POSTGRES_SERVER=db
3636
POSTGRES_PORT=5432
3737
POSTGRES_DB=app
3838
POSTGRES_USER=postgres

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ node_modules/
33
/test-results/
44
/playwright-report/
55
/blob-report/
6-
/playwright/.cache/
6+
/playwright/.cache/

CLAUDE.md

Lines changed: 0 additions & 162 deletions
This file was deleted.

README.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@
2424
- 🚢 Deployment instructions using Docker Compose, including how to set up a frontend Traefik proxy to handle automatic HTTPS certificates.
2525
- 🏭 CI (continuous integration) and CD (continuous deployment) based on GitHub Actions.
2626

27+
## Documentation
28+
29+
For comprehensive documentation on how to use, develop, and extend this template, see the [documentation](./docs/README.md).
30+
31+
Key documentation sections:
32+
33+
- [Getting Started](./docs/01-getting-started/01-prerequisites.md) - Prerequisites and initial setup
34+
- [Architecture Overview](./docs/02-architecture/01-overview.md) - Modular monolith architecture design
35+
- [Development Workflow](./docs/03-development-workflow/) - Day-to-day development guidelines
36+
- [Extending the API](./docs/04-guides/01-extending-the-api.md) - How to add new modules and features
37+
2738
### Dashboard Login
2839

2940
[![API docs](img/login.png)](https://github.com/fastapi/full-stack-fastapi-template)
@@ -138,7 +149,7 @@ Before deploying it, make sure you change at least the values for:
138149

139150
You can (and should) pass these as environment variables from secrets.
140151

141-
Read the [deployment.md](./deployment.md) docs for more details.
152+
Read the [deployment documentation](./docs/06-deployment/README.md) for more details.
142153

143154
### Generate Secret Keys
144155

@@ -152,29 +163,6 @@ python -c "import secrets; print(secrets.token_urlsafe(32))"
152163

153164
Copy the content and use that as password / secret key. And run that again to generate another secure key.
154165

155-
156-
## Backend Development
157-
158-
Backend docs: [backend/README.md](./backend/README.md).
159-
160-
## Frontend Development
161-
162-
Frontend docs: [frontend/README.md](./frontend/README.md).
163-
164-
## Deployment
165-
166-
Deployment docs: [deployment.md](./deployment.md).
167-
168-
## Development
169-
170-
General development docs: [development.md](./development.md).
171-
172-
This includes using Docker Compose, custom local domains, `.env` configurations, etc.
173-
174-
## Release Notes
175-
176-
Check the file [release-notes.md](./release-notes.md).
177-
178166
## License
179167

180-
The Full Stack FastAPI Template is licensed under the terms of the MIT license.
168+
The Full Stack FastAPI Template is licensed under the terms of the MIT license.

app/modules/utils/__init__.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""
2+
Utils module initialization.
3+
4+
This module provides utility endpoints and functions.
5+
"""
6+
from fastapi import APIRouter, FastAPI
7+
8+
from app.core.config import settings
9+
from app.core.logging import get_logger
10+
11+
# Configure logger
12+
logger = get_logger("utils_module")
13+
14+
15+
def get_utils_router() -> APIRouter:
16+
"""
17+
Get the utils module's router.
18+
19+
Returns:
20+
APIRouter for utils module
21+
"""
22+
from app.modules.utils.api.routes import router as utils_router
23+
return utils_router
24+
25+
26+
def init_utils_module(app: FastAPI) -> None:
27+
"""
28+
Initialize the utils module.
29+
30+
This function sets up routes for the utils module.
31+
32+
Args:
33+
app: FastAPI application
34+
"""
35+
from app.modules.utils.api.routes import router as utils_router
36+
37+
# Include the utils router in the application
38+
app.include_router(utils_router, prefix=settings.API_V1_STR)
39+
40+
# Log initialization
41+
logger.info("Utils module initialized")

app/modules/utils/api/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
Utils API package.
3+
"""

app/modules/utils/api/routes.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"""
2+
Utils routes.
3+
4+
This module provides API routes for utility operations.
5+
"""
6+
from typing import Any
7+
8+
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, status
9+
from pydantic import EmailStr
10+
11+
from app.api.deps import CurrentSuperuser
12+
from app.core.config import settings
13+
from app.core.logging import get_logger
14+
from app.shared.models import Message # Using shared Message model
15+
16+
# Configure logger
17+
logger = get_logger("utils_routes")
18+
19+
# Create router
20+
router = APIRouter(prefix="/utils", tags=["utils"])
21+
22+
23+
@router.get("/health-check/", response_model=bool)
24+
def health_check() -> Any:
25+
"""
26+
Health check endpoint.
27+
28+
Returns:
29+
True if the API is running
30+
"""
31+
return True
32+
33+
34+
@router.post("/test-email/", response_model=Message)
35+
def test_email(
36+
current_user: CurrentSuperuser,
37+
email_to: EmailStr,
38+
background_tasks: BackgroundTasks,
39+
) -> Any:
40+
"""
41+
Test email sending.
42+
43+
Args:
44+
email_to: Recipient email address
45+
background_tasks: Background tasks
46+
current_user: Current superuser
47+
48+
Returns:
49+
Success message
50+
"""
51+
# This endpoint is now handled by the email module
52+
# Redirect to the email module's test endpoint
53+
raise HTTPException(
54+
status_code=status.HTTP_301_MOVED_PERMANENTLY,
55+
detail="This endpoint has moved to /api/v1/email/test",
56+
headers={"Location": f"{settings.API_V1_STR}/email/test?email_to={email_to}"},
57+
)

backend/alembic.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ script_location = app/alembic
66

77
# template used to generate migration files
88
# file_template = %%(rev)s_%%(slug)s
9+
file_template = migration_template.py.mako
910

1011
# timezone to use when rendering the date
1112
# within the migration file as well as the filename.

backend/app/alembic/README

Lines changed: 0 additions & 1 deletion
This file was deleted.

backend/app/alembic/script.py.mako

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)