Prompt file imported from zamax14/Vibe-Coder-Course (
.github/prompts/new-crud.prompt.md). Copyright stays with the author.
Generate a complete CRUD module for the entity described below. Follow the project's modular architecture strictly.
Requirements
Create all 7 files under app/<entity_name>/:
__init__.py— Empty fileconstants.py—ENTITY_NAMEandMESSAGESdict with keys:not_found,created,updated,deleted,already_existsexceptions.py—<Entity>NotFoundExceptionand<Entity>AlreadyExistsException(if applicable)models.py— SQLAlchemy 2.0 model withMapped+mapped_column, always includeid,created_at,updated_atschemas.py— Pydantic v2 schemas:<Entity>Create,<Entity>Update(all optional),<Entity>Response(withConfigDict(from_attributes=True))service.py— Async functions:get_all,get_by_id,create,update,deleteusingAsyncSessionroutes.py—APIRouterwith prefix and tags, standard 5 CRUD endpoints
Then register the router in app/main.py by adding the import and app.include_router().
Reference
Follow the exact patterns from users module as reference.