Task Description: Implement a User Registration System
Develop a user registration system that allows new users to create accounts. The implementation should include the following functionalities:
User Model: Create a User model that includes the following properties:
username: A string that must be unique and at least 3 characters long.
email: A valid email format that must also be unique.
password: A string that must be at least 8 characters long and include at least one numeric digit and one special character.
Registration Functionality: Implement a function to handle user registration that performs the following tasks:
Validate the input fields for username, email, and password based on the criteria mentioned above.
Return a success message and save the user details if validation passes.
Return appropriate error messages if any validation fails (e.g., "Username is too short", "Email is already taken", "Password must contain a number and special character").
Database Integration: Use a simple database (for example, SQLite) to store user data and implement functions to check for existing usernames and emails during registration.
API Endpoint: Create an API endpoint /api/register that accepts a POST request with JSON payload containing username, email, and password.
Testing: Ensure the implementation passes the provided test code which checks for successful user registrations as well as cases where the input is invalid.
All implementation code must reside in the /app/ directory. Please ensure to follow clean code practices, including proper organization of files and functions.