Skip to content

Commit 202045e

Browse files
authored
Merge pull request #31 from Sheldenburg/chore/update-docs
Chore/update docs
2 parents 9259482 + 477c1e8 commit 202045e

17 files changed

+117
-2014
lines changed

.copier/.copier-answers.yml.jinja

-1
This file was deleted.

.copier/update_dotenv.py

-26
This file was deleted.

README-original.md

-238
This file was deleted.

README.md

+34-48
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,25 @@
1-
# Nextjs FastAPI Template
2-
3-
<!-- <a href="https://github.com/tiangolo/full-stack-fastapi-template/actions?query=workflow%3ATest" target="_blank"><img src="https://github.com/tiangolo/full-stack-fastapi-template/workflows/Test/badge.svg" alt="Test"></a>
4-
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/tiangolo/full-stack-fastapi-template" target="_blank"><img src="https://coverage-badge.samuelcolvin.workers.dev/tiangolo/full-stack-fastapi-template.svg" alt="Coverage"></a> -->
1+
# AI Engineer Template Nextjs + FastAPI 🚀
52

63
![nextjs+fastapi_template](nextjs+fastapi-template.png)
74
![nextjs+fastapi_template_dark_mode](nextjs+fastapi-template-dark-mode.png)
85

9-
### Demo video
10-
https://drive.google.com/file/d/1QfZvzOnOeBvtoDMlBb4IxDx3DoC-GC4Q/view?usp=sharing
6+
### Demo website 🌐
117

12-
### Tech stack
13-
The backend code in this repository originated from the [FastAPI full stack template](https://github.com/fastapi/full-stack-fastapi-template) and includes AI components that make this AI engineer template unique.
8+
https://ai-engineer-template.vercel.app
149

15-
To fast-track the MVP building process, which is crucial for most AI products, we have chosen a simple tech stack. This allows people to focus more on iterating through product features rather than on DevOps from the outset.
10+
### Tech stack 🛠️
1611

17-
![architecture](architecture.png)
12+
The backend code in this repository originated from the [FastAPI full stack template](https://github.com/fastapi/full-stack-fastapi-template) plus additional AI components that make this AI engineer template unique.
1813

19-
### How to run in local
20-
1. Clone this repo
21-
```bash
22-
git clone https://github.com/Sheldenburg/nextjs-fastapi-template.git
23-
```
24-
2. Follow the original [README]('README-original.md') to docker compose and set up Postgres, reverse proxy and Fastapi server. You can leave the original React fronend running if you'd like. Or, you can just comment out the frontend bit in the docker compose file.
25-
3. Run nextjs app in local
26-
```bash
27-
cd frontend
28-
```
29-
```bash
30-
npm install
31-
```
32-
```bash
33-
npm run dev
34-
```
14+
To fast-track MVP building process, which is crucial for most AI products, we have chosen a simple tech stack. This allows people to focus more on iterating through product features rather than on DevOps from the outset.
3515

36-
Note: This is a fork from the original [Full Stack FastAPI Template](https://github.com/tiangolo/full-stack-fastapi-template "Full Stack FastAPI Template"). Instead of the original Reactjs frontend, we used Nextjs14 in this repository.
16+
![architecture](architecture.png)
3717

38-
Here are the reasons why we wanted to build with Nextjs (a full stack framework built on top of React) over React.
39-
- Dependencies reduction
40-
A barebone Reactjs application would require installation of dependency packages to achieve multi-page routing, managing API requests, caching etc. There are a number of solutions out there, e.g. in the original repo, @tanstack/react-router is used for routing, @tanstack/react-query + axios are used for managing API requests and caching.
41-
In a Nextjs application, all these functions are built in without the need for third-party libraries. Also, Nextjs14 (app router) uses file-based routing which means the routing is automatically done via the folder structure.
18+
### How to run in local 🏃‍♂️
4219

43-
- Server side rendering
44-
Data fetching and mutation in a Nextjs application is mostly dealt in server side while client side data fetching is also allowed. This offers advantages to get away with 'useEffect' and other cumbersome boiler plate codes in order to do data fetching at client side. Server side rendering also offers performance benefit.
20+
Refer to [development](development.md)
4521

46-
- Popularity
47-
Nextjs is getting more and more popular. There are good amount of frontend projects and Youtube tutorials based on Nextjs, which are beginner friendly.
22+
### Openapi Fetch
4823

4924
[![Openapi-fetch](https://openapi-ts.pages.dev/assets/openapi-fetch.svg "Openapi-fetch")](https://openapi-ts.pages.dev/openapi-fetch/ "Openapi-fetch")
5025

@@ -58,10 +33,20 @@ import createClient from "openapi-fetch";
5833
import type { paths } from "./v1";
5934
import { cookies } from "next/headers";
6035

61-
const client = createClient<paths>({ baseUrl: process.env.API_BASE_URL, headers: { Authorization: `Bearer ${cookies().get("access_token")?.value}` } });
36+
const client =
37+
createClient <
38+
paths >
39+
{
40+
baseUrl: process.env.API_BASE_URL,
41+
headers: {
42+
Authorization: `Bearer ${cookies().get("access_token")?.value}`,
43+
},
44+
};
6245
export default client;
6346
```
47+
6448
then, on a server component, we can just do
49+
6550
```javascript
6651
import client from "@/lib/api";
6752
async function getItems() {
@@ -70,31 +55,32 @@ async function getItems() {
7055
});
7156
if (error) {
7257
console.log(error);
73-
// any other error handling code
58+
// any other error handling code
7459
}
7560
return data;
7661
}
7762
```
78-
This is as cleanest as it can possibly get, in my personal opinion, for handling frontend API requests.
63+
64+
This is is a very simple and clean way, in my personal opinion, to handle frontend API requests.
7965
8066
### UI library
67+
8168
We use [Shadcn](https://ui.shadcn.com/ "Shadcn"). It's light-weight, all the UI components are imported as plain javascript code for transparency. So, you can modify to suit your need.
8269
8370
### Deployment
84-
Docker compose is up to date now with nextjs frontend. You can just deploy through docker compose on a remote server.
85-
A friendly warning is this code was recently written (in 3-4 days), so there are still bugs. All pull requests are welcome!
8671
87-
### Roadmap
88-
- Tidy up the error handling bit
89-
- Add task queue for long last jobs (Celery + Redis)
90-
- AI chat interface
72+
This is a 100% serverless template! No need to manage a VM or Kubernates yourself. And it will be completely free to start with. Frontend, backend and database code is deployed to three serverless hosting separately with individual scalability.<br>
73+
Frontend --> Vercel<br>
74+
Backend --> GCP Cloud Run<br>
75+
Database --> Supabase (Postgres)<br>
76+
**You don't need to clickOps the deployment. The whole deployment process is set up via github actions. Whenever there is a merge to the main branch, a CD will be triggered.**
9177
92-
### Backend
93-
We did not change the backend code, all the other details remain valid from the original [README](README-original.md)
78+
Refer to the guide [here](deployment.md)
9479
9580
### EuclideanAI
96-
Who the hell is EuclideanAI? we are a boutique AI & Data consultancy who provide purpose-built AI, data, machine learning solutions for our clients. [Feel free to reach out!](https://euclideanai.com/contactus/)
81+
82+
Who the hell is EuclideanAI? we are a boutique Data&AI consultancy who provide purpose-built AI, data, machine learning solutions for our clients. [Feel free to reach out!](https://euclideanai.com/contactus/)
9783
9884
### License
9985
100-
The Nextjs FastAPI Template is licensed under the terms of the MIT license.
86+
The AI Engineer Template is licensed under the terms of the MIT license.

0 commit comments

Comments
 (0)