|
4 | 4 |
|
5 | 5 | ### Overview |
6 | 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. |
54 | | - |
55 | | -## Assumptions |
56 | | - |
57 | | -- Requires a python installation (3.12) |
58 | | -- Github access https://docs.github.com/en/get-started/quickstart/set-up-git |
59 | | -- Docker/Docker compose |
| 7 | +Basic Foundation is a starter kit for building SaaS applications in Python. It provides user authentication, APIs, and |
| 8 | +user management using modern Python technologies, including FastAPI, PostgreSQL, and HTMX. |
| 9 | + |
| 10 | +### Tech Stack |
| 11 | + |
| 12 | +- **Python 3.12**: Improved typing support, error messages, and performance. |
| 13 | +- **Type Hints and Type Checking**: Comprehensive type hints with Pyright configured for type checking during |
| 14 | + development. |
| 15 | +- **Async FastAPI**: All API operations are implemented asynchronously using `async`/`await` and non-blocking I/O. |
| 16 | +- **PostgreSQL**: Database layer for persistence. |
| 17 | +- **SQLAlchemy**: Async DB layer with SQLAlchemy 2.0 for ORM. |
| 18 | +- **HTMX**: Frontend admin web app with dynamic interactions via HTMX. |
| 19 | +- **TailwindCSS**: Utility-first styling for the admin interface. |
| 20 | +- **Testing**: Full test coverage for core app and API using Pytest. |
| 21 | +- **Playwright**: End-to-end in-browser testing for the admin web app. |
| 22 | +- **GitHub Actions**: CI/CD pipelines for testing and deployment. |
| 23 | + |
| 24 | +### Features |
| 25 | + |
| 26 | +- **Asynchronous API Implementation**: FastAPI for non-blocking I/O and async database access. |
| 27 | +- **JWT Authentication**: Secure token-based authentication for both API and web endpoints. |
| 28 | +- **RESTful API Module**: Comprehensive user management and authentication via API. |
| 29 | +- **Responsive Web UI**: Server-side rendered admin UI with partial page updates using Jinja2 templates and HTMX. |
| 30 | +- **TailwindCSS**: Modular and customizable styles using TailwindCSS. |
| 31 | +- **Email Integration**: SMTP support for sending account-related emails (password recovery, activation). |
| 32 | +- **DBMate for Migrations**: Easy schema migrations with DBMate, including schema versioning, rollback and SQL schema |
| 33 | + dumping. |
| 34 | +- **Transactional Tests**: Rollback transaction after each test to ensure isolated test environments. |
| 35 | +- **100% Test Coverage**: Test coverage measurement with reporting via Coverage.py. |
| 36 | +- **End-to-End Testing**: Playwright tests for frontend functionality, including interactive elements. |
| 37 | +- **CI/CD with GitHub Actions**: Automated testing, versioning, and deployment with GitHub Actions. Releases include |
| 38 | + version bumps, migrations, and automated deployment (Render.com). |
| 39 | +- **Preview Environments**: Each branch or pull request is deployed to an isolated environment via Render.com. |
| 40 | + |
| 41 | +## Requirements |
| 42 | + |
| 43 | +- Python (3.12): required for generics and type hinting |
| 44 | +- Docker/Docker compose: run postgres instance locally via docker-compose |
60 | 45 |
|
61 | 46 | ## Getting started |
62 | 47 |
|
|
0 commit comments