Repository: cording12/next-fast-turbo
Branch: main
Commit: 0b135d79b59a
Files: 140
Total size: 244.9 KB
Directory structure:
gitextract_2mwlqf4v/
├── .eslintrc.js
├── .gitignore
├── .npmrc
├── .vscode/
│ ├── next-fast-turbo.code-workspace
│ └── settings.json
├── LICENCE
├── README.md
├── apps/
│ ├── api/
│ │ ├── .vscode/
│ │ │ ├── launch.json
│ │ │ └── settings.json
│ │ ├── README.md
│ │ ├── harry-potter-db-seed-spells.csv
│ │ ├── harry-potter-db-seed-users.csv
│ │ ├── package.json
│ │ ├── poetry.toml
│ │ ├── pyproject.toml
│ │ ├── requirements.txt
│ │ ├── run.py
│ │ ├── src/
│ │ │ ├── __init__.py
│ │ │ ├── api/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── api_v1/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── api.py
│ │ │ │ │ └── endpoints/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── spells.py
│ │ │ │ │ └── users.py
│ │ │ │ └── deps.py
│ │ │ ├── config.py
│ │ │ ├── crud/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── base.py
│ │ │ │ ├── crud_spell.py
│ │ │ │ └── crud_user.py
│ │ │ ├── main.py
│ │ │ └── schemas/
│ │ │ ├── __init__.py
│ │ │ ├── base.py
│ │ │ ├── spell.py
│ │ │ └── user.py
│ │ ├── tests/
│ │ │ ├── __init__.py
│ │ │ └── test_api.py
│ │ └── vercel.json
│ ├── docs/
│ │ ├── .vscode/
│ │ │ └── extensions.json
│ │ ├── api/
│ │ │ ├── spells/
│ │ │ │ ├── get-all-spells.mdx
│ │ │ │ ├── get-spell.mdx
│ │ │ │ └── search-spells.mdx
│ │ │ └── users/
│ │ │ ├── create-user.mdx
│ │ │ ├── get-all-users.mdx
│ │ │ ├── get-user.mdx
│ │ │ └── search-users.mdx
│ │ ├── documentation/
│ │ │ ├── configuration/
│ │ │ │ ├── docs.mdx
│ │ │ │ ├── fastapi.mdx
│ │ │ │ ├── nextjs.mdx
│ │ │ │ └── turbo.mdx
│ │ │ ├── deployment/
│ │ │ │ └── deployment.mdx
│ │ │ ├── introduction.mdx
│ │ │ └── local-development.mdx
│ │ ├── mint.json
│ │ ├── openapi.json
│ │ └── package.json
│ └── web/
│ ├── .eslintrc.js
│ ├── .vscode/
│ │ └── launch.json
│ ├── app/
│ │ ├── globals.css
│ │ ├── layout.tsx
│ │ ├── page.tsx
│ │ ├── placeholder-stats.tsx
│ │ └── settings/
│ │ └── page.tsx
│ ├── components/
│ │ ├── demo-exercise.tsx
│ │ ├── demo-goal.tsx
│ │ ├── demo-revenue.tsx
│ │ ├── demo-subscriptions.tsx
│ │ ├── flex-wrapper.tsx
│ │ ├── grid-wrapper.tsx
│ │ ├── icons.tsx
│ │ ├── layouts/
│ │ │ └── dashboard/
│ │ │ ├── DashboardLayout.module.css
│ │ │ ├── DashboardLayout.tsx
│ │ │ ├── index.ts
│ │ │ └── layout-components/
│ │ │ ├── Footer/
│ │ │ │ ├── Footer.module.css
│ │ │ │ ├── Footer.tsx
│ │ │ │ └── index.ts
│ │ │ ├── Header/
│ │ │ │ ├── Header.tsx
│ │ │ │ └── index.ts
│ │ │ ├── Sidebar/
│ │ │ │ ├── NavLink.tsx
│ │ │ │ ├── NavLinks.tsx
│ │ │ │ ├── Sidebar.tsx
│ │ │ │ ├── SidebarMobile.tsx
│ │ │ │ └── index.ts
│ │ │ └── index.ts
│ │ ├── search-users.tsx
│ │ ├── tailwind-indicator.tsx
│ │ ├── theme/
│ │ │ ├── mode-toggle.tsx
│ │ │ ├── theme-provider.tsx
│ │ │ └── theme.css
│ │ ├── typography.tsx
│ │ └── ui/
│ │ ├── button.tsx
│ │ ├── card.tsx
│ │ ├── dropdown-menu.tsx
│ │ ├── form.tsx
│ │ ├── input.tsx
│ │ ├── label.tsx
│ │ ├── radio-group.tsx
│ │ ├── separator.tsx
│ │ ├── skeleton.tsx
│ │ └── tooltip.tsx
│ ├── components.json
│ ├── lib/
│ │ ├── api/
│ │ │ └── client/
│ │ │ ├── core/
│ │ │ │ ├── ApiError.ts
│ │ │ │ ├── ApiRequestOptions.ts
│ │ │ │ ├── ApiResult.ts
│ │ │ │ ├── CancelablePromise.ts
│ │ │ │ ├── OpenAPI.ts
│ │ │ │ └── request.ts
│ │ │ ├── index.ts
│ │ │ ├── models/
│ │ │ │ ├── HTTPValidationError.ts
│ │ │ │ ├── Spell.ts
│ │ │ │ ├── SpellSearchResults.ts
│ │ │ │ ├── User.ts
│ │ │ │ ├── UserCreate.ts
│ │ │ │ ├── UserSearchResults.ts
│ │ │ │ └── ValidationError.ts
│ │ │ └── services/
│ │ │ ├── SpellsService.ts
│ │ │ └── UsersService.ts
│ │ ├── config/
│ │ │ ├── index.ts
│ │ │ └── nav.tsx
│ │ ├── twConfig.ts
│ │ └── utils.ts
│ ├── next-env.d.ts
│ ├── next.config.js
│ ├── package.json
│ ├── postcss.config.js
│ ├── tailwind.config.js
│ └── tsconfig.json
├── package.json
├── packages/
│ ├── eslint-config/
│ │ ├── README.md
│ │ ├── library.js
│ │ ├── next.js
│ │ ├── package.json
│ │ └── react-internal.js
│ └── typescript-config/
│ ├── base.json
│ ├── nextjs.json
│ ├── package.json
│ └── react-library.json
├── pnpm-workspace.yaml
├── tsconfig.json
└── turbo.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .eslintrc.js
================================================
// This configuration only applies to the package manager root.
/** @type {import("eslint").Linter.Config} */
module.exports = {
ignorePatterns: ["apps/**", "packages/**"],
extends: ["@repo/eslint-config/library.js"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
};
================================================
FILE: .gitignore
================================================
# Dependencies
node_modules
.pnp
.pnp.js
# Local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
# Testing
coverage
# Turbo
.turbo
# Vercel
.vercel
# Build Outputs
.next/
out/
build
dist
# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Misc
.DS_Store
*.pem
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Environments
.venv
================================================
FILE: .npmrc
================================================
================================================
FILE: .vscode/next-fast-turbo.code-workspace
================================================
{
"folders": [
{
"name": "Frontend",
"path": "../apps/web"
},
{
"name": "API",
"path": "../apps/api"
},
{
"name": "Documentation",
"path": "../apps/docs"
},
{
"name": "Root",
"path": "../"
}
],
"extensions": {
"recommendations": ["joshx.workspace-terminals"]
},
"launch": {
"version": "0.2.0",
"configurations": [],
"compounds": [
{
"name": "Launch Frontend and Backend",
"configurations": ["Next.js: Chrome", "Python: FastAPI"]
}
]
}
}
================================================
FILE: .vscode/settings.json
================================================
{
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"python.testing.pytestArgs": ["apps"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"cSpell.enableFiletypes": ["mdx"]
}
================================================
FILE: LICENCE
================================================
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
================================================
FILE: README.md
================================================
## Introduction
Next-Fast-Turbo is an open-source project scaffold. It's designed to be easy to get up and running both locally and in production. It's a monorepo that includes a Next.js frontend, a FastAPI backend, and a fully built and annotated Mintlify documentation site. It's built with TypeScript, and includes ESLint and Prettier for code quality. It's also set up to use Vercel for deployments and Remote Caching.
View the live frontend at [next-fast-turbo-web.vercel.app](https://next-fast-turbo-web.vercel.app/) and the live backend at [next-fast-turbo-api.vercel.app](https://next-fast-turbo-api.vercel.app/).
## Features
- Pre-configured [FastAPI backend](https://next-fast-turbo.mintlify.app/documentation/configuration/fastapi)
- Pre-configured [Next.js frontend](https://next-fast-turbo.mintlify.app/documentation/configuration/nextjs)
- Pre-configured [Mintlify documentation site](https://next-fast-turbo.mintlify.app/documentation/configuration/docs)
## Tech Stack
- [Next.js](https://nextjs.org/) – Frontend Framework
- [Tailwind](https://tailwindcss.com/) – CSS Framework
- [ShadCN UI](https://ui.shadcn.com/) – UI Components
- [FastAPI](https://fastapi.tiangolo.com/) – Python Backend
- [Mintlify](https://mintlify.com/) – Documentation
- [Supabase](https://supabase.com/) – Database
- [Turborepo](https://turbo.build/repo) – Monorepo
- [Vercel](https://vercel.com/) – deployments
## Getting started
Next-Fast-Turbo is designed to be cloned and modified to each project. For more information on getting started, [view the documentation](https://next-fast-turbo.mintlify.app/documentation/introduction).
## Contributing
Contributions are welcome. Here's how you can contribute:
- [Open an issue](https://github.com/cording12/next-fast-turbo/issues) if you believe you've encountered a bug.
- Follow the [local development guide](https://next-fast-turbo.mintlify.app/documentation/local-development) to get your local dev environment set up.
- Make a [pull request](https://github.com/cording12/next-fast-turbo/pulls) to add new features/make quality-of-life improvements/fix bugs.
## License
Next-Fast-Turbo is open-source under the GNU General Public License Version 3 (GPLv3) or any later version.
================================================
FILE: apps/api/.vscode/launch.json
================================================
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: FastAPI",
"type": "debugpy",
"request": "launch",
"module": "uvicorn",
"args": ["src.main:app", "--reload"],
"jinja": true
}
]
}
================================================
FILE: apps/api/.vscode/settings.json
================================================
{
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
================================================
FILE: apps/api/README.md
================================================
Generate requirements.txt using Poetry package manager:
```
poetry export --without-hashes --format=requirements.txt > requirements.txt
```
Python monorepo info:
https://medium.com/@ashley.e.shultz/python-mono-repo-with-only-built-in-tooling-7c2d52c2fc66
================================================
FILE: apps/api/harry-potter-db-seed-spells.csv
================================================
id,name,description
c76a2922-ba4c-4278-baab-44defb631236,Aberto,Opens locked doors
06485500-d023-4799-93fd-77f2c3341aa3,Accio,Summons objects
acbc0ae1-12e1-4813-b51e-09d22de40475,Aguamenti,Summons water
c9d2f389-a419-4f7e-8d3d-254959638019,Alohomora,Unlocks objects
018429a5-15d5-41af-bf8f-98a966733d77,Anapneo,Clears someone's airway
c828685c-52d2-466d-bcc6-fbcd8376cfb5,Aparecium,Reveals secret written messages
7fdd393c-2608-4ef3-9fd0-f691ad6f8b88,Apparate,A non-verbal transportation spell that allows a witch or wizard to instantly travel on the spot and appear at another location (disapparate is the opposite)
73886d47-2808-4861-ae40-956f4cb56272,Ascendio,Propells someone into the air
9a6b6854-8858-4b21-b761-12526a154597,Avada Kedavra,"Also known as The Killing Curse, the most evil spell in the Wizarding World; one of three Unforgivable Curses; Harry Potter is the only known witch or wizard to survive it"
b6f20bba-c0db-4ad2-8ac6-2a375a596287,Avis,Conjures a small flock of birds
48edfe4d-ddfc-49ac-8065-bd7e73c73778,Bat,Bogey Hex - Turns the target's boogers into bats
6bd8d5c1-9375-4b70-8d6e-ad019176c7a2,Bombardo,Creates an explosion
8fc19d10-3130-4b85-95c1-f2a51ba5ee3c,Brackium Emendo,Heals broken bones
f08c17fa-7bf9-49bf-9fba-a7806815bc80,Capacious Extremis,"Known as the Extension Charm, it's a complicated spell that can greatly expand or extend the capacity of an object or space without affecting it externally"
55dec867-ac07-4975-94c7-090f6fd25c86,Confundo,"Known as the Confundus Charm, it causes confusion of the target"
816d9fee-b78f-47b4-be46-b48626c013f9,Conjunctivitis Curse,Affects the eyes and sight of a target
58b8727a-6c0c-469c-b91d-8ac0cc0dd2d8,Crinus Muto,Changes hair color and style
f1e91049-e866-4f6f-9d87-d6fd366aecbf,Crucio,"One of three Unforgivable Curses, it causes unbearable pain in the target"
7324e645-8f41-4c83-a367-0d10a72906ff,Diffindo,Used to precisely cut an object
638072b9-b7ac-405d-914b-d9293c5f9d25,Disillusionment Charm,Causes the target to take on the appearance of its surroundings
b7643e32-ef9c-41b8-83f2-03f6b5015e04,Disapparate,A non-verbal transportation spell that allows a witch or wizard to instantly travel on the spot and leave for another location (apparate is the opposite)
20476c31-4f27-49ac-876f-a4c4028f1b5b,Engorgio,Causes rapid growth in the targeted object
ecb9a882-d6d7-495e-9958-a1a06902bb65,Episkey,Heals minor injuries
317ff981-ad65-421e-92fb-5f6647d95232,Expecto patronum,"The Patronus Charm is a powerful projection of hope and happiness that drives away Dementors; a corpeal Patronus takes the the respective animal form of the caster, while a non-corpeal appears as a wisp of light; at 13, Harry Potter was the youngest known witch or wizard to prouduce a corpeal Patronus"
60149246-91cf-44a5-8885-78a7acc4bf90,Erecto,"Allows a witch or wizard to build a structure, like a tent"
6d8138c3-0773-4c23-b0bf-aab0e5c6fd95,Evanesco,Vanishes objects
678474e6-fb30-4bf0-a18c-228f6b36592d,Expelliarmus,Forces an opponent to drop whatever's in their possession
31b38b6c-4775-4e20-815d-dbf302433de6,Ferula,A healing charm that conjures wraps and bandages for wounds
37d262c9-28ab-408f-9576-acf54ce50203,Fidelius Charm,"A complex charm that conceals a secret into the soul of a chosen ""Secret Keeper"". If a location is the subject of concealment, it becomes undetectable to others"
9121b557-0ebf-4b60-a119-9d1c5ff05dee,Fiendfyre Curse,"Conjures destructive, enormous enchanted flames"
de23025f-5e6a-4ec3-b827-5c526a922a89,Finite Incantatem,A general counter-spell that's used to reverse or counter already cast charms
d536cbe5-bc0f-49e5-b063-e02c231a3988,Furnunculus Curse,A jinx that causes a breakout of boils or pimples
7915b07a-d26e-4057-9083-e457643e57a6,Geminio,Duplicates objects
2a942514-7a19-4f0e-9353-171c573abcba,Glisseo,Transforms a staircase into a slide
a42028b6-67f5-463b-b759-452103533227,Homenum Revelio,Reveals the presence of another person
552cd4ee-2c67-48fd-ae20-a83773262a8a,Homonculus Charm,Detects anyone's true identity and location on a piece of parchment; used to create the Marauder's Map
2dfca7d2-ec9b-4150-b3f3-fd972a5fd1bc,Immobulus,Immobilises living targets
a49300cc-ddbf-4ff4-b8c2-e8bddbbe4118,Impedimenta,A temporary jinx that slows the movement of the target
e5c22d31-26f1-4c88-a586-d9c09cb88c1f,Incarcerous,Conjures ropes
a53ad5be-00ee-4254-b3c0-4cec60b0c034,Imperio,"One of the three Unforgivable Curses, it places the target under the complete control of the caster"
a3b34bf6-1ff7-4fe3-81ee-e617150f5da9,Impervius,Makes an object waterproof
de048df0-b227-4376-a29b-90fe6878d950,Incendio,Conjures flames
c4a4520b-b80d-49e8-9e5a-3ca0a7f376ca,Langlock,Causes the target's tongue to stick to the roof of their mouth
0da7cb76-dabc-46ff-b8e9-c23a4f03caea,Legilimens,Invading or navigating another's mind
723dd9c9-ee62-495b-9071-cddd16087b86,Levicorpus,Levitates the target by their ankle
8add16ef-b4b1-4e2b-a91e-80aa194da438,Locomotor Mortis,The Leg-Locker curse bounds the target's legs
3b7a10ce-3339-4a36-9493-292c8775e47b,Lumos,Illuminates the caster's wand
832edaca-dbff-4a57-80c7-1d8a827c8416,Morsmordre,Conjures and projects Lord Voldemort's Dark Mark
7f4b43e0-3356-43f9-9299-15ec37cfaf76,Mucus Ad Nauseam,Inflicts an extreme runny nose or cold
f86bbf7e-94ea-4c22-89fb-809af8214a85,Muffliato,Creates a buzzing sound in the target's ears to prevent eavesdropping
66be613d-532c-46d8-a3e9-f5a2d9cccf0c,Nox,"Reverses the lumos charm, extinguishing a wand's light"
9e3c0217-652a-4763-82f8-5519026a1ea6,Obliviate,Erases the target's memory
0af49753-c8ae-4748-87a7-b7cfc47d33a0,Obscuro,Conjures a blindfold
67e838c1-4623-414e-9a91-12125631dbad,Oculus Reparo,Repairs eyeglasses
12251f32-af9d-408f-a652-3a4cc9602bc0,Oppugno,Directs an object or person to attack a victim
da9eab7b-2c7c-42de-861c-fb254bd9423c,Petrificus Totalus,Temporarily freezes or petrifies the body of the target
3e5fd245-2ecf-40c4-937d-b2c2f9eee003,Periculum,Conjures flares/red sparks
ad5685f8-6e05-49b1-a41c-d72786001d72,Piertotum Locomotor,Incantation used to bring to life inanimate objects and artifacts
0a267162-0594-4372-a3d5-89382926f495,Protean Charm,Links objects together for better communication
8808aa30-39f4-400c-a0e5-1dcbad657931,Protego,"Casts an invisible shield around the caster, protecting against spells and objects (except for The Killing Curse)"
56742dd7-3c93-4085-bea3-971e88d81dc2,Reducto,Reduces the target to pieces
2f177949-1f80-4663-9840-da8197411f2a,Reducio,Shrinks an enlarged object to its regular size
358ecb3c-e684-492c-b706-47cbd1eae02e,Renneverate,Awakens or revives the target
1b7a8a4c-8d4f-4001-8155-e68f1198ef72,Reparifors,Heals magical ailments like poisoning or paralysis
799f31a3-799e-411f-b67c-a64e48a5f503,Reparo,Fixes broken objects
32dbeb89-0978-4037-ab1b-413d62be02c3,Rictusempra,A charm that disarms an opponent by tickling them
c9dc8bed-5834-4001-8fa1-852690d027f2,Riddikulus,"Used to defeat a Boggart, the charm allows the scary creature to assume a comedic form, disarming it"
14c47e18-cbf3-4aec-afd3-5473d18ee7c0,Scourgify,Cleans objects
3617c34c-e650-4e3b-a13a-651d18471225,Sectumsempra,Inflicts severe lacerations and haemorrhaging on the target
53747fb8-bdab-466e-90fb-ca75c66f3dd9,Serpensortia,Conjures a live snake
43d3d53e-7ab9-4145-bda7-d96be99c5d31,Silencio,Silences the target
d5f71164-fa43-4566-b537-8852859bde01,Sonorus,Amplifies the witch or wizard's voice
9ec3258c-bc2f-4427-8440-ebea450a44aa,Spongify,Softens the target
37110a48-07e3-4fd7-9aae-ac1145161e1e,Stupefy,The Stunning spell freezes objects and renders living targets unconscious
daeb6f2a-5aff-43e1-964a-a06da7f66a3c,Tarantallegra,"Aimed at the legs, causes uncontrollable dancing movement"
4eaa6532-3ef2-428d-922f-101aee3d66ed,Unbreakable Vow,A magically binding contract that results in the death of whoever breaks it
e23728b2-f6fd-4c70-a1d2-ce602940d873,Wingardium Leviosa,"Causes an object to levitate; but remember what Hermione said: ""It's Wing-gar-dium Levi-o-sa, make the 'gar' nice and long.'"""
================================================
FILE: apps/api/harry-potter-db-seed-users.csv
================================================
id,forename,surname,email
fd142190-f1d7-4ce2-bdb3-6ed6b3edc020,Patricia,Stimpson,patriciastimpson@hogwarts.com
f94086b8-03ae-4457-ba2c-e624d0980869,Lavender,Brown,lavenderbrown@hogwarts.com
ecca342d-d345-4fb3-8a85-ece848ab8938,Milicent,Bullstroude,milicentbullstroude@hogwarts.com
ec714982-e604-40d4-bd4c-dc5155506957,Morag,MacDougal,moragmacdougal@hogwarts.com
eaea5eb3-48a3-41c6-9ea5-c695299bab16,Lisa,Turpin,lisaturpin@hogwarts.com
e7f4554e-8193-4b16-a40b-a8b38a0c3e57,Graham,Montague,grahammontague@hogwarts.com
e65c8acb-0dfc-4f15-bcf8-d32b78811093,Rose,Zeller,rosezeller@hogwarts.com
e4653b01-76a5-4769-a6a2-1f2efaf89cbb,Rose,Weasley,roseweasley@hogwarts.com
e32dd37c-91cd-4950-8ef2-e2ba1b87bd75,Lily,Moon,lilymoon@hogwarts.com
dcdc063e-cf3e-48fc-b777-65922e899b38,Albus,Severus,albusseverus@hogwarts.com
d9cec110-a1d0-4437-9a55-dced475dfe6d,Andrew,Kirke,andrewkirke@hogwarts.com
d5c4daa3-c726-426a-aa98-fb40f3fba816,Cedric,Diggory,cedricdiggory@hogwarts.com
cf3707ad-e816-4b54-90d0-403800a06ecd,Emma,Dobbs,emmadobbs@hogwarts.com
cb263aed-289b-43ad-8647-db54b8a5fc92,Michael,Corner,michaelcorner@hogwarts.com
c8aed011-ab8f-46df-9e8d-dde938256ea9,Miles,Bletchley,milesbletchley@hogwarts.com
c74b1fae-4793-4b47-bec2-ee652beabce2,Ritchie,Coote,ritchiecoote@hogwarts.com
c61b5c80-2c8e-404f-88ca-349a6344f35c,Cassius,Warrington,cassiuswarrington@hogwarts.com
c5acae3e-1a05-4f1d-bb83-3f8c7639d84e,Mandy,Brocklehurst,mandybrocklehurst@hogwarts.com
c3b1f9a5-b87b-48bf-b00d-95b093ea6390,Ron,Weasley,ronweasley@hogwarts.com
c29cd5f9-d2c3-4be9-ba1c-04169cdf511b,Alicia,Spinet,aliciaspinet@hogwarts.com
bff82738-5bb0-4edc-9cec-f80d1af4801f,Vicky,Frobisher,vickyfrobisher@hogwarts.com
b78e6677-8bb4-4eb7-97cb-2f86677e27ea,Adrian,Pucey,adrianpucey@hogwarts.com
b634f0a1-7b48-49b6-b039-27f947ee76fd,Angelina,Johnson,angelinajohnson@hogwarts.com
b01be346-290b-4f65-9c88-a49922e116ee,Orla,Quirke,orlaquirke@hogwarts.com
af95bd8a-dfae-45bb-bc69-533860d34129,Draco,Malfoy,dracomalfoy@hogwarts.com
ae068570-8419-4063-bf61-ba4a0ef41fe3,Laura,Madley,lauramadley@hogwarts.com
a93b80a0-987d-4148-944d-16043df95e8c,Dennis,Creevey,denniscreevey@hogwarts.com
a506574f-c8cf-46c6-a8ac-2f805c25e49e,Graham,Pritchard,grahampritchard@hogwarts.com
a3e5ea64-b103-4f47-bc26-dc08b799c668,Eddie,Carmichael,eddiecarmichael@hogwarts.com
a31ddc78-af12-4978-929c-3cc8a00a833e,Gregory,Goyle,gregorygoyle@hogwarts.com
a01f6dbb-bad5-426b-a7df-f9613fa1021d,Euan,Abercrombie,euanabercrombie@hogwarts.com
9e3f7ce4-b9a7-4244-b709-dae5c1f1d4a8,Harry,Potter,harrypotter@hogwarts.com
9c8ce8c7-ae0a-4646-920f-09c071862f10,James,Potter,jamespotter@hogwarts.com
9ba0ca6e-4fba-410d-9b5e-e20694dde413,Melinda,Bobbin,melindabobbin@hogwarts.com
9ac09267-92ea-444a-a395-28f3b0f6fe6f,Terrence,Higgs,terrencehiggs@hogwarts.com
98546bab-8d5b-4627-95f6-38e306d58a91,Owen,Cauldwell,owencauldwell@hogwarts.com
979ab773-944f-4ff8-88be-943a4bc2c18a,Lee,Jordan,leejordan@hogwarts.com
938559ee-e8e5-4963-8437-e7da04fd1b31,Marcus,Belby,marcusbelby@hogwarts.com
9055a7b1-6ac9-4363-977c-4dec78572fad,Terry,Boot,terryboot@hogwarts.com
8f9aa40b-5d7c-441e-ad32-4564ecda3b70,Cho,Chang,chochang@hogwarts.com
8f3b8796-c7b9-442e-ac02-113d48306fc7,Percy,Weasley,percyweasley@hogwarts.com
8e557e86-28d5-433f-8ac1-d2cecfeb8fb7,Colin,Creevey,colincreevey@hogwarts.com
88886e27-9ce2-416f-9dd6-56d4cd94a4fb,Geoffrey,Hooper,geoffreyhooper@hogwarts.com
861c4cde-2f0f-4796-8d8f-9492e74b2573,Luna,Lovegood,lunalovegood@hogwarts.com
7f2f6207-8998-4f98-92c2-8d02898a82eb,Scorpius,Malfoy,scorpiusmalfoy@hogwarts.com
7cc5e694-850d-4c44-830b-7154e23bb5c3,Susan,Bones,susanbones@hogwarts.com
781f1061-5413-40c7-8a35-b078e2e969b1,Barnabas,the,barnabasthe@hogwarts.com
7772cb4e-5c33-405a-970d-c05cae167917,Daphne,Greengrass,daphnegreengrass@hogwarts.com
6fa93583-b935-4228-91e0-729e6713bdab,Zacharias,Smith,zachariassmith@hogwarts.com
6c4350a9-2356-4bba-96bd-0458c12d99b5,Romilda,Vane,romildavane@hogwarts.com
69c18f6a-cd97-4218-9f2f-740393e6eb1f,Padma,Patil,padmapatil@hogwarts.com
61b6d68e-4128-408c-9f71-9ef167cb0e69,Anthony,Goldstein,anthonygoldstein@hogwarts.com
58a287c2-8c7a-485a-b095-8c6dcfc7f31d,Lucian,Bole,lucianbole@hogwarts.com
57fe29d4-312a-4711-bd9a-c320253d9176,Victoire,Weasley,victoireweasley@hogwarts.com
575fbbc2-ac94-4c58-92f6-e5d75846da91,Jack,Sloper,jacksloper@hogwarts.com
4eef1e03-cf1c-4441-9119-a6e47a61f880,Kevin,Whitby,kevinwhitby@hogwarts.com
4c7e6819-a91a-45b2-a454-f931e4a7cce3,Hermione,Granger,hermionegranger@hogwarts.com
4a0f4c3b-14dc-4a9e-a2f8-da23734f5d34,Marietta,Edgecombe,mariettaedgecombe@hogwarts.com
48880498-3903-4914-bd11-ec650d803199,Natalie,McDonald,nataliemcdonald@hogwarts.com
47aa7511-59b9-4760-9bd7-822a1103177b,Theodore,Nott,theodorenott@hogwarts.com
458828b3-82a5-4cad-a784-e23215825765,Peregrine,Derrick,peregrinederrick@hogwarts.com
42915280-ba56-4ab8-8b17-9511ba2ab093,Penelope,Clearwater,penelopeclearwater@hogwarts.com
3db6dc51-b461-4fa4-a6e4-b1ff352221c5,Neville,Longbottom,nevillelongbottom@hogwarts.com
3d629315-1dbb-4e1e-840d-ffbf45bd5894,Sally-Anne,Perks,sally-anneperks@hogwarts.com
341e65d4-6917-48d7-80b2-1f9af607e95a,Cormac,McLaggen,cormacmclaggen@hogwarts.com
34155375-c8c0-415e-873a-b6483f0cbf17,Justin,Finch-Fletchley,justinfinch-fletchley@hogwarts.com
2f8db183-e935-4b91-884f-fb9effe42ab8,Malcolm,Baddock,malcolmbaddock@hogwarts.com
2b203c7e-7b3d-4f27-8b3c-11473904da73,Hugo,Weasley,hugoweasley@hogwarts.com
2a0615de-8aa4-41e7-9504-dd875f5f3f01,George,Weasley,georgeweasley@hogwarts.com
29adbbf0-417a-4c97-8467-adb5341f75e5,Eleanor,Branstone,eleanorbranstone@hogwarts.com
28e9fe6b-3ca5-41ca-8a14-b995e0fb398b,Jimmy,Peakes,jimmypeakes@hogwarts.com
2899e63f-ed02-4152-8ace-0270a068a70d,Pansy,Parkinson,pansyparkinson@hogwarts.com
28741184-263c-4000-b011-ca7c60466ef4,Fred,Weasley,fredweasley@hogwarts.com
2832bea8-7aad-4160-a748-442f5770d586,Katie,Bell,katiebell@hogwarts.com
26bd4437-73fa-4865-afdd-2fc1456f4592,Kenneth,Towler,kennethtowler@hogwarts.com
1fab149b-52b1-4ffe-be52-4eda25d98f5d,Blaise,Zabini,blaisezabini@hogwarts.com
1cd6dc64-01a9-4379-9cfd-1a7167ba1bb1,Ginny,Weasley,ginnyweasley@hogwarts.com
14aca981-2b60-413e-8f8e-3534961b534b,Millicent,Bulstrode,millicentbulstrode@hogwarts.com
1413e1b3-2903-4a47-a2d5-e8abc5ce8014,Seamus,Finnigan,seamusfinnigan@hogwarts.com
13a54f8a-7f68-4add-a1b4-49f60c8e7bcc,Eloise,Midgen,eloisemidgen@hogwarts.com
0e53860c-7679-49e4-891e-fb92286f0e5b,Demelza,Robins,demelzarobins@hogwarts.com
0e42ecbe-27b2-4940-9b03-00182a92c415,Marcus,Flint,marcusflint@hogwarts.com
0c80d701-fa23-4126-9711-efe5f3c4789a,Ernie,Macmillan,erniemacmillan@hogwarts.com
0af82694-e24f-45ec-a8d7-5bb1199ce631,Hannah,Abbott,hannahabbott@hogwarts.com
0a13bf8e-a763-44cc-ac76-c6c53a639809,Roger,Davies,rogerdavies@hogwarts.com
09396e81-d317-499f-b330-25b90ba17d20,Oliver,Wood,oliverwood@hogwarts.com
05bd5fd1-f347-45e6-8ec0-59b7f11c2aec,Stewart,Ackerley,stewartackerley@hogwarts.com
04f9eb45-d843-4e29-a7d3-0bd49ed87f85,Vincent,Crabbe,vincentcrabbe@hogwarts.com
0201cf73-8a86-4358-b232-2abaa23f09af,Parvati,Patil,parvatipatil@hogwarts.com
ca3827f0-375a-4891-aaa5-f5e8a5bad225,Minerva,McGonagall,minervamcgonagall@hogwarts.com
3569d265-bd27-44d8-88e8-82fb0a848374,Severus,Snape,severussnape@hogwarts.com
36bfefd0-e0bb-4d11-be98-d1ef6117a77a,Rubeus,Hagrid,rubeushagrid@hogwarts.com
b8f9095b-9de6-4d7d-83e0-4391af8f22e4,Remus,Lupin,remuslupin@hogwarts.com
2fb675cd-5505-4c8e-a54e-579e73bf4174,Horace,Slughorn,horaceslughorn@hogwarts.com
d58e7249-19d1-40bd-a43f-1da0497fe8aa,Dolores,Umbridge,doloresumbridge@hogwarts.com
b0620914-858d-46fc-8e6d-033c565e138b,Mrs,Norris,mrsnorris@hogwarts.com
2b82cfb8-0440-4a57-a030-6d75a40c0d98,Argus,Filch,argusfilch@hogwarts.com
b415c867-1cff-455e-b194-748662ac2cca,Albus,Dumbledore,albusdumbledore@hogwarts.com
e9457467-d10a-4893-afa9-19f9602b218a,Madam,Pomfrey,madampomfrey@hogwarts.com
ba19be27-178b-4594-95b7-51ba0e3ba1dd,Quirinus,Quirrel,quirinusquirrel@hogwarts.com
e8694719-a975-48fb-9523-f4cade1c38aa,Pomona,Sprout,pomonasprout@hogwarts.com
6ea188f3-d95c-407c-ab00-a0bec8678a71,Cuthbert,Binns,cuthbertbinns@hogwarts.com
a61e0783-7914-4f8d-a800-c409c06315cf,Filius,Flitwick,filiusflitwick@hogwarts.com
0a81c4f9-b80d-45a7-a4fd-9191453815a1,Madam,Hooch,madamhooch@hogwarts.com
3d687c4d-852e-470f-bac5-5a02758b1f8f,Gilderoy,Lockhart,gilderoylockhart@hogwarts.com
cdec9b95-c7a5-4623-ad12-6fa76d168588,Madame,Pince,madamepince@hogwarts.com
8ea29415-012d-4781-ba5f-d0de63a05abe,Sybill,Trelawney,sybilltrelawney@hogwarts.com
58f2cf41-392c-4e84-b441-dbbce585f78d,Septima,Vector,septimavector@hogwarts.com
99d3ce6b-6a45-495a-a7c6-132203697d45,Aurora,Sinistra,aurorasinistra@hogwarts.com
41ebe856-f0f4-4c77-8795-4735d3a87f3d,Alastor,Moody,alastormoody@hogwarts.com
b48c5b8a-4066-4c24-ba26-7677f5ed2b6f,Wilhelmina,Grubbly-Plank,wilhelminagrubbly-plank@hogwarts.com
c4e73590-3ee2-4125-87fb-692dd991819b,Galatea,Merrythought,galateamerrythought@hogwarts.com
61d78dce-890b-4f02-844f-b41d66553802,Charity,Burbage,charityburbage@hogwarts.com
================================================
FILE: apps/api/package.json
================================================
{
"name": "api",
"version": "0.0.0",
"scripts": {
"dev": ".\\.venv\\Scripts\\python run.py",
"generate:requirements": "poetry export --without-hashes --format=requirements.txt > requirements.txt"
}
}
================================================
FILE: apps/api/poetry.toml
================================================
[virtualenvs]
in-project = true
create = true
================================================
FILE: apps/api/pyproject.toml
================================================
[tool.poetry]
name = "api"
version = "0.1.0"
description = ""
authors = ["cording12 "]
[tool.poetry.dependencies]
python = "^3.9"
fastapi = "^0.109.2"
uvicorn = "^0.27.1"
email-validator = "^2.1.0"
pydantic-settings = "^2.2.1"
python-dotenv = "^1.0.1"
supabase-py-async = "^2.5.5"
[tool.poetry.dev-dependencies]
isort = "^5.10.1"
black = "^22.6.0"
pytest = "^8.0.1"
pylint-pydantic = "^0.3.2"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
================================================
FILE: apps/api/requirements.txt
================================================
aiohttp==3.9.3; python_version >= "3.9" and python_version < "4.0"
aiosignal==1.3.1; python_version >= "3.9" and python_version < "4.0"
annotated-types==0.6.0; python_version >= "3.8"
anyio==4.3.0; python_version >= "3.9" and python_version < "4.0"
argcomplete==3.2.3; python_version >= "3.9" and python_version < "4.0"
async-timeout==4.0.3; python_version >= "3.9" and python_version < "3.11"
attrs==23.2.0; python_version >= "3.9" and python_version < "4.0"
certifi==2024.2.2; python_version >= "3.9" and python_version < "4.0"
charset-normalizer==3.3.2; python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.7.0"
click==8.1.7; python_version >= "3.8"
colorama==0.4.6; python_version >= "3.9" and python_full_version < "3.0.0" and platform_system == "Windows" and python_version < "4.0" or platform_system == "Windows" and python_version >= "3.9" and python_full_version >= "3.7.0" and python_version < "4.0"
commitizen==3.18.4; python_version >= "3.9" and python_version < "4.0"
decli==0.6.1; python_version >= "3.9" and python_version < "4.0"
deprecation==2.1.0; python_version >= "3.9" and python_version < "4.0"
dnspython==2.6.1; python_version >= "3.8"
email-validator==2.1.1; python_version >= "3.8"
exceptiongroup==1.2.0; python_version < "3.11" and python_version >= "3.8"
fastapi==0.109.2; python_version >= "3.8"
frozenlist==1.4.1; python_version >= "3.9" and python_version < "4.0"
gotrue==2.4.1; python_version >= "3.9" and python_version < "4.0"
h11==0.14.0; python_version >= "3.9" and python_version < "4.0"
httpcore==1.0.4; python_version >= "3.9" and python_version < "4.0"
httpx==0.25.2; python_version >= "3.9" and python_version < "4.0"
idna==3.6; python_version >= "3.9" and python_version < "4.0"
importlib-metadata==7.0.2; python_version >= "3.9" and python_version < "4.0"
jinja2==3.1.3; python_version >= "3.9" and python_version < "4.0"
markupsafe==2.1.5; python_version >= "3.9" and python_version < "4.0"
multidict==6.0.5; python_version >= "3.9" and python_version < "4.0"
packaging==24.0; python_version >= "3.9" and python_version < "4.0"
postgrest==0.16.1; python_version >= "3.9" and python_version < "4.0"
prompt-toolkit==3.0.36; python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.6.2"
pydantic-core==2.16.3; python_version >= "3.8"
pydantic-settings==2.2.1; python_version >= "3.8"
pydantic==2.6.4; python_version >= "3.9" and python_version < "4.0"
python-dateutil==2.9.0.post0; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.3.0"
python-dotenv==1.0.1; python_version >= "3.8"
pyyaml==6.0.1; python_version >= "3.9" and python_version < "4.0"
questionary==2.0.1; python_version >= "3.9" and python_version < "4.0"
realtime==1.0.2; python_version >= "3.9" and python_version < "4.0"
six==1.16.0; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.3.0"
sniffio==1.3.1; python_version >= "3.9" and python_version < "4.0"
starlette==0.36.3; python_version >= "3.8"
storage3==0.7.3; python_version >= "3.9" and python_version < "4.0"
strenum==0.4.15; python_version >= "3.9" and python_version < "4.0"
supabase-py-async==2.5.5; python_version >= "3.9" and python_version < "4.0"
supafunc==0.4.0; python_version >= "3.9" and python_version < "4.0"
termcolor==2.4.0; python_version >= "3.9" and python_version < "4.0"
tomlkit==0.12.4; python_version >= "3.9" and python_version < "4.0"
typing-extensions==4.10.0; python_version < "3.10" and python_version >= "3.9"
uvicorn==0.27.1; python_version >= "3.8"
wcwidth==0.2.13; python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.6.2"
websockets==11.0.3; python_version >= "3.9" and python_version < "4.0"
yarl==1.9.4; python_version >= "3.9" and python_version < "4.0"
zipp==3.18.1; python_version >= "3.9" and python_version < "4.0"
================================================
FILE: apps/api/run.py
================================================
import uvicorn
if __name__ == "__main__":
uvicorn.run("src.main:app", reload=True)
================================================
FILE: apps/api/src/__init__.py
================================================
__version__ = "0.1.0"
================================================
FILE: apps/api/src/api/__init__.py
================================================
================================================
FILE: apps/api/src/api/api_v1/__init__.py
================================================
================================================
FILE: apps/api/src/api/api_v1/api.py
================================================
from fastapi import APIRouter
from src.api.api_v1.endpoints import users, spells
api_router = APIRouter()
api_router.include_router(users.router, prefix="/users", tags=["users"], responses={404: {"description": "Not found"}})
api_router.include_router(spells.router, prefix="/spells", tags=["spells"], responses={404: {"description": "Not found"}})
================================================
FILE: apps/api/src/api/api_v1/endpoints/__init__.py
================================================
================================================
FILE: apps/api/src/api/api_v1/endpoints/spells.py
================================================
from typing import Literal, Optional, Union
from fastapi import APIRouter, HTTPException
from src.api.deps import SessionDep
from src.crud import spell
from src.schemas import Spell, SpellSearchResults
router = APIRouter()
@router.get("/get/", status_code=200, response_model=Spell)
async def get_spell(session: SessionDep, spell_id: str) -> Spell:
"""Returns a spell from a spell_id.
**Returns:**
- spell: spell object.
"""
return await spell.get(session, id=spell_id)
@router.get("/get-all/", status_code=200, response_model=list[Spell])
async def get_all_spells(session: SessionDep) -> list[Spell]:
"""Returns a list of all spells.
**Returns:**
- list[spell]: List of all spells.
"""
return await spell.get_all(session)
@router.get("/search/", status_code=200, response_model=SpellSearchResults)
async def search_spells(
session: SessionDep,
search_on: Literal["id", "name", "description"] = "name",
keyword: Optional[Union[str, int]] = None,
max_results: Optional[int] = 10,
) -> SpellSearchResults:
"""
Search for spells based on a keyword and return the top `max_results` items.
**Args:**
- search_on (str, optional): The field to perform the search on. Defaults to "name".
- keyword (str, optional): The keyword to search for. Defaults to None.
- max_results (int, optional): The maximum number of search results to return. Defaults to 10.
**Returns:**
- SpellSearchResults: Object containing a list of the top `max_results` items that match the keyword.
"""
if not keyword:
results = await spell.get_all(session)
return SpellSearchResults(results=results)
results = await spell.search_all(
session, field=search_on, search_value=keyword, max_results=max_results
)
if not results:
raise HTTPException(
status_code=404, detail="No spells found matching the search criteria"
)
return SpellSearchResults(results=results)
================================================
FILE: apps/api/src/api/api_v1/endpoints/users.py
================================================
from typing import Literal, Optional, Union
from fastapi import APIRouter, HTTPException
from src.api.deps import SessionDep
from src.crud import user
from src.schemas import User, UserCreate, UserSearchResults
router = APIRouter()
@router.get("/get/", status_code=200, response_model=User)
async def get_user(session: SessionDep, user_id: str) -> User:
"""Returns a user from a user_id.
**Returns:**
- User: User object.
"""
return await user.get(session, id=user_id)
@router.get("/get-all/", status_code=200, response_model=list[User])
async def get_all_users(session: SessionDep) -> list[User]:
"""Returns a list of all users.
**Returns:**
- list[User]: List of all users.
"""
return await user.get_all(session)
@router.get("/search/", status_code=200, response_model=UserSearchResults)
async def search_users(
session: SessionDep,
search_on: Literal["id", "email", "forename", "surname"] = "email",
keyword: Optional[Union[str, int]] = None,
max_results: Optional[int] = 10,
) -> UserSearchResults:
"""
Search for users based on a keyword and return the top `max_results` items.
**Args:**
- keyword (str, optional): The keyword to search for. Defaults to None.
- max_results (int, optional): The maximum number of search results to return. Defaults to 10.
- search_on (str, optional): The field to perform the search on. Defaults to "email".
**Returns:**
- UserSearchResults: Object containing a list of the top `max_results` items that match the keyword.
"""
if not keyword:
results = await user.get_all(session)
return UserSearchResults(results=results)
results = await user.search_all(
session, field=search_on, search_value=keyword, max_results=max_results
)
if not results:
raise HTTPException(
status_code=404, detail="No users found matching the search criteria"
)
return UserSearchResults(results=results)
@router.post("/create", status_code=201, response_model=User)
async def create_user(user_in: UserCreate, session: SessionDep) -> User:
"""Craete a new user.
**Args:**
- user_in (UserCreate): JSON of the user to create. Forename, surname and email. Email must be unique.
**Returns:**
- User: User object
"""
return await user.create(session, obj_in=user_in)
================================================
FILE: apps/api/src/api/deps.py
================================================
from typing import Annotated
from fastapi import Depends, HTTPException
from supabase_py_async import AsyncClient, create_client
from supabase_py_async.lib.client_options import ClientOptions
from src.config import settings
async def get_db() -> AsyncClient:
client: AsyncClient | None = None
try:
client = await create_client(
settings.DB_URL,
settings.DB_API_KEY,
options=ClientOptions(
postgrest_client_timeout=10, storage_client_timeout=10
),
)
# client = await client.auth.sign_in_with_password(
# {"email": settings.DB_EMAIL, "password": settings.DB_PASSWORD}
# )
yield client
except Exception as e:
print(e)
raise
SessionDep = Annotated[AsyncClient, Depends(get_db)]
================================================
FILE: apps/api/src/config.py
================================================
import os
from dotenv import load_dotenv
from pydantic_settings import BaseSettings, SettingsConfigDict
load_dotenv()
# If the environment is Gitpod, the root path will be the workspace cluster host
# If not using gitpod, you can delete this if statement, but keep the else clause
if os.getenv("USER") == "gitpod":
ROOT_PATH = f"https://8000-cording12-nextfastturbo-qqfo0frc496.{os.getenv('GITPOD_WORKSPACE_CLUSTER_HOST')}"
else:
# Otherwise, the root path will be the local host. ROOT_PATH is an env var configured in Vercel deployment.
# The value for production is equal to the root path of the deployment URL in Vercel.
ROOT_PATH = os.getenv("ROOT_PATH", "http://127.0.0.1:8000")
class Settings(BaseSettings):
PROJECT_NAME: str = "FastAPI App"
PROJECT_DESCRIPTION: str = "A simple FastAPI app"
DB_URL: str = os.getenv("DB_URL")
DB_API_KEY: str = os.getenv("DB_API_KEY")
DB_EMAIL: str = os.getenv("DB_EMAIL")
DB_PASSWORD: str = os.getenv("DB_PASSWORD")
model_config = SettingsConfigDict(env_file=".env")
API_VERSION: str = "/api/v1"
ROOT: str = ROOT_PATH
settings = Settings()
================================================
FILE: apps/api/src/crud/__init__.py
================================================
from .crud_spell import spell
from .crud_user import user
================================================
FILE: apps/api/src/crud/base.py
================================================
from typing import Generic, Optional, TypeVar
from supabase_py_async import AsyncClient
from src.schemas.base import CreateBase, ResponseBase, UpdateBase
ModelType = TypeVar("ModelType", bound=ResponseBase)
CreateSchemaType = TypeVar("CreateSchemaType", bound=CreateBase)
UpdateSchemaType = TypeVar("UpdateSchemaType", bound=UpdateBase)
class CRUDBase(Generic[ModelType, CreateSchemaType, UpdateSchemaType]):
def __init__(self, model: type[ModelType]):
"""CRUD object with default methods to do CRUD ops
Args:
model (type[ModelType]): Model class type
"""
self.model = model
async def get(self, db: AsyncClient, *, id: str) -> Optional[ModelType]:
"""get by table_name by id"""
data, count = (
await db.table(self.model.table_name).select("*").eq("id", id).execute()
)
_, got = data
return self.model(**got[0]) if got else None
async def get_all(self, db: AsyncClient) -> list[ModelType]:
"""get all by table_name"""
data, count = await db.table(self.model.table_name).select("*").execute()
_, got = data
return [self.model(**item) for item in got]
async def search_all(
self, db: AsyncClient, *, field: str, search_value: str, max_results: int
) -> list[ModelType]:
"""search all by table_name"""
data, count = (
await db.table(self.model.table_name)
.select("*")
.ilike(field, f"%{search_value}%")
.limit(max_results)
.execute()
)
_, got = data
return [self.model(**item) for item in got]
async def create(self, db: AsyncClient, *, obj_in: CreateSchemaType) -> ModelType:
"""create by CreateSchemaType"""
data, count = (
await db.table(self.model.table_name).insert(obj_in.model_dump()).execute()
)
_, created = data
return self.model(**created[0])
async def update(self, db: AsyncClient, *, obj_in: UpdateSchemaType) -> ModelType:
"""update by UpdateSchemaType"""
data, count = (
await db.table(self.model.table_name)
.update(obj_in.model_dump())
.eq("id", obj_in.id)
.execute()
)
_, updated = data
return self.model(**updated[0])
async def delete(self, db: AsyncClient, *, id: str) -> ModelType:
"""remove by UpdateSchemaType"""
data, count = (
await db.table(self.model.table_name).delete().eq("id", id).execute()
)
_, deleted = data
return self.model(**deleted[0])
================================================
FILE: apps/api/src/crud/crud_spell.py
================================================
from typing import Optional
from fastapi import HTTPException
from supabase_py_async import AsyncClient
from src.crud.base import CRUDBase
from src.schemas import Spell, SpellCreate, SpellUpdate
class CRUDSpell(CRUDBase[Spell, SpellCreate, SpellUpdate]):
async def get(self, db: AsyncClient, *, id: str) -> Optional[Spell]:
try:
return await super().get(db, id=id)
except Exception as e:
raise HTTPException(
status_code=404,
detail=f"{e.code}: Spell not found. {e.details}",
)
async def get_all(self, db: AsyncClient) -> list[Spell]:
try:
return await super().get_all(db)
except Exception as e:
raise HTTPException(
status_code=404,
detail=f"An error occurred while fetching spells. {e}",
)
async def search_all(
self, db: AsyncClient, *, field: str, search_value: str, max_results: int
) -> list[Spell]:
try:
return await super().search_all(
db, field=field, search_value=search_value, max_results=max_results
)
except Exception as e:
raise HTTPException(
status_code=404,
detail=f"An error occurred while searching for users. {e}",
)
spell = CRUDSpell(Spell)
================================================
FILE: apps/api/src/crud/crud_user.py
================================================
from typing import Optional
from fastapi import HTTPException
from supabase_py_async import AsyncClient
from src.crud.base import CRUDBase
from src.schemas import User, UserCreate, UserUpdate
class CRUDUser(CRUDBase[User, UserCreate, UserUpdate]):
async def create(self, db: AsyncClient, *, obj_in: UserCreate) -> User:
try:
return await super().create(db, obj_in=obj_in)
except Exception as e:
raise HTTPException(
status_code=400,
detail=f"{e.code}: Failed to create user. {e.details}",
)
async def get(self, db: AsyncClient, *, id: str) -> Optional[User]:
try:
return await super().get(db, id=id)
except Exception as e:
raise HTTPException(
status_code=404,
detail=f"{e.code}: User not found. {e.details}",
)
async def get_all(self, db: AsyncClient) -> list[User]:
try:
return await super().get_all(db)
except Exception as e:
raise HTTPException(
status_code=404,
detail=f"An error occurred while fetching users. {e}",
)
async def search_all(
self, db: AsyncClient, *, field: str, search_value: str, max_results: int
) -> list[User]:
try:
return await super().search_all(
db, field=field, search_value=search_value, max_results=max_results
)
except Exception as e:
raise HTTPException(
status_code=404,
detail=f"An error occurred while searching for users. {e}",
)
async def update(self, db: AsyncClient, *, obj_in: UserUpdate) -> User:
return await super().update(db, obj_in=obj_in)
async def delete(self, db: AsyncClient, *, id: str) -> User:
return await super().delete(db, id=id)
user = CRUDUser(User)
================================================
FILE: apps/api/src/main.py
================================================
from fastapi import APIRouter, FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.routing import APIRoute
from src.api.api_v1.api import api_router
from src.config import settings
info_router = APIRouter()
@info_router.get("/", status_code=200, include_in_schema=False)
async def info():
return [{"Status": "API Running"}]
def custom_generate_unique_id(route: APIRoute):
"""Generates a custom ID when using the TypeScript Generator Client
Args:
route (APIRoute): The route to be customised
Returns:
str: tag-route_name, e.g. items-CreateItem
"""
return f"{route.tags[0]}-{route.name}"
def get_application():
_app = FastAPI(
title=settings.PROJECT_NAME,
description=settings.PROJECT_DESCRIPTION,
generate_unique_id_function=custom_generate_unique_id,
root_path=settings.ROOT,
root_path_in_servers=True,
)
_app.include_router(api_router, prefix=settings.API_VERSION)
_app.include_router(info_router, tags=[""])
_app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
return _app
app = get_application()
================================================
FILE: apps/api/src/schemas/__init__.py
================================================
from .spell import Spell, SpellCreate, SpellSearchResults, SpellUpdate
from .user import User, UserCreate, UserSearchResults, UserUpdate
================================================
FILE: apps/api/src/schemas/base.py
================================================
from typing import ClassVar
from pydantic import BaseModel, ConfigDict
# Shared properties
# class CRUDBaseModel(BaseModel):
# # where the data
# table_name: str
# Properties to receive on item creation
# in
class CreateBase(BaseModel):
# inherent to add more properties for creating
pass
# Properties to receive on item update
# in
class UpdateBase(BaseModel):
# inherent to add more properties for updating
id: str
# response
# Properties shared by models stored in DB
class InDBBase(BaseModel):
id: str
user_id: str
created_at: str
# Properties to return to client
# crud model
# out
class ResponseBase(InDBBase):
# inherent to add more properties for responding
table_name: ClassVar[str] = "ResponseBase".lower()
Config: ClassVar[ConfigDict] = ConfigDict(
extra="ignore", arbitrary_types_allowed=True
)
================================================
FILE: apps/api/src/schemas/spell.py
================================================
from typing import ClassVar, Sequence
from pydantic import BaseModel
class Spell(BaseModel):
id: str
name: str
description: str
table_name: ClassVar[str] = "spells"
class SpellCreate(BaseModel):
id: str
name: str
description: str
class SpellUpdate(BaseModel):
id: str
name: str
description: str
class SpellSearchResults(BaseModel):
results: Sequence[Spell]
================================================
FILE: apps/api/src/schemas/user.py
================================================
from typing import ClassVar, Sequence
from pydantic import BaseModel, EmailStr
class User(BaseModel):
id: str
forename: str
surname: str
email: EmailStr
table_name: ClassVar[str] = "user"
class UserCreate(BaseModel):
forename: str
surname: str
email: EmailStr
class UserUpdate(BaseModel):
forename: str
surname: str
email: EmailStr
class ResponseMessage(BaseModel):
message: str
class UserSearchResults(BaseModel):
results: Sequence[User]
================================================
FILE: apps/api/tests/__init__.py
================================================
================================================
FILE: apps/api/tests/test_api.py
================================================
from src import __version__
def test_version():
assert __version__ == '0.1.0'
================================================
FILE: apps/api/vercel.json
================================================
{
"version": 2,
"builds": [
{
"src": "/src/main.py",
"use": "@vercel/python"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "src/main.py"
}
],
"env": {
"APP_MODULE": "src.main:app"
}
}
================================================
FILE: apps/docs/.vscode/extensions.json
================================================
{
"recommendations": ["unifiedjs.vscode-mdx", "xyc.vscode-mdx-preview"]
}
================================================
FILE: apps/docs/api/spells/get-all-spells.mdx
================================================
---
openapi: get /api/v1/spells/get-all/
---
================================================
FILE: apps/docs/api/spells/get-spell.mdx
================================================
---
openapi: get /api/v1/spells/get/
---
================================================
FILE: apps/docs/api/spells/search-spells.mdx
================================================
---
openapi: get /api/v1/spells/search/
---
================================================
FILE: apps/docs/api/users/create-user.mdx
================================================
---
openapi: post /api/v1/users/create
---
================================================
FILE: apps/docs/api/users/get-all-users.mdx
================================================
---
openapi: get /api/v1/users/get-all/
---
================================================
FILE: apps/docs/api/users/get-user.mdx
================================================
---
openapi: get /api/v1/users/get/
---
================================================
FILE: apps/docs/api/users/search-users.mdx
================================================
---
openapi: get /api/v1/users/search/
---
================================================
FILE: apps/docs/documentation/configuration/docs.mdx
================================================
---
title: Documentation config
"og:title": Mintlify setup and configuration
description: Mintlify setup and configuration
---
## Introduction
The documentation site is built entirely using Mintlify. Mintlify docs are rendered from MDX files and configurations. Mintlify works with a Github integration to
constantly build an independent docs site based off your latest published repository.
Documentation can be edited in raw MDX, or directly through the Mintlify dashboard (which stays in sync with your local Github repo).
Mintlify is fast to setup and provides tonnes of features out-the-box without the need to pay for a subscription for the basic services.
You can run the **docs site only** by running the `pnpm run dev` command from a terminal within the `docs` directory.
## Docs structure
The docs root directory is structured as follows:
```
docs
├── _images
├── api
├── configuration
├── deployment
├── logos
├── *.mdx
├── mint.json
└── package.json
```
The docs directory is relatively simple and is made mostly of MDX files. Some notable files are:
| Item | Description |
| ------------ | ----------------------------------------------------------- |
| api | Automatically generated files (except for Introduction.mdx) |
| mint.json | Mintlify configuration object |
| package.json | Scripts needed in the monorepo/for generating the API files |
## Creating API endpoint documentation
We can leverage FastAPI's baked in OpenAPI support to automatically generate API documentation.
Using Mintlify's `@mintlify/scraping` package, we can scrape our FastAPI's OpenAPI schema to generate an interactive API documentation site.
For a more detailed description, read the [official
documentation](https://mintlify.com/docs/api-playground/openapi/setup#create-mdx-files-for-openapi-endpoints)
### Generating OpenAPI schema
#### Step 1: Generate MDX
Run the `generate-api` scripts within the `package.json` to generate the required MDX
files. There are two scripts here, one configured to use the production
`OpenAPI.json` and the second configured to use the development version.\
\
It is typically preferred to use the production version once any changes to
your API have been made and published.
#### Step 2: Update mint.json
Upon generating the relevant API information, `@mintlify/scraping` helpfully outputs the suggested navigation to the terminal:
```bash
navigation object suggestion:
[
{
"group": "users",
"pages": [
"api/users/get-user",
"api/users/get-all-users",
"api/users/search-users",
"api/users/create-user"
]
},
{
"group": "spells",
"pages": [
"api/spells/get-spell",
"api/spells/get-all-spells",
"api/spells/search-spells"
]
}
]
```
For sake of simplicity, copy this navigation object suggestion and add it your `mint.json` under the `navigation` object:
```json
"navigation": [
{
"group": "Getting Started",
"pages": ["documentation/introduction", "documentation/local-development"]
},
{
"group": "Configuration",
"pages": [
"documentation/configuration/turbo",
"documentation/configuration/fastapi",
"documentation/configuration/nextjs",
"documentation/configuration/docs"
]
},
{
"group": "Deployment",
"pages": [
"documentation/deployment/vercel",
"documentation/deployment/deployment"
]
},
{
"group": "API Reference",
"pages": ["api/introduction"]
},
{
"group": "Users",
"pages": [
"api/users/get-user",
"api/users/get-all-users",
"api/users/search-users",
"api/users/create-user"
]
},
{
"group": "Spells",
"pages": [
"api/spells/get-spell",
"api/spells/get-all-spells",
"api/spells/search-spells"
]
}
],
```
Add the `openapi` key to your `mint.json`. This, preferably, can be linked to your published OpenAPI schema:
```json
{
...
"openapi":"https://next-fast-turbo-api.vercel.app/openapi.json"
...
}
```
This enables the generated MDX files to describe and interact with your API.
This has been hit and miss in the past for me. If doing this does not auto-populate your API reference with the documentation, the solution is to manually\
create an `openapi.json` file in the `docs` root. Manually copy and paste/save your `openapi.json` into this file.
================================================
FILE: apps/docs/documentation/configuration/fastapi.mdx
================================================
---
title: FastAPI config
"og:title": "FastAPI configuration and setup"
description: FastAPI configuration and setup
---
## Introduction
The backend uses [FastAPI](https://fastapi.tiangolo.com/). FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.8+ based on standard Python type hints
You can run the **api only** by running the `pnpm run dev` command from a terminal within the `api` directory. Alternatively, you can directly run the `run.py` file.
## API structure
The API root directory is structured as follows:
```
api
├── src
│ ├── api
│ ├── crud
│ ├── schemas
│ ├── __init__.py
│ ├── config.py
│ └── main.py
├── tests
├── .env
├── .env.example
├── harry-potter-db-seed-spells.csv
├── harry-potter-db-seed-users.csv
├── package.json
├── poetry.lock
├── pyproject.toml
├── requirements.txt
├── run.py
└── vercel.json
```
### Src directory
The `src` directory is where all the application code sits. Below briefly explains each folder/file
| Item | Description |
| --------- | ----------------------------------------------- |
| api | The API endpoints for the application |
| crud | The CRUD operations used within the application |
| schemas | The schemas used within the application |
| config.py | Main application configuration |
| main.py | Application |
### Root directory
The root directory contains the typical files one would expect to see in a Python project. The below files are worth describing:
| Item | Description |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| package.json | Not typical in a Python programme; used due to the nature of the monorepo. Running `pnpm run dev` at the project root will execute the `dev` script in this `package.json` |
| vercel.json | The configuration for deploying the FastAPI aspect of the application to Vercel. |
| \*.csv | Simple seed data for the database, sourced from the [Harry Potter API](https://hp-api.onrender.com/) |
## Dependencies
### Python 3.9
Because the project is being deployed on Vercel, Python version `3.9` must be used as this is the latest supported version of Python. For more information, read the [official documentation](https://vercel.com/docs/functions/runtimes/python).
If deploying to somewhere other than Vercel, check which version of Python you may use and adjust the project according to your needs.
### Supabase
The project uses [Supabase](https://supabase.com/) as a database. Since Planetscale [removed their free Hobby tier](https://planetscale.com/blog/planetscale-forever),
Supabase has seemed like a good alternative to use. You do not have to use Supabase with the backend, but the project is written from the perspective of using it.
If you are using Supabase,
[`supabase-py-async`](https://pypi.org/project/supabase-py-async/) is already
included as a project dependency within the `pyproject.toml`. If you are not
using Supabase, this can be removed.
### Poetry
[Poetry](https://python-poetry.org/) is used to manage the virtual environment and project dependencies.
A `requirements.txt` has been generated to enable the installation of Python packages via the `pip install` command.
If you do not use Poetry, you can remove the `poetry.lock` and `pyproject.toml` files.
You will need a `requirements.txt` when deploying. Vercel also accepts a `Pipenv` file if you use Pipenv, otherwise, you'll need the `requirements.txt` for the `api` to build correctly
## Adding your own endpoints
Given the project structure, there are three areas that you must be aware of when adding your own endpoints with new models. The main areas are:
- Schemas
- CRUD
- API
### Example: Creation of Spells endpoints
#### Step 1: Create a schema
Add a new schema to the `schemas` directory.
```python src/schemas/spell.py
from typing import ClassVar, Sequence
from pydantic import BaseModel
class Spell(BaseModel):
id: str
name: str
description: str
table_name: ClassVar[str] = "spells"
class SpellCreate(BaseModel):
id: str
name: str
description: str
class SpellUpdate(BaseModel):
id: str
name: str
description: str
class SpellSearchResults(BaseModel):
results: Sequence[Spell]
```
The `table_name` value needs to be included in the base `Spell` class. This **must** be the same as the name of the table created in Supabase. It is used in the CRUD operations to identify the table to work with.
| Item | Description |
|--------------------|---------------------------------------------------------------------------------------------|
| `Spell` | The base class describing the columns that will be in the Supabase table |
| SpellCreate | The class for creating a new `Spell` |
| SpellUpdate | The class for updating an existing `Spell` |
| SpellSearchResults | Describes how data will be returned in the API response. It will be a `Sequence` of `Spell` |
To easily import the new `Spell` classes throughout our application, they need to be added to the `src/schemas/__init__.py` file.
```python src/schemas/__init__.py
from .user import User, UserCreate, UserSearchResults, UserUpdate
from .spell import Spell, SpellCreate, SpellSearchResults, SpellUpdate
```
This allows us to import from `src/schemas` like so:
```python
from src.schemas import Spell, SpellCreate, SpellSearchResults, SpellUpdate
```
#### Step 2: Setup CRUD operations
Specific CRUD operations can be created for each endpoint. However, generic CRUD operations in `src/crud/base.py` can also be used without modification.
```python src/crud/crud_spell.py
from fastapi import HTTPException
from supabase_py_async import AsyncClient
from src.crud.base import CRUDBase
from src.schemas import Spell, SpellCreate, SpellUpdate
class CRUDSpell(CRUDBase[Spell, SpellCreate, SpellUpdate]):
async def get(self, db: AsyncClient, *, id: str) -> Spell | None:
try:
return await super().get(db, id=id)
except Exception as e:
raise HTTPException(
status_code=404,
detail=f"{e.code}: Spell not found. {e.details}",
)
async def get_all(self, db: AsyncClient) -> list[Spell]:
try:
return await super().get_all(db)
except Exception as e:
raise HTTPException(
status_code=404,
detail=f"An error occurred while fetching spells. {e}",
)
async def search_all(
self, db: AsyncClient, *, field: str, search_value: str, max_results: int
) -> list[Spell]:
try:
return await super().search_all(
db, field=field, search_value=search_value, max_results=max_results
)
except Exception as e:
raise HTTPException(
status_code=404,
detail=f"An error occurred while searching for spells. {e}",
)
spell = CRUDSpell(Spell)
```
The `CRUDSpell` class inherits from the `CRUDBase` class located in `src/crud/base.py`. The `Spell`, `SpellCreate` and `SpellUpdate` classes are passed to the `CRUDBase` class to specify the types of data that will be used in the CRUD operations.
The operations that will be used in the API endpoints are functions of the `CRUDSpell` class.
Finally, `spell` is an instance of `CRUDSpell`. We import this instance to use in the API endpoints like so: `spell.get_all(db)` or `spell.get(db, id=id)`.
**This part of the project is intended to be read-only**, however, the `SpellCreate` and `SpellUpdate` classes are created in the schema regardless as they are required by the `CRUDBase` model's function arguments. `CRUDBase` can be refactored to have optional parameters, or a read-only version of the `CRUDBase` class can be created. This is beyond the scope of this project.
Similar to setting up the schemas, the `CRUDSpell` class needs to be added to the `src/crud/__init__.py` file.
```python src/crud/__init__.py
from .crud_user import user
from .crud_spell import spell
```
#### Step 3: Create the API endpoints
Create the endpoints in the `src/api/api_v1/endpoints/spells.py` file.
```python src/api/api_v1/endpoints/spells.py
from typing import Literal, Optional, Union
from fastapi import APIRouter, HTTPException
from src.api.deps import SessionDep
from src.crud import spell
from src.schemas import Spell, SpellSearchResults
router = APIRouter()
@router.get("/get/", status_code=200, response_model=Spell)
async def get_spell(session: SessionDep, spell_id: str) -> Spell:
"""Returns a spell from a spell_id.
**Returns:**
- spell: spell object.
"""
return await spell.get(session, id=spell_id)
@router.get("/get-all/", status_code=200, response_model=list[Spell])
async def get_all_spells(session: SessionDep) -> list[Spell]:
"""Returns a list of all spells.
**Returns:**
- list[spell]: List of all spells.
"""
return await spell.get_all(session)
@router.get("/search/", status_code=200, response_model=SpellSearchResults)
async def search_spells(
session: SessionDep,
search_on: Literal["spells", "description"] = "spell",
keyword: Optional[Union[str, int]] = None,
max_results: Optional[int] = 10,
) -> SpellSearchResults:
"""
Search for spells based on a keyword and return the top `max_results` spells.
**Args:**
- keyword (str, optional): The keyword to search for. Defaults to None.
- max_results (int, optional): The maximum number of search results to return. Defaults to 10.
- search_on (str, optional): The field to perform the search on. Defaults to "email".
**Returns:**
- SpellSearchResults: Object containing a list of the top `max_results` spells that match the keyword.
"""
if not keyword:
results = await spell.get_all(session)
return SpellSearchResults(results=results)
results = await spell.search_all(
session, field=search_on, search_value=keyword, max_results=max_results
)
if not results:
raise HTTPException(
status_code=404, detail="No spells found matching the search criteria"
)
return SpellSearchResults(results=results)
```
Here we are calling `spell` object which we setup in step 2.
The `SessionDep` (located in `src/api/deps.py`) dependency is used to access the database.
The `response_model` parameter is used to specify the type of data that will be returned from the endpoint. This is used to generate TypeScript types for the frontend.
To include the new endpoints in the API, it must be added to the API router, located in `src/api/api_v1/api.py`.
```python src/api/api_v1/api.py
from fastapi import APIRouter
from src.api.api_v1.endpoints import users, spells
api_router = APIRouter()
api_router.include_router(users.router, prefix="/users", tags=["users"], responses={404: {"description": "Not found"}})
api_router.include_router(spells.router, prefix="/spells", tags=["spells"], responses={404: {"description": "Not found"}})
```
#### Step 4: Create the table in Supabase
Create a new table in your Supabase dashboard. It is **imperative** that the table name matches the `table_name` value in the `Spell` class in `src/schemas/spell.py`.
Columns should be added to match the `Spell` class. For example, we have the following `Spell` class:
```python
class Spell(BaseModel):
id: str
name: str
description: str
table_name: ClassVar[str] = "spells"
```
In this example, the table should be named `spells` (table names are case-sensitive) with the columns `id`, `name`, and `description`. \
\
For data types, `id` can be automatically assigned - in this example, it is set to a `uuid`. The `name` and `description` fields are strings, therefore their column's type is set to `text`. The `id` column should be the primary key.
You do not need to add the `table_name` column as this is used in the FastAPI code to identify the table to work with.
The data can be seeded using the Supabase dashboard by uploading the `harry-potter-db-seed-spells.csv` file. For a more detailed explanation, please see the [official documentation](https://supabase.com/docs/guides/database/import-data#option-1-csv-import-via-supabase-dashboard)
The table security should be configured to allow the FastAPI application to access the data. By default, Supabase will have [RLS (Row Level Security)](https://supabase.com/docs/guides/auth/row-level-security) enabled.\
\
If left un-configured, the database will return an empty array. As this is a simple read-only project, I am turning `RLS` off. However, for true CRUD operations, it should be configured to use authentication which is beyond the scope of this project.
\
To disable `RLS`, in the table settings, select `configure RLS` and then `disable RLS`.\
Once the table has been created, you must ensure that the `DB_URL` and `DB_API_KEY` parameters are populated in your `.env` file located in the root of the `API` directory.\
\
These values come from the Supabase dashboard by going to `settings` and then `API`. Copy the Project URL (`DB_URL`) and the Project API Key (`DB_API_KEY`).
`DB_USERNAME` and `DB_PASSWORD` should also included in the `.env` as they are configured in the `src/config.py`. If you do not include these you will receive an error from Pydantic.\
\
Their inclusion is a pre-cursor to authentication, but they are not actually used in this project scaffold.
#### Step 5: Test your new endpoints
You can now test your new endpoints using the FastAPI Swagger UI or by making requests to the API.
================================================
FILE: apps/docs/documentation/configuration/nextjs.mdx
================================================
---
title: Next.js config
"og:title": "Next.js config and setup"
"description": "Next.js config and setup"
---
## Introduction
The frontend uses the latest version of Next.js and TypeScript; it is configured using the latest [app router](https://nextjs.org/docs/app).
You can run the **frontend only** by running the `pnpm run dev` command from a terminal within the `web` directory. Alternatively, you can run the entire application by running `pnpm run dev` from the **root directory**.
## App structure
The app root directory is structured as follows:
```
web
├── app
├── components
├── lib
├── public
├── .env
├── .env.example
├── .eslintrc.js
├── components.json
├── next.config.js
├── package.json
├── postcss.config.js
├── README.md
├── tailwind.config.js
├── tsconfig.json
└── yarn.lock
```
#### App
| Item | Description |
| ----------- | ---------------------------------------------------------------------------------------------------- |
| globals.css | Tailwind global config. Uses a generated theme from [ShadCN UI themes](https://ui.shadcn.com/themes) |
| layout.tsx | App layout |
| page.tsx | Landing page |
#### Components
| Item | Description |
| ------- | ----------------------------------------------------------------------------------------------------------------------------- |
| layouts | The dashboard layout is stored which wraps the application `{children}` in `root/app/layout.tsx` |
| theme | The `ThemeProvider` component(s) that wrap the application. |
| ui | Where `ShadCN` components are stored upon being generated. Configured by the `components.json` located in the `frontend root` |
| \*.tsx | Components used within the application |
#### Lib
| Item | Description |
| ----------- | ---------------------------------------------------------------------------------------------------------------- |
| api | The output generated by the `openapi` npm package. Configured in the `package.json` task named `generate-client` |
| config | Stores site config. Currently contains the setup for sidebar navigation |
| twConfig.ts | Tailwind colour config exported to an accessible Object. Used for assigning theme-aware colours in charts |
| utils.ts | ShadCN utils |
## TypeScript from FastAPI
As FastAPI is based on the OpenAPI specification, you get automatic compatibility with many tools, including the automatic API docs (provided by Swagger UI).
One particular advantage that is not necessarily obvious is that you can generate clients (sometimes called SDKs ) for your API, for many different programming languages.
For a more detailed explanation, see the [official FastAPI documentation](https://fastapi.tiangolo.com/advanced/generate-clients/#generate-a-typescript-client-with-the-preprocessed-openapi)
## Why generate TypeScript?
Generating a TypeScript client for your FastAPI backend is a great way to ensure that your frontend and backend are always in sync. It is also a way to provide type hinting while writing your frontend code without needing a permanent reference to the API, or re-creating the schema using something like Zod.
### How to generate TypeScript
There are two generate-client tasks configured in the `package.json`:
```JSON
"scripts": {
...
"generate-client": "openapi --input https://next-fast-turbo.vercel.app/openapi.json --output ./lib/api/client --client axios --useOptions --useUnionTypes",
"generate-client:dev": "openapi --input http://127.0.0.0:8000/openapi.json --output ./lib/api/client --client axios --useOptions --useUnionTypes"
...
},
```
The `generate-client` task is set to run off the production OpenAPI schema.\
\
The `generate-client:dev` task is set to use the localhost OpenAPI schema. This is useful for development, as it will use the latest schema from the backend.
Ensure your production API URL is configured, or that your local API URL is correct, and then run the relevant task.
A key file to be aware of is the `OpenAPI.ts` which is generated in the `lib/api/client/core` directory. This file has the main configuration for the API connection as below:
```tsx lib/api/client/core/OpenAPI.ts
export const OpenAPI: OpenAPIConfig = {
BASE: "http://127.0.0.0:8000",
VERSION: "0.1.0",
WITH_CREDENTIALS: false,
CREDENTIALS: "include",
TOKEN: undefined,
USERNAME: undefined,
PASSWORD: undefined,
HEADERS: undefined,
ENCODE_PATH: undefined,
};
```
The problem with this is that we would want to differentiate between which API is being used. When the TypeScript is generated, the given OpenAPI URL is used as the base URL for the API.
This is not ideal for production, as you would want to use the production API URL, and vice versa in development.
You can override this by adding the following to your root `layout.tsx` file:
```tsx layout.tsx
import { OpenAPI } from "@/lib/api/client";
if (process.env.NODE_ENV === "production") {
OpenAPI.BASE = "https://next-fast-turbo.vercel.app"
}
```
## Using the generated API
Once you have generated your TypeScript interface to your API, you can use it in your frontend code.
In its simplest form, you can import the generated API and use it as below:
```tsx
import { UsersService } from "@/lib/api/client";
const response = await UsersService.usersSearchUsers({
keyword: "keyword",
searchOn: "searchOn",
maxResults: "maxResults",
});
```
You can see this code being used in the `components/search-users.tsx` file, as part of the form's onSubmit function:
```tsx
const onSubmit = async (data: z.infer) => {
try {
const maxResults = data.searchResults ? parseInt(data.searchResults) : 10;
const response = await UsersService.usersSearchUsers({
keyword: data.keyword,
searchOn: data.searchOn,
maxResults: maxResults,
});
setSearchResults(response);
setError(null);
} catch (error) {
setSearchResults({ results: [] });
setError(error);
}
};
```
This code also imports the `UserSearchResults` type which is used to set the state of the search results:
```tsx
import { UsersService, UserSearchResults } from "@/lib/api/client";
const [searchResults, setSearchResults] = React.useState({
results: [],
});
```
## Important considerations
- If you make changes to your API, you will need to re-generate the TypeScript interface.
- Re-generating this interface will overwrite the existing files. If you want to modify anything (e.g. `api/client/core/OpenAPI.ts`) and have it persist, do this outside of the generated files. You can see this in action in the `root/app/layout.tsx` file.
================================================
FILE: apps/docs/documentation/configuration/turbo.mdx
================================================
---
title: Turbo config
"og:title": "Configuring Turbo for FastAPI, Next.js and Turborepo"
description: Configuring Turbo for FastAPI, Next.js and Turborepo.
---
## Introduction
This project was first created using the `create-turbo` npm package:
```bash npm
npx create-turbo@latest
```
```bash yarn
yarn dlx create-turbo@latest
```
```bash pnpm
pnpm dlx create-turbo@latest
```
It is recommended that you read through the [official documentation](https://turbo.build/repo/docs/getting-started/create-new) to understand the breakdown of the monorepo.
## Changes to the official Turbo starter
The official Turbo starter is a great starting point for a monorepo, but it has some configurations I did not need. As I will not be sharing code between the backend and frontend (nor the docs), I have **removed** the `packages/ui` directory.
If you want to **add a new package** to the project, please reference the [official documentation](https://turbo.build/repo/docs/handbook/sharing-code/internal-packages).
For quick reference:
1. Create a new folder in `packages/`
2. Add a `package.json`, with `name` and `types` pointing at `src/index.ts[x]`
3. Add `src/index.ts[x]`, with at least one named export
4. Install your packages from `root`
## Turbo.json
The currently configured `turbo.json` does not have many changes from the official starter. The only change is the addition of the `globalEnv` key.
```json
{
"globalEnv": [
"NODE_ENV"
],
}
```
Without adding these environment variables to the `globalEnv`, you will receive an eslint error when referencing variables in your `.env`, however, your code will still work.
There are different ways that people solve this. While it's possible to use\
`"globalDependencies": ["**/.env"]`, that did not work in this project.\
================================================
FILE: apps/docs/documentation/deployment/deployment.mdx
================================================
---
title: Deploying the monorepo
description: Deploying your monorepo to Vercel/Mintlify
"og:title": Deploying your monorepo to Vercel/Mintlify
---
## Introduction
Deploying your monorepo to Vercel is relatively straightforward, but there are a handful of things to be aware of.
The frontend deployment is relatively straightforward, but the backend deployment can be a little more complex and need a bit more attention.
For a more detailed guide on deploying a monorepo to Vercel, see the [official documentation](https://vercel.com/docs/monorepos/turborepo).
## Prerequisites
Before continuing, ensure you have:
- A [Vercel](https://vercel.com/) account. It is typically easiest to sign up with your GitHub account, as we'll also be deploying directly from the GitHub repository.
- Published your repo to GitHub. If you haven't done this yet, you can follow the instructions [here](https://docs.github.com/en/get-started/quickstart/create-a-repo).
- Optional. If you're planning to deploy your documentation site to Mintlify, you'll need to have a [Mintlify](https://mintlify.com/) account.
## Frontend Deployment
Go to your [Vercel dashboard](https://vercel.com/dashboard) and click the `Add New...` button, and select `Project`.
Select the `Import Git Repository` option and select your repository from the list of repositories.
Vercel will automatically detect that you have a monorepo, and should have correctly populated all the required fields.
The project root directory should be automatically detected, but if it isn't, you can manually set it to the folder where your frontend is stored. In this project, that is `apps/web`.
Click the `Deploy` button to deploy your project.
We don't want to continuously rebuild our frontend every time we push changes to the backend or documentation. To prevent this, we can add an ignored build step.\
\
From the newly deployed frontend dashboard, navigate to `Settings`, then to `Git`. Scroll down to the `Ignored Build Step` section and set the behaviour to
**Only build Turborepo app if there are changes**.
For more information, see the [official documentation](https://vercel.com/docs/projects/overview#ignored-build-step).
## Backend deployment
Go to your [Vercel dashboard](https://vercel.com/dashboard) and click the `Add New...` button, and select `Project`.
Select the `Import Git Repository` option and select your repository from the list of repositories.
Vercel will automatically detect that you have a monorepo, but for the backend we need to change the default configuration.
- Configure your project name
- Change the `Framework Preset` to `Other` (there is currently no Python option)
- Change the `Root Directory` to the folder where your backend is stored. In this project, that is `apps/api`
- Add your Environment Variables
Click the `Deploy` button to deploy your project. Once built, the API should be running at the URL provided.
We don't want to continuously rebuild our frontend every time we push changes to the backend or documentation. To prevent this, we can add an ignored build step.\
\
From the newly deployed frontend dashboard, navigate to `Settings`, then to `Git`. Scroll down to the `Ignored Build Step` section and set the behaviour to
**Only build Turborepo app if there are changes**.
For more information, see the [official documentation](https://vercel.com/docs/projects/overview#ignored-build-step).
## Documentation deployment
For a more detailed explanation, visit the [offical documentation](https://mintlify.com/docs/quickstart)
Connecting to an existing repository with Mintlify is a little bit tricky, as their walkthrough currently seems to only support creating a new repository. However, it is possible to connect an existing repository by following the steps below.
Sign in to [Mintlify](https://mintlify.com/). You will further be prompted to **Sign in with GitHub**. Follow the onscreen instructions.
Configure your deployment to be pointed to your `docs` directory. Ensure **set up as a monorepo** is selected.
From the Mintlify dashboard, click **Things to Do** and then click **Enable automatic updates**.
================================================
FILE: apps/docs/documentation/introduction.mdx
================================================
---
title: Introduction
"og:title": "Getting started with Next-Fast-Turbo"
description: A starter project for FastAPI, Next.js and Turborepo.
---
## What is Next-Fast-Turbo?
Next-Fast-Turbo is designed as a personal starter kit for Next.js and FastAPI projects. It is a monorepo that includes a Next.js frontend and a FastAPI backend. The project is designed to be deployed to Vercel, but can be deployed to any platform that supports monorepos.
This documentation is not written to be a tutorial, but instead to be a reference for the project. It is designed to be a living document that can be updated as the project evolves.
## Features
**Frontend**\
The Next.js application comes with a fully built frontend that includes:
- A responsive layout
- A dashboard/sidebar design
- Pre-configured connection to the backend API
- Autogenerated TypeScript types based off the FastAPI OpenAPI schema
- A variety of design components, mostly from ShadCN UI (including chart examples)
**Backend**\
The FastAPI application comes with a fully built backend that includes:
- Example endpoints
- Pre-configured schema/crud operations
- Easily extensible to add more endpoints
**Documentation**\
Built using Mintlify, a fully responsive and configured documentation site that features:
- A fully built documentation site
- A variety of Mintlify components
- A fully configured mint.json
## Tech stack
Next-Fast-Turbo is fully open-source built using the following technologies:
**Frontend**
- [Next.js](https://nextjs.org/) - Framework for building React applications
- [Tailwind CSS](https://tailwindcss.com/) - CSS framework
- [ShadCN UI](https://ui.shadcn.com/) - UI kit
**Backend**
- [FastAPI](https://fastapi.tiangolo.com/) - Python backend API
**Documentation**
- [Mintlify](https://mintlify.io/) - Documentation
**Global**
- [Vercel](https://vercel.com/) - hosting
- [Turbo](https://turbo.build/repo) - monorepo
## Getting started
Install the application locally
Deploy the monorepo to Vercel
================================================
FILE: apps/docs/documentation/local-development.mdx
================================================
---
title: "Local Development"
"og:title": "How to setup local development"
description: "A guide on how to run the codebase locally."
---
## Introduction
Next-Fast-Turbo 's codebase is set up in a monorepo (via [Turborepo](https://turbo.build/repo)) and is fully open-source.
Here's the monorepo structure:
```
apps
├── api
├── docs
├── web
packages
├── eslint-config
├── typescript-config
```
The `apps` directory contains the code for:
- `web`: The frontend of the Next-Fast-Turbo's application
- `api`: Next-Fast-Turbo's FastAPI backend - written in Python
- `docs`: Next-Fast-Turbo's documentation site
The `packages` directory contains the code for:
- `eslint-config`: ESLint configurations for Next-Fast-Turbo's codebase. Boilerplate code included as part of the [create Turbo](https://turbo.build/repo/docs/getting-started/create-new) command
- `typescript-config`: TypeScript configurations for Next-Fast-Turbo's codebase. Boilerplate code included as part of the [create Turbo](https://turbo.build/repo/docs/getting-started/create-new) command
## Running Next-Fast-Turbo
### Step 1: Local setup
Clone the [Next-Fast-Turbo repo](https://github.com/cording12/next-fast-turbo.git).
```bash
git clone https://github.com/cording12/next-fast-turbo.git app-name
```
Change to the root directory of the cloned repository and install the dependencies using the following command:
```bash
cd app-name
pnpm install
```
It is recommended to use the pre-configured Workspace stored in the `.vscode` folder at the project root.
Navigate to `app-name/.vscode/` and double click `next-fast-turbo.code-workspace` to open in VS Code, or, in VS Code navigate to **File** and then **Open Workspace from File**.
You can rename this to match your project name. The extension, `code-workspace`, must stay the same, but it can be changed to `app-name.code-workspace`
### Step 2: Python setup
In a monorepo, VS Code sometimes uses the wrong Python interpreter, leading to **module not found** errors. You can open the `api` folder in its own VS Code window, but using
the pre-configured Workspace is recommended.
While working on the Python backend, ensure that your terminal is activated in the correct folder. From the root, run the following command to change to the `api` directory:
```bash
cd apps/api
```
Create a virtual environment in the `api` directory:
```bash Poetry
poetry install
```
```bash Pip
python -m venv .venv
```
If you're using Poetry, you could receive an error noting incorrect format of the `poetry.lock` file. This is a version mismatch between the version installed and the version used to generate the lock file. You can fix this by deleting the `poetry.lock` file
and running `poetry install` again.
Run the following command to install the Python dependencies:
```bash
pip install -r requirements.txt
```
Create a `.env` file in the `api` directory and add the following environment variables:
```env
DB_URL=supabase_url
DB_API_KEY=supabase_api_key
DB_EMAIl=email_address
DB_PASSWORD=password
```
These can be placeholder values for now, but you'll need to replace them with your actual Supabase credentials (covered in step 3).
### Step 3: Creating tables in Supabase
Next-Fast-Turbo uses [Supabase](https://supabase.com/) as the database for the backend. You'll need to create a new project in Supabase and then create the required tables. To get this example running, you need to only create two tables in Supabase.
Visit [Supabase](https://supabase.com/) and register an account. Once you're logged in, create a new project and give it a name.
While your project is building, copy the `Project API Key` and `URL` values and add these to the `.env` file in the `api` directory, as described in step 3 of the [Python setup](#step-2-python-setup).
The tables are seeded with the two `.csv` files located in the `api` root, but the tables must be created before seeding.
From the dashboard, visit the `Table Editor` and click the `New table` button.
Create the `users` and `spells` tables with columns that match their respective CSV columns. Below is how they are both configured:
RLS is set to disabled on these tables. Authentication with Supabase was not in the scope for this project, but you will want to configure this yourself for anything more than this simple example.
You can read more about [RLS](https://supabase.com/docs/guides/auth/row-level-security) in the Supabase documentation.
Once the tables are created, you can seed them with the data from the `.csv` files. From the `Table Editor`, click the `Insert` button and select the relevant `.csv` file to upload.
### Step 4: Configure Turbo remote caching (optional)
Turborepo can use a technique known as [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.
By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel.
From the project root, run the command:
```bash
npx turbo login
```
This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview).
Link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo:
```bash
npx turbo link
```
### Step 5: Running everything
To make the most of Turbo's monorepo structure, you can run the frontend, backend and documentation site simultaneously. From the root, run the following command:
```bash root
pnpm run dev
```
You can still run each separately by running the task directly from the relevant `package.json` or by running the `pnpm run dev` command from a terminal activated in the desired target location
## Working with a monorepo in VS Code
For a better development experience, you can use VS Code Workspaces for the monorepo. This will allow you to run tasks and debug the codebase from a single window, while keeping things more organised.
Furthermore, VS Code doesn't handle Python virtual environments particularly well when working within a monorepo. Running the `dev` command from the project root can make VS Code use your global Python installation,
instead of the `.venv` created in the `api` root. By using a Workspace, this alleviates the problem.
For a more detailed guide on setting up a monorepo in VS Code, check out the [official Multi-root Workspaces](https://code.visualstudio.com/docs/editor/multi-root-workspaces) documentation
### Step 1: Open the monorepo
In the `/.vscode/` directory, you'll find a `next-fast-turbo.code-workspace` file. Open this file in VS Code to open the monorepo Workspace.
### Step 2: Running tasks
VS Code will try to autodetect tasks from gulp, grunt, npm, and TypeScript project files across all folders in a workspace as well as search for tasks defined in tasks.json files. The location of tasks is indicated by a folder name suffix
From the above example, you can see there are several configured tasks with the relevant folder name after the task name.
### Step 3: Debugging
With multi-root workspaces, VS Code searches across all folders for `launch.json` debug configuration files and displays them with the folder name as a suffix.
Additionally VS Code will also display launch configurations defined in the workspace configuration file.
You can still create [launch configurations](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations) for each individual package in the monorepo and they will populate in the dropdown list automatically.
#### Workspace launch configurations
If you want to create a Workspace level configuration with [compound launch](https://code.visualstudio.com/docs/editor/debugging#_compound-launch-configurations), you can edit the `next-fast-turbo.code-workspace` file and add the configurations you wish to launch.
You can also edit the Workspace configuration file via the Command Palette\
(Windows: Ctrl + Shift + P) and searching for `open workspace config`
A compound launch configuration can reference the individual launch configurations by name as long as the names are unique within the workspace, for example:
```json
{
"launch": {
"version": "0.2.0",
"configurations": [],
"compounds": [
{
"name": "Launch Frontend and Backend",
"configurations": ["Next.js: Chrome", "Python: FastAPI"]
}
]
}
}
```
For a more detailed explanation, check out the [official documentation](https://code.visualstudio.com/docs/editor/multi-root-workspaces#_workspace-launch-configurations)
### Optional: Extensions
Helps VS Code identify the correct Python virtual environment when installed in the working directory. This is especially useful when working with Python in a monorepo, as it can be difficult for VS Code to manage multiple virtual environments.
[Python Envy](https://marketplace.visualstudio.com/items?itemName=teticio.python-envy)
Terminal management in a monorepo can become cumbersome. This extension automatically creates a terminal in each of your monorepo's directories and names them accordingly. This will allow you to run commands and tasks from a terminal that's already set up in the correct directory.
[Workspace Terminals](https://marketplace.visualstudio.com/items?itemName=joshx.workspace-terminals)
## Next Steps
Configuring Turbo for your monorepo
Configuring FastAPI
Configuring Next.js
Configuring Mintlify for documentation
================================================
FILE: apps/docs/mint.json
================================================
{
"$schema": "https://mintlify.com/schema.json",
"name": "Next-Fast-Turbo Docs",
"favicon": "/logos/logo.svg",
"logo": {
"light": "/logos/logo.svg",
"dark": "/logos/logo-light.svg"
},
"colors": {
"primary": "#7c3aed",
"light": "#af87ff",
"dark": "#1e293b",
"background": {
"dark": "#030712",
"light": "#ffffff"
}
},
"modeToggle": {
"default": "dark"
},
"topbarCtaButton": {
"name": "Dashboard",
"url": "https://next-fast-turbo-web.vercel.app/"
},
"tabs": [
{
"name": "API Reference",
"url": "api"
}
],
"anchors": [
{
"name": "Documentation",
"icon": "book-open-cover",
"url": "documentation"
},
{
"name": "API Reference",
"icon": "rectangle-terminal",
"url": "api"
}
],
"navigation": [
{
"group": "Getting Started",
"pages": [
"documentation/introduction",
"documentation/local-development"
]
},
{
"group": "Configuration",
"pages": [
"documentation/configuration/turbo",
"documentation/configuration/fastapi",
"documentation/configuration/nextjs",
"documentation/configuration/docs"
]
},
{
"group": "Deployment",
"pages": [
"documentation/deployment/deployment"
]
},
{
"group": "Users",
"pages": [
"api/users/get-user",
"api/users/get-all-users",
"api/users/search-users",
"api/users/create-user"
]
},
{
"group": "Spells",
"pages": [
"api/spells/get-spell",
"api/spells/get-all-spells",
"api/spells/search-spells"
]
}
],
"api": {
"maintainOrder": true,
"baseUrl": "https://next-fast-turbo-api.vercel.app"
},
"openapi": "https://next-fast-turbo-api.vercel.app/openapi.json",
"feedback": {
"thumbsRating": true
},
"footerSocials": {
"github": "https://github.com/cording12/next-fast-turbo",
"linkedin": "https://www.linkedin.com/in/jon-cording/"
}
}
================================================
FILE: apps/docs/openapi.json
================================================
{
"openapi": "3.1.0",
"info": {
"title": "FastAPI App",
"description": "A simple FastAPI app",
"version": "0.1.0"
},
"servers": [
{
"url": "https://next-fast-turbo-api.vercel.app"
}
],
"paths": {
"/api/v1/users/get/": {
"get": {
"tags": [
"users"
],
"summary": "Get User",
"description": "Returns a user from a user_id.\n\n**Returns:**\n- User: User object.",
"operationId": "users-get_user",
"parameters": [
{
"name": "user_id",
"in": "query",
"required": true,
"schema": {
"type": "string",
"title": "User Id"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
},
"404": {
"description": "Not found"
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/v1/users/get-all/": {
"get": {
"tags": [
"users"
],
"summary": "Get All Users",
"description": "Returns a list of all users.\n\n**Returns:**\n- list[User]: List of all users.",
"operationId": "users-get_all_users",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/User"
},
"type": "array",
"title": "Response Users-Get All Users"
}
}
}
},
"404": {
"description": "Not found"
}
}
}
},
"/api/v1/users/search/": {
"get": {
"tags": [
"users"
],
"summary": "Search Users",
"description": "Search for users based on a keyword and return the top `max_results` items.\n\n**Args:**\n- keyword (str, optional): The keyword to search for. Defaults to None.\n- max_results (int, optional): The maximum number of search results to return. Defaults to 10.\n- search_on (str, optional): The field to perform the search on. Defaults to \"email\".\n\n**Returns:**\n- UserSearchResults: Object containing a list of the top `max_results` items that match the keyword.",
"operationId": "users-search_users",
"parameters": [
{
"name": "search_on",
"in": "query",
"required": false,
"schema": {
"enum": [
"id",
"email",
"forename",
"surname"
],
"type": "string",
"default": "email",
"title": "Search On"
}
},
{
"name": "keyword",
"in": "query",
"required": false,
"schema": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Keyword"
}
},
{
"name": "max_results",
"in": "query",
"required": false,
"schema": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": 10,
"title": "Max Results"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UserSearchResults"
}
}
}
},
"404": {
"description": "Not found"
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/v1/users/create": {
"post": {
"tags": [
"users"
],
"summary": "Create User",
"description": "Craete a new user.\n\n**Args:**\n- user_in (UserCreate): JSON of the user to create. Forename, surname and email. Email must be unique.\n\n**Returns:**\n- User: User object",
"operationId": "users-create_user",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UserCreate"
}
}
},
"required": true
},
"responses": {
"201": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
}
}
}
},
"404": {
"description": "Not found"
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/v1/spells/get/": {
"get": {
"tags": [
"spells"
],
"summary": "Get Spell",
"description": "Returns a spell from a spell_id.\n\n**Returns:**\n- spell: spell object.",
"operationId": "spells-get_spell",
"parameters": [
{
"name": "spell_id",
"in": "query",
"required": true,
"schema": {
"type": "string",
"title": "Spell Id"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Spell"
}
}
}
},
"404": {
"description": "Not found"
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/v1/spells/get-all/": {
"get": {
"tags": [
"spells"
],
"summary": "Get All Spells",
"description": "Returns a list of all spells.\n\n**Returns:**\n- list[spell]: List of all spells.",
"operationId": "spells-get_all_spells",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/Spell"
},
"type": "array",
"title": "Response Spells-Get All Spells"
}
}
}
},
"404": {
"description": "Not found"
}
}
}
},
"/api/v1/spells/search/": {
"get": {
"tags": [
"spells"
],
"summary": "Search Spells",
"description": "Search for spells based on a keyword and return the top `max_results` items.\n\n**Args:**\n- keyword (str, optional): The keyword to search for. Defaults to None.\n- max_results (int, optional): The maximum number of search results to return. Defaults to 10.\n- search_on (str, optional): The field to perform the search on. Defaults to \"email\".\n\n**Returns:**\n- spellSearchResults: Object containing a list of the top `max_results` items that match the keyword.",
"operationId": "spells-search_spells",
"parameters": [
{
"name": "search_on",
"in": "query",
"required": false,
"schema": {
"enum": [
"id",
"spells",
"description"
],
"type": "string",
"default": "spells",
"title": "Search On"
}
},
{
"name": "keyword",
"in": "query",
"required": false,
"schema": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Keyword"
}
},
{
"name": "max_results",
"in": "query",
"required": false,
"schema": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": 10,
"title": "Max Results"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SpellSearchResults"
}
}
}
},
"404": {
"description": "Not found"
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"HTTPValidationError": {
"properties": {
"detail": {
"items": {
"$ref": "#/components/schemas/ValidationError"
},
"type": "array",
"title": "Detail"
}
},
"type": "object",
"title": "HTTPValidationError"
},
"Spell": {
"properties": {
"id": {
"type": "string",
"title": "Id"
},
"name": {
"type": "string",
"title": "Name"
},
"description": {
"type": "string",
"title": "Description"
}
},
"type": "object",
"required": [
"id",
"name",
"description"
],
"title": "Spell"
},
"SpellSearchResults": {
"properties": {
"results": {
"items": {
"$ref": "#/components/schemas/Spell"
},
"type": "array",
"title": "Results"
}
},
"type": "object",
"required": [
"results"
],
"title": "SpellSearchResults"
},
"User": {
"properties": {
"id": {
"type": "string",
"title": "Id"
},
"forename": {
"type": "string",
"title": "Forename"
},
"surname": {
"type": "string",
"title": "Surname"
},
"email": {
"type": "string",
"format": "email",
"title": "Email"
}
},
"type": "object",
"required": [
"id",
"forename",
"surname",
"email"
],
"title": "User"
},
"UserCreate": {
"properties": {
"forename": {
"type": "string",
"title": "Forename"
},
"surname": {
"type": "string",
"title": "Surname"
},
"email": {
"type": "string",
"format": "email",
"title": "Email"
}
},
"type": "object",
"required": [
"forename",
"surname",
"email"
],
"title": "UserCreate"
},
"UserSearchResults": {
"properties": {
"results": {
"items": {
"$ref": "#/components/schemas/User"
},
"type": "array",
"title": "Results"
}
},
"type": "object",
"required": [
"results"
],
"title": "UserSearchResults"
},
"ValidationError": {
"properties": {
"loc": {
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"type": "array",
"title": "Location"
},
"msg": {
"type": "string",
"title": "Message"
},
"type": {
"type": "string",
"title": "Error Type"
}
},
"type": "object",
"required": [
"loc",
"msg",
"type"
],
"title": "ValidationError"
}
}
}
}
================================================
FILE: apps/docs/package.json
================================================
{
"name": "docs",
"version": "0.1.0",
"scripts": {
"dev": "mintlify dev --port 3001",
"generate-api": "npx @mintlify/scraping@latest openapi-file https://next-fast-turbo-api.vercel.app/openapi.json --outDir ./api/",
"generate-api:dev": "npx @mintlify/scraping@latest openapi-file https://127.0.0.1:8000/openapi.json --outDir ./api/"
},
"dependencies": {
"@mintlify/scraping": "^3.0.88",
"mintlify": "^4.0.127"
}
}
================================================
FILE: apps/web/.eslintrc.js
================================================
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ["@repo/eslint-config/next.js"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
};
================================================
FILE: apps/web/.vscode/launch.json
================================================
{
"version": "0.2.0",
"configurations": [
{
"name": "Next.js: Chrome",
"type": "node-terminal",
"request": "launch",
"command": "pnpm run dev",
"serverReadyAction": {
"pattern": "- Local:.+(https?://.+)",
"uriFormat": "%s",
"action": "debugWithChrome",
"webRoot": "${workspaceFolder}"
}
}
]
}
================================================
FILE: apps/web/app/globals.css
================================================
@tailwind base;
@tailwind components;
@tailwind utilities;
@import "../components/theme/theme.css";
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
================================================
FILE: apps/web/app/layout.tsx
================================================
import "./globals.css";
import type { Metadata } from "next";
import { Inter as FontSans } from "next/font/google";
import { DashboardLayout } from "@/components/layouts/dashboard";
import { cn } from "@/lib/utils";
import { ThemeProvider } from "@/components/theme/theme-provider";
import { OpenAPI } from "@/lib/api/client";
import { TailwindIndicator } from "@/components/tailwind-indicator";
export const fontSans = FontSans({
subsets: ["latin"],
variable: "--font-sans",
});
if (process.env.NODE_ENV === "production") {
OpenAPI.BASE = "https://next-fast-turbo.vercel.app";
}
console.log("Using OpenAPI.base", OpenAPI.BASE);
export const metadata: Metadata = {
title: "Next-Fast-Turbo",
description: "A Next.js, FastAPI and Turbo project scaffol",
icons: {
icon: ["/favicon.png"],
},
};
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}): JSX.Element {
return (
{children}
);
}
================================================
FILE: apps/web/app/page.tsx
================================================
import { CardsStats } from "./placeholder-stats";
import SearchUsers from "@/components/search-users";
export default async function Page() {
return (
);
}
================================================
FILE: apps/web/app/placeholder-stats.tsx
================================================
// Example cards from ShadCN: https://github.com/shadcn-ui/ui/tree/0fae3fd93ae749aca708bdfbbbeddc5d576bfb2e/apps/www/registry/default/example/cards
import { FlexWrapper } from "@/components/flex-wrapper";
import { DemoRevenue } from "@/components/demo-revenue";
import { DemoSubscriptions } from "@/components/demo-subscriptions";
import { DemoExercise } from "@/components/demo-exercise";
import { DemoGoal } from "@/components/demo-goal";
export function CardsStats() {
return (
);
}
================================================
FILE: apps/web/app/settings/page.tsx
================================================
export default function Page() {
return
Settings page
;
}
================================================
FILE: apps/web/components/demo-exercise.tsx
================================================
"use client";
// Example data from ShadCN: https://github.com/shadcn-ui/ui/blob/0fae3fd93ae749aca708bdfbbbeddc5d576bfb2e/apps/www/registry/default/example/cards/stats.tsx#L61
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Line, LineChart, ResponsiveContainer, Tooltip } from "recharts";
import { twColourConfig } from "@/lib/twConfig";
const timeSeriesData = [
{
average: 400,
today: 240,
},
{
average: 300,
today: 139,
},
{
average: 200,
today: 980,
},
{
average: 278,
today: 390,
},
{
average: 189,
today: 480,
},
{
average: 239,
today: 380,
},
{
average: 349,
today: 430,
},
];
export function DemoExercise() {
return (
Exercise Minutes
Your exercise minutes are ahead of where you normally are.
{/*
*/}
{
if (active && payload && payload.length) {
return (