|
2 | 2 |
|
3 | 3 |  |
4 | 4 |
|
5 | | -Opinionated Foundation Boilerplate for a SaaS Platform |
6 | | - |
7 | | -- Boring tech |
8 | | -- Reproducible builds |
9 | | -- Development flow |
10 | | - - easy deployment |
11 | | - - preview builds |
12 | | -- 100% test coverage |
13 | | -- Easy to extend |
14 | | - |
15 | | -tech |
16 | | - |
17 | | -- fastapi |
18 | | -- postgresql |
19 | | -- htmx |
20 | | -- tailwind.css |
| 5 | +### Overview |
| 6 | + |
| 7 | +Basic Foundation is designed for developers building web applications and APIs in Python. It takes advantage of Python |
| 8 | +3.12’s type hinting and async capabilities for scalability and performance. The project includes transactional database |
| 9 | +tests, ensuring that the real database logic is tested and not just mocked. With built-in JWT authentication, API, and |
| 10 | +web modules, and a pre-configured CI/CD pipeline, it streamlines setting up the infrastructure needed for a typical SaaS |
| 11 | +project. Additionally, full test coverage and support for dynamic preview environments reduce the chances of bugs and |
| 12 | +make deployments safer. |
| 13 | + |
| 14 | +## Features of Basic Foundation |
| 15 | + |
| 16 | +- **Python 3.12 with Type Hints**: The project uses Python 3.12 and includes type hints throughout the codebase. Pyright |
| 17 | + is configured to perform type checking during development, ensuring that types are correctly enforced. This reduces |
| 18 | + runtime errors by catching type mismatches early. |
| 19 | +- **100% Asynchronous APIs**: All API operations are asynchronous, implemented with FastAPI and async SQLAlchemy. This |
| 20 | + setup allows non-blocking I/O, which improves performance and scalability when handling multiple concurrent requests, |
| 21 | + such as during API-heavy workloads. |
| 22 | +- **Transactional Tests with Rollbacks**: Instead of relying on mock objects, database tests are run in real |
| 23 | + transactions that are rolled back after the test completes. This ensures that each test starts with a clean database |
| 24 | + state while still exercising the full application stack, making it possible to catch more bugs and integration issues. |
| 25 | +- **Authentication and User Management**: The application includes JWT-based authentication, with functionality for user |
| 26 | + registration, login, and subscription management. These are implemented as modular components that can be extended to |
| 27 | + fit project-specific requirements. |
| 28 | +- **API Module**: The API module exposes endpoints for core business logic, including user management and subscription |
| 29 | + handling. Built using FastAPI, it offers an easy way to extend or add new APIs while maintaining clear separation |
| 30 | + between the web and API layers. |
| 31 | +- **Web Module**: Server-side rendering is handled using Jinja2 templates, while HTMX is used to enhance the user |
| 32 | + experience with partial page updates. TailwindCSS is used for styling to minimize the need for custom CSS. This |
| 33 | + approach keeps the frontend simple, while still supporting dynamic updates. |
| 34 | +- **Email Integration**: The project includes email sending via SMTP, enabling the app to send account-related emails |
| 35 | + such as password recovery or account activation. This feature simplifies integrating email functionality without |
| 36 | + third-party services. |
| 37 | +- **Database Migrations with DBMate**: Database schema changes are handled by DBMate, which provides simple migration |
| 38 | + commands for PostgreSQL. It ensures that schema changes can be applied, rolled back, and dumped consistently across |
| 39 | + different environments. |
| 40 | +- **100% Test Coverage**: Every core library, API endpoint, and web component has full test coverage. Tests are written |
| 41 | + using pytest, ensuring that all critical paths are tested. This helps catch regressions and bugs early in the |
| 42 | + development process. |
| 43 | +- **Playwright for Frontend Testing**: Playwright is used for testing frontend functionality, including interactive |
| 44 | + features like forms and modals. These tests ensure that the frontend behaves as expected across different browsers and |
| 45 | + devices. |
| 46 | +- **Continuous Integration and Deployment (CI/CD)**: GitHub Actions is used for automated testing, versioning, and |
| 47 | + building of the project. Each release includes automated version bumps, database migrations, and deployment to |
| 48 | + Render.com or other platforms. |
| 49 | +- **Preview Environments**: The project supports preview environments using Render.com’s feature, allowing each pull |
| 50 | + request or branch to deploy its own isolated environment. This is useful for testing changes before merging them into |
| 51 | + the main branch. |
| 52 | +- **TailwindCSS for Styling**: Minimal CSS is used in favor of TailwindCSS, which provides utility-based styling. This |
| 53 | + keeps the styles consistent and reduces the complexity of managing custom CSS. |
21 | 54 |
|
22 | 55 | ## Assumptions |
23 | 56 |
|
24 | | -- Requires a python installation (recommend python [3.12](https://docs.python.org/release/3.12.1/whatsnew/3.12.html)) |
| 57 | +- Requires a python installation (3.12) |
25 | 58 | - Github access https://docs.github.com/en/get-started/quickstart/set-up-git |
26 | 59 | - Docker/Docker compose |
27 | 60 |
|
|
0 commit comments