How icesun39/my_book_api works
Book API is an asynchronous REST service for user accounts, authors, books, and favorites. Clients enter through the FastAPI app and resource routers, which delegate operations to services; services validate and transform data through schemas and persist domain records through SQLAlchemy to PostgreSQL. The README also documents JWT authorization, role-based access, and password hashing. Authentication wiring is represented at the documented capability level because its source was not sampled.
Main entry points: main.py FastAPI app · author_routes.py Author routes · book_services.py Book service · user_services.py User service
Components 22
API surface
- FastAPI app
src/backend/main.py - Book routes
src/backend/routers/book_routes.py - Author routes
src/backend/routers/author_routes.py - User routes
src/backend/routers/user_routes.py - Auth routes
src/backend/routers/auth.py - Book schemas
src/backend/schemas/book_schemas.py - Author schemas
src/backend/schemas/author_schemas.py - User schemas
src/backend/schemas/user_schemas.py
Domain services
- Book service
src/backend/services/book_services.py - Author service
src/backend/services/author_service.py - User service
src/backend/services/user_services.py
Identity and access
- Auth service
src/backend/services/auth_service.py - Access controls
src/backend/core/dependencies.py - Password and JWT
src/backend/core/security.py
Persistence
- Async session
src/backend/database/database.py - Book model
src/backend/models/book.py - Author model
src/backend/models/author.py - User model
src/backend/models/user.py - Book-author link
src/backend/models/associations/books_and_authors.py - Favorite link
src/backend/models/associations/user_favorite_books.py
Other components
- API client
- PostgreSQL
Connections 31
- API client → FastAPI app: sends requests
- FastAPI app → Book routes: registers routes
- FastAPI app → Author routes: registers routes
- FastAPI app → User routes: registers routes
- FastAPI app → Auth routes: registers routes
- Book routes → Book service: dispatches
- Author routes → Author service: dispatches
- User routes → User service: dispatches
- Book routes → Book schemas: validates responses
- Author routes → Author schemas: validates responses
- Author routes → Book schemas: validates responses
- User routes → User schemas: validates requests
- Book service → Async session: queries and commits
- Author service → Async session: queries and commits
- User service → Async session: queries and commits
- Book service → User service: loads user
- User service → Password and JWT: hashes passwords
- Book service → Book model: reads and writes
- Book service → Author model: reads authors
- Author service → Author model: reads and writes
- Author service → Book model: reads books
- User service → User model: reads and writes
- Book model → Book-author link: uses association
- Author model → Book-author link: uses association
- User model → Favorite link: uses association
- Async session → PostgreSQL: persists data
- Book routes → Access controls: requires user or admin
- Author routes → Access controls: requires user or admin
- User routes → Access controls: requires admin
- Auth routes → Auth service: authentication capability
- Access controls → Password and JWT: uses JWT controls