in this session. we will go over the basic API structure.
first. we will use `argon2` for password hashing.
install `argon2`.
make sure to install it inside the previously created conda environment.
this project follows the feature-based modularization pattern.
in a traditional MVC structure. components are separated into `routes/`. `services/`. and `models/`.
however. we structure features based on endpoint-centric architecture.
this ensures a 1:1 mapping between API design and code structure.
making maintenance and collaboration easier.
moreover. it follows a similar structure to Next.js API Routes.
allowing frontend developers to intuitively understand the project.
each feature (e.g.. `create_user`. `update_user`) has its own folder.
containing `router.py`. `schema.py`. and `crud.py` to maintain an independent structure.
by using FastAPI's Modular Router system.
routers can be registered automatically.
allowing new features to be added by simply creating a folder without modifying `main.py`.
automatically detect and register the `router.py` file inside the folder.
this maintains scalability like a microservices approach.
while allowing modularization within a single project.
since we are only explaining the structure. we will create a simple `get_test` API.
typically. we separate files into three main components: `router`. `schema`. and `crud`.
- `router` handles endpoint processing.
- `schema` manages data validation and API input/output models.
- `crud` handles database operations.
additional files can be added flexibly as needed.
however. the `router` file is essential.
while `schema` and `crud` files are used only when necessary.
still. in most cases. `router` and `schema` will be written together.
since we are not interacting with the database this time. we will not create a `crud` file.
now. let's examine the code for the `get_test` endpoint.
this endpoint returns a JSON response containing a `message` key with the value `"testget"`.
let's check if this is properly defined in `schema.py`.
we have also pre-created a `create_user` endpoint.
but it includes service logic such as password hashing and validation.
even if it looks complex. the core structure remains the same.
- `router` handles API endpoints.
- `schema` defines validation and API input/output models.
- `crud` handles database operations.
when managing the database in FastAPI. operations will follow a consistent pattern.
- common schema is defined in `share_schema.py`.
- common CRUD operations are defined in `share_crud.py`.
next time. we will cover one of the most critical parts: integrating the YOLO model with API endpoints.