How vintasoftware/nextjs-fastapi-template works
Main Components
• Backend Service: Represented by the “fastapi_backend” directory. Highlight key elements such as:
– API endpoints (located under fastapi_backend/api and fastapi_backend/app/routes)
– Database interactions (files under fastapi_backend/app/database, Alembic migrations, and models)
– Business logic and utilities (modules like fastapi_backend/app/utils, users, email, etc.)
– Commands and tooling such as the OpenAPI schema generation (under fastapi_backend/commands)
• Frontend Service: Represented by the “nextjs-frontend” directory. Key aspects include:
– Pages and components (see directories like nextjs-frontend/app, nextjs-frontend/components)
– OpenAPI client integration (under nextjs-frontend/app/openapi-client)
– TypeScript with Zod validations (illustrate the integration with generated types)
• Database: Although not directly present in the file tree, the README references PostgreSQL and Docker Compose setups. Also include information on migrations (Alembic scripts) and configurations.
• External Services and Tools:
– Docker & Docker Compose: Explain how Docker is used to containerize both the frontend and backend as well as supporting services (database, MailHog for email testing).
– CI/CD Workflows: GitHub Actions workflows located under “.github/workflows” for continuous integration and deployment.
– Pre-commit Hooks: Illustrate the local and Docker-based pre-commit configurations in enforcing code quality.
– Hot Reload & File Watching: Show that backend uses Python-based file watchers (e.g., Watchdog) and the frontend uses Chokidar to trigger updates and schema regeneration.
– Email Service: Use of MailHog for local email testing.
Relationships and Interactions
– Backend generates the openapi.json either manually or automatically.
– The generated OpenAPI schema is then used by the frontend client (in nextjs-frontend/app/openapi-client) to maintain type safety.
• Database’s Role:
• CI/CD Pipeline:
– Represent GitHub Actions as the orchestrator that, upon code push, triggers builds and deployments.
• Demonstrate integration with Docker:
– Use containers for backend, frontend, database, and MailHog. Illustrate connections among these containers and the local development workflow via docker-compose.
Architectural Patterns and Design Principles
• Modular Design: Both the backend and frontend are well separated into domain-specific subfolders (e.g., API routes, models, components).
• Service Separation: Clearly emphasize the decoupling between frontend and backend, a typical full-stack pattern.
• Type Safety & Client Generation: Underline the use of Zod and OpenAPI for end-to-end type safety and a self-updating client contract.
• Containerization Principle: Emphasize the use of Docker and the consistency it brings to development, testing, and production environments.