Unleashing seamless integration for powerful performance.
Table of Contents
The Edge Cutters project is a robust software application template leveraging FastAPI and SQLAlchemy for advanced database integration. It efficiently manages user authentication, permissions, and CRUD operations through well-defined endpoints. By incorporating token handling and user management features, it ensures secure access control within its architecture. With seamless Docker containerization and migration handling, the project guarantees smooth deployment and database schema evolution.
Feature | Description | |
---|---|---|
βοΈ | Architecture | The project follows a modular architecture using FastAPI, SQLAlchemy, and StarletteAdvancedAlchemy to provide a robust and scalable backend system for API development. It leverages Docker for containerization and configuration management, ensuring seamless deployment. |
π© | Code Quality | The codebase maintains good quality standards with clear structure and well-documented code. It utilizes Pydantic for data validation, SQLAlchemy for database interactions, and AsyncSession for asynchronous database operations, enhancing code readability and maintainability. |
π | Documentation | The project offers extensive documentation covering setup, usage, and architecture details. Detailed descriptions of modules, functions, and configuration files facilitate developers in understanding and contributing to the project effectively. |
π | Integrations | Key external dependencies include FastAPI, SQLAlchemy, Alembic, and Pydantic, among others. These integrations enable advanced database management, API routing, schema migrations, and data validation within the project. |
𧩠| Modularity | The codebase exhibits high modularity with separate modules for authentication, user management, database configurations, and API endpoints. This modular design promotes code reuse, simplifies maintenance, and enhances scalability of the application. |
π§ͺ | Testing | WIP: Testing frameworks like Pytest and tools like pre-commit are used for ensuring code quality and functionality. Automated tests cover various aspects of the project, including API endpoints, database interactions, and authentication mechanisms. |
β‘οΈ | Performance | The project demonstrates efficient resource utilization with asynchronous database operations, optimized pagination methods, and Uvicorn for fast HTTP server performance. The use of SQLAlchemy's advanced features enhances database query efficiency, contributing to overall system performance. |
π‘οΈ | Security | Robust security measures are implemented with user authentication, token handling, role-based access control, and password validation. The project follows best practices for data protection, ensuring secure user interactions and preventing unauthorized access. |
π¦ | Dependencies | Key external libraries and dependencies include FastAPI, SQLAlchemy, psycopg2-binary, and Pydantic. These packages enhance functionality, data management, and API development capabilities within the project. |
π | Scalability | The project is designed to handle increased traffic and load through its modular architecture, asynchronous database operations, and efficient API routing. It supports seamless scalability by leveraging advanced features of FastAPI and SQLAlchemy for managing user data and system resources effectively. |
βββ edge-cutters/
βββ README.md
βββ alembic.ini
βββ docker
β βββ Dockerfile
β βββ prestart.sh
β βββ run.sh
βββ local.yml
βββ requirements.txt
βββ src
βββ __init__.py
βββ auth
βββ config
βββ database
βββ dependencies.py
βββ main.py
βββ routers.py
βββ schemas.py
βββ users
βββ utils.py
.
File | Summary |
---|---|
requirements.txt | Manages project dependencies vital for seamless operation within the edge-cutters repository architecture. Facilitates compatibility and integration of essential external packages to enhance functionality and performance. |
local.yml | Defines volume mappings and services for local development environment. Configures backend and PostgreSQL containers with necessary dependencies and environment variables. Facilitates seamless communication and data persistence between the services. |
src
File | Summary |
---|---|
main.py | Implements FastAPI app with advanced database integration using SQLAlchemy and StarletteAdvancedAlchemy. RouteServiceProvider endpoints via v1_router. |
schemas.py | Enables ORM mode for data using limit/offset pagination in the parent repository. Implements a BaseSchema class to extend Pydantics BaseModel and a Generic class for offset pagination with key attributes. |
dependencies.py | Provides database session for requests, using SQLAlchemys AsyncSession in the Edge Cutters repositorys architecture. |
routers.py | Defines API routers for authentication and user endpoints in FastAPI, grouped under version 1 (v1), enhancing modularity and readability in the repositorys codebase architecture. |
utils.py | Enables offset/limit pagination in the repositorys architecture by providing a function to calculate pagination values. It supports the Repository.apply_limit_offset_pagination() method and enhances data retrieval efficiency. |
docker
File | Summary |
---|---|
Dockerfile | Builds a Python Docker container, sets environment variables, installs dependencies, and configures entry point for the web application. |
prestart.sh | Executes prestart tasks like running migrations before app startup, ensuring up-to-date database schema. |
run.sh | Executes the FastAPI application with Uvicorn, specifying the host and port configurations. |
src.auth
File | Summary |
---|---|
tokens.py | Enables authentication and token handling for user access. Validates passwords, creates tokens with expiration, and verifies user credentials. Ensures user permissions match scope. Smoothly integrates with the repositorys user management and security architecture. |
models.py | Roles have permissions and users; Permissions have roles and users. Utilizes association tables for many-to-many relationships between entities. Facilitates flexible and secure access control in the systems architecture. |
permissions.py | Defines role and permission actions as Enums. Provides methods to access permission values. Helps manage access control in the architecture by listing available permissions. |
schemas.py | Defines token and token data schemas for authentication endpoints. Standardizes access token and token type, along with user permissions and username. Ensures consistent data structure for user authentication within the repository. |
endpoints.py | Enables user authentication, token generation, and retrieval of user details. Implements OAuth2 password flow, user authentication, permissions checking, and token expiry. Uses FastAPI for routing and security measures. |
src.config
File | Summary |
---|---|
base.py | Defines settings for database URI, token expiry, algorithm, and secret key for the Edge Cutters application. Configured using pydantic. |
src.users
File | Summary |
---|---|
models.py | Defines User model with many-to-many relationships for roles and permissions, including hybrid properties. Supports user authentication and authorization within the repositorys backend architecture. |
permissions.py | Defines user permissions as an Enum for CRUD operations, providing a list of available permissions. |
schemas.py | Defines user-related schemas inheriting from a base schema. Includes fields for user details, ID, and password. Contributes to data validation and structure in repositorys user management system. |
dependencies.py | Provides user repository dependency, ensuring sessions and filtering by deletion status for the parent FastAPI applications users feature. |
repositories.py | Implements user repository using advanced_alchemy to interface with the database. Connects user models to SQLAlchemyAsyncRepository for efficient data operations within the edge-cutters repositorys architecture. |
endpoints.py | Defines user endpoints for CRUD operations with authentication and permissions. Utilizes FastAPI for handling requests, Pydantic for data validation, and custom repositories for data manipulation. Enhances security and scalability in managing user data. |
src.database
File | Summary |
---|---|
session.py | Defines AsyncSession and SQLAlchemy configurations using the SQLAlchemy database URI. Resides in src/database and sets up the db_session dependency for the edge-cutters repository. |
base.py | Edge-cutters._ |
base_class.py | Defines a common base class for managing new tables within the app. Automatically tracks creation and update timestamps, along with an optional deletion timestamp. Timezones are accurately handled through the use of advanced SQLAlchemy features. |
src.database.migrations
File | Summary |
---|---|
env.py | Handles offline and online migrations using SQLAlchemy and Alembic. Configures database connection and runs migrations based on context, ensuring smooth migration process. Resolves Heroku PostgreSQL connection issue and supports asynchronous migrations as needed. |
script.py.mako | Generates migration scripts for the database schema evolution with precise upgrade and downgrade paths. Resides in the src/database/migrations directory, adding agility to database changes within the larger repository architecture. |
src.database.migrations.versions
File | Summary |
---|---|
812c97994acf_setup_default_data.py | Implements default data setup for user roles and permissions in the database using Alembic migrations. Sets up administrator user, permissions, roles, and their relationships in the system. |
406eb81159d5_create_users_roles_and_permissions_table.py | Creates tables for users, roles, permissions, and their relationships in the database schema using Alembic migrations. |
System Requirements:
- Python:
version 3.12.2
- Clone the edge-cutters repository:
$ git clone https://github.com/renceInbox/edge-cutters
- Change to the project directory:
$ cd edge-cutters
- Install the dependencies:
$ pip install -r requirements.txt
Run edge-cutters using the command below:
$ uvicorn --host 0.0.0.0 src.main:app
Run the test suite using the command below:
$ pytest
Contributions are welcome! Here are several ways you can contribute:
- Report Issues: Submit bugs found or log feature requests for the
edge-cutters
project. - Submit Pull Requests: Review open PRs, and submit your own PRs.
- Join the Discussions: Share your insights, provide feedback, or ask questions.
Contributing Guidelines
- Fork the Repository: Start by forking the project repository to your github account.
- Clone Locally: Clone the forked repository to your local machine using a git client.
git clone https://github.com/renceInbox/edge-cutters
- Create a New Branch: Always work on a new branch, giving it a descriptive name.
git checkout -b new-feature-x
- Make Your Changes: Develop and test your changes locally.
- Commit Your Changes: Commit with a clear message describing your updates.
git commit -m 'Implemented new feature x.'
- Push to github: Push the changes to your forked repository.
git push origin new-feature-x
- Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
- Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
This project is protected under the MIT License. For more details, refer to the LICENSE file.