Skip to content

Add base router#92

Merged
javidahmed64592 merged 7 commits into
mainfrom
add-base-router
May 7, 2026
Merged

Add base router#92
javidahmed64592 merged 7 commits into
mainfrom
add-base-router

Conversation

@javidahmed64592
Copy link
Copy Markdown
Owner

This pull request refactors the FastAPI server architecture to introduce a pluggable, class-based router system and improve modularity, configuration, and testability. The main changes include extracting routing logic into a BaseRouter abstraction, adding a TemplateServerRouter for core endpoints, and updating the server and tests to support this new design.

API Router Refactor and Modularization

  • Introduced a new BaseRouter abstract class that encapsulates API route registration, authentication, and rate limiting, enabling routers to be defined as classes rather than functions. (python_template_server/routers/base_router.py python_template_server/routers/base_router.pyR1-R109)
  • Added a TemplateServerRouter implementing health and login endpoints, using the new router abstraction. (python_template_server/routers/template_server_router.py python_template_server/routers/template_server_router.pyR1-R47)
  • Updated the main server class (TemplateServer) to use a list of routers, which are configured and registered at startup. The old setup_routes and add_route methods were removed in favor of this new pattern. (python_template_server/template_server.py [1] [2] [3]

Configuration and Initialization Improvements

Testing and Fixtures

  • Added a test fixture for TemplateServerRouter, including mock rate limiting and configuration, to support the new router-based architecture. (tests/conftest.py [1] [2]

Project Organization

These changes lay the foundation for a more extensible, maintainable, and testable FastAPI server by decoupling route logic from the main server class and centralizing security and rate limiting concerns in reusable router classes.

@javidahmed64592 javidahmed64592 merged commit c3b9f66 into main May 7, 2026
16 checks passed
@javidahmed64592 javidahmed64592 deleted the add-base-router branch May 7, 2026 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant