# middleware Specification ## Purpose TBD - created by archiving change add-meeting-assistant-mvp. Update Purpose after archive. ## Requirements ### Requirement: FastAPI Server Configuration The middleware server SHALL be implemented using Python FastAPI framework with environment-based configuration. #### Scenario: Server startup with valid configuration - **WHEN** the server starts with valid .env file containing DB_HOST, DB_PORT, DB_USER, DB_PASS, DB_NAME, DIFY_API_URL, DIFY_API_KEY - **THEN** the server SHALL start successfully and accept connections #### Scenario: Server startup with missing configuration - **WHEN** the server starts with missing required environment variables - **THEN** the server SHALL fail to start with descriptive error message ### Requirement: Database Connection Pool The middleware server SHALL maintain a connection pool to the MySQL database at mysql.theaken.com:33306. #### Scenario: Database connection success - **WHEN** the server connects to MySQL with valid credentials - **THEN** a connection pool SHALL be established and queries SHALL execute successfully #### Scenario: Database connection failure - **WHEN** the database is unreachable - **THEN** the server SHALL return HTTP 503 with error details for affected endpoints ### Requirement: Table Initialization The middleware server SHALL ensure all required tables exist on startup with the `meeting_` prefix. #### Scenario: Tables created on first run - **WHEN** the server starts and tables do not exist - **THEN** the server SHALL create meeting_users, meeting_records, meeting_conclusions, and meeting_action_items tables #### Scenario: Tables already exist - **WHEN** the server starts and tables already exist - **THEN** the server SHALL skip table creation and continue normally ### Requirement: CORS Configuration The middleware server SHALL allow cross-origin requests from the Electron client. #### Scenario: CORS preflight request - **WHEN** Electron client sends OPTIONS request - **THEN** the server SHALL respond with appropriate CORS headers allowing the request