Skip to content

Commit ef98faf

Browse files
committed
Initial commit
0 parents  commit ef98faf

File tree

323 files changed

+48750
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

323 files changed

+48750
-0
lines changed

.claude/settings.local.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(tree:*)",
5+
"Bash(alembic revision:*)",
6+
"Bash(uv run alembic:*)",
7+
"Bash(uv run python:*)",
8+
"Bash(git rm:*)",
9+
"Bash(git add:*)",
10+
"Bash(npm run generate-client:*)",
11+
"Bash(cat:*)",
12+
"Bash(npm uninstall:*)",
13+
"Bash(npm run dev:*)",
14+
"Bash(netstat:*)",
15+
"Bash(findstr:*)",
16+
"Bash(dir /s /b \"c:\\Users\\makara\\Desktop\\full-stack-fastapi-template\\frontend\\src\\routes\")",
17+
"Bash(taskkill:*)",
18+
"Bash(powershell -Command \"Stop-Process -Id 8644 -Force\")",
19+
"Bash(powershell -Command:*)",
20+
"Bash(uv sync:*)",
21+
"Bash(python:*)",
22+
"Bash(curl:*)",
23+
"Bash(npm run build:*)",
24+
"Bash(uv add:*)",
25+
"Bash(dir:*)",
26+
"Bash(mkdir:*)",
27+
"Bash(uv run pytest:*)",
28+
"Bash(del \"c:\\Users\\makara\\Desktop\\full-stack-fastapi-template\\backend\\app\\alembic\\versions\\0e52e71d55df_add_owasp_demo_tables.py\")",
29+
"Bash(ls:*)",
30+
"Bash(npx @tanstack/router-cli generate)",
31+
"Bash(uv run:*)",
32+
"Bash(timeout:*)",
33+
"Bash(npm install:*)",
34+
"Bash(docker ps:*)",
35+
"Bash(npx tsc:*)",
36+
"Bash(git stash:*)",
37+
"Bash(npm run lint)",
38+
"Bash(del \"c:\\\\Users\\\\makara\\\\Desktop\\\\full-stack-fastapi-template\\\\frontend\\\\src\\\\routes\\\\unauthorized.tsx\")",
39+
"Bash(del \"c:\\\\Users\\\\makara\\\\Desktop\\\\full-stack-fastapi-template\\\\frontend\\\\src\\\\components\\\\owasp\\\\SettingsButton.tsx\")",
40+
"Bash(find:*)",
41+
"Bash(python3:*)"
42+
],
43+
"deny": [],
44+
"ask": []
45+
}
46+
}

.copier/.copier-answers.yml.jinja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ _copier_answers|to_json -}}

.copier/update_dotenv.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from pathlib import Path
2+
import json
3+
4+
# Update the .env file with the answers from the .copier-answers.yml file
5+
# without using Jinja2 templates in the .env file, this way the code works as is
6+
# without needing Copier, but if Copier is used, the .env file will be updated
7+
root_path = Path(__file__).parent.parent
8+
answers_path = Path(__file__).parent / ".copier-answers.yml"
9+
answers = json.loads(answers_path.read_text())
10+
env_path = root_path / ".env"
11+
env_content = env_path.read_text()
12+
lines = []
13+
for line in env_content.splitlines():
14+
for key, value in answers.items():
15+
upper_key = key.upper()
16+
if line.startswith(f"{upper_key}="):
17+
if " " in value:
18+
content = f"{upper_key}={value!r}"
19+
else:
20+
content = f"{upper_key}={value}"
21+
new_line = line.replace(line, content)
22+
lines.append(new_line)
23+
break
24+
else:
25+
lines.append(line)
26+
env_path.write_text("\n".join(lines))

.env.example

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Domain
2+
# This would be set to the production domain with an env var on deployment
3+
# used by Traefik to transmit traffic and aqcuire TLS certificates
4+
DOMAIN=localhost
5+
# To test the local Traefik config
6+
# DOMAIN=localhost.tiangolo.com
7+
8+
# Used by the backend to generate links in emails to the frontend
9+
FRONTEND_HOST=http://localhost:5173
10+
# In staging and production, set this env var to the frontend host, e.g.
11+
# FRONTEND_HOST=https://dashboard.example.com
12+
13+
# Environment: local, staging, production
14+
ENVIRONMENT=local
15+
16+
PROJECT_NAME="FastAPI Project"
17+
STACK_NAME=full-stack-fastapi-project
18+
19+
# Backend
20+
BACKEND_CORS_ORIGINS="http://localhost,http://localhost:5173,https://localhost,https://localhost:5173"
21+
SECRET_KEY=changethis-generate-a-secure-random-secret-key
22+
FIRST_SUPERUSER=admin@example.com
23+
FIRST_SUPERUSER_PASSWORD=changethis
24+
25+
# Google OAuth
26+
# Get these from Google Cloud Console: https://console.cloud.google.com/
27+
GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com
28+
GOOGLE_CLIENT_SECRET=your-google-client-secret
29+
30+
# Frontend Google OAuth (same as GOOGLE_CLIENT_ID)
31+
VITE_GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com
32+
VITE_API_URL=http://localhost:8000
33+
34+
# Emails
35+
SMTP_HOST=
36+
SMTP_USER=
37+
SMTP_PASSWORD=
38+
EMAILS_FROM_EMAIL=info@example.com
39+
SMTP_TLS=True
40+
SMTP_SSL=False
41+
SMTP_PORT=587
42+
43+
# Postgres
44+
POSTGRES_SERVER=localhost
45+
POSTGRES_PORT=5432
46+
POSTGRES_DB=app
47+
POSTGRES_USER=postgres
48+
POSTGRES_PASSWORD=changethis
49+
50+
SENTRY_DSN=
51+
52+
# Configure these with your own Docker registry images
53+
DOCKER_IMAGE_BACKEND=backend
54+
DOCKER_IMAGE_FRONTEND=frontend

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* text=auto
2+
*.sh text eol=lf

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
node_modules/
2+
/test-results/
3+
/playwright-report/
4+
/blob-report/
5+
/playwright/.cache/
6+
7+
# Environment variables
8+
.env
9+
.env.local
10+
.env.*.local

.pre-commit-config.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.4.0
6+
hooks:
7+
- id: check-added-large-files
8+
- id: check-toml
9+
- id: check-yaml
10+
args:
11+
- --unsafe
12+
- id: end-of-file-fixer
13+
exclude: |
14+
(?x)^(
15+
frontend/src/client/.*|
16+
backend/app/email-templates/build/.*
17+
)$
18+
- id: trailing-whitespace
19+
exclude: ^frontend/src/client/.*
20+
- repo: https://github.com/charliermarsh/ruff-pre-commit
21+
rev: v0.2.2
22+
hooks:
23+
- id: ruff
24+
args:
25+
- --fix
26+
- id: ruff-format
27+
- repo: local
28+
hooks:
29+
- id: local-biome-check
30+
name: biome check
31+
entry: bash -c 'cd frontend && npm run lint'
32+
language: system
33+
types: [text]
34+
files: ^frontend/
35+
36+
ci:
37+
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
38+
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate

.vscode/launch.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Debug FastAPI Project backend: Python Debugger",
9+
"type": "debugpy",
10+
"request": "launch",
11+
"module": "uvicorn",
12+
"args": [
13+
"app.main:app",
14+
"--reload"
15+
],
16+
"cwd": "${workspaceFolder}/backend",
17+
"jinja": true,
18+
"envFile": "${workspaceFolder}/.env",
19+
},
20+
{
21+
"type": "chrome",
22+
"request": "launch",
23+
"name": "Debug Frontend: Launch Chrome against http://localhost:5173",
24+
"url": "http://localhost:5173",
25+
"webRoot": "${workspaceFolder}/frontend"
26+
},
27+
]
28+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.formatOnSave": true
3+
}

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Full Stack FastAPI Project
2+
3+
## Technology Stack and Features
4+
5+
-[**FastAPI**](https://fastapi.tiangolo.com) for the Python backend API.
6+
- 🧰 [SQLModel](https://sqlmodel.tiangolo.com) for the Python SQL database interactions (ORM).
7+
- 🔍 [Pydantic](https://docs.pydantic.dev), used by FastAPI, for the data validation and settings management.
8+
- 💾 [PostgreSQL](https://www.postgresql.org) as the SQL database.
9+
- 🚀 [React](https://react.dev) for the frontend.
10+
- 💃 Using TypeScript, hooks, Vite, and other parts of a modern frontend stack.
11+
- 🎨 [Chakra UI](https://chakra-ui.com) for the frontend components.
12+
- 🤖 An automatically generated frontend client.
13+
- 🧪 [Playwright](https://playwright.dev) for End-to-End testing.
14+
- 🦇 Dark mode support.
15+
- 🐋 [Docker Compose](https://www.docker.com) for development and production.
16+
- 🔒 Secure password hashing by default.
17+
- 🔑 JWT (JSON Web Token) authentication.
18+
- 🔑 Google OAuth authentication.
19+
- 📫 Email based password recovery.
20+
- ✅ Tests with [Pytest](https://pytest.org).
21+
- 📞 [Traefik](https://traefik.io) as a reverse proxy / load balancer.
22+
23+
### Dashboard Login
24+
25+
[![API docs](img/login.png)](https://github.com/fastapi/full-stack-fastapi-template)
26+
27+
### Dashboard - Admin
28+
29+
[![API docs](img/dashboard.png)](https://github.com/fastapi/full-stack-fastapi-template)
30+
31+
### Dashboard - Create User
32+
33+
[![API docs](img/dashboard-create.png)](https://github.com/fastapi/full-stack-fastapi-template)
34+
35+
### Dashboard - Items
36+
37+
[![API docs](img/dashboard-items.png)](https://github.com/fastapi/full-stack-fastapi-template)
38+
39+
### Dashboard - User Settings
40+
41+
[![API docs](img/dashboard-user-settings.png)](https://github.com/fastapi/full-stack-fastapi-template)
42+
43+
### Dashboard - Dark Mode
44+
45+
[![API docs](img/dashboard-dark.png)](https://github.com/fastapi/full-stack-fastapi-template)
46+
47+
### Interactive API Documentation
48+
49+
[![API docs](img/docs.png)](https://github.com/fastapi/full-stack-fastapi-template)
50+
51+
## Configuration
52+
53+
Update configs in the `.env` file to customize your configurations.
54+
55+
Before deploying, make sure you change at least the values for:
56+
57+
- `SECRET_KEY`
58+
- `FIRST_SUPERUSER_PASSWORD`
59+
- `POSTGRES_PASSWORD`
60+
- `GOOGLE_CLIENT_ID`
61+
- `GOOGLE_CLIENT_SECRET`
62+
63+
You can (and should) pass these as environment variables from secrets.
64+
65+
Read the [deployment.md](./deployment.md) docs for more details.
66+
67+
### Generate Secret Keys
68+
69+
Some environment variables in the `.env` file have a default value of `changethis`.
70+
71+
You have to change them with a secret key, to generate secret keys you can run the following command:
72+
73+
```bash
74+
python -c "import secrets; print(secrets.token_urlsafe(32))"
75+
```
76+
77+
Copy the content and use that as password / secret key. And run that again to generate another secure key.
78+
79+
## Backend Development
80+
81+
Backend docs: [backend/README.md](./backend/README.md).
82+
83+
## Frontend Development
84+
85+
Frontend docs: [frontend/README.md](./frontend/README.md).
86+
87+
## Deployment
88+
89+
Deployment docs: [deployment.md](./deployment.md).
90+
91+
## Development
92+
93+
General development docs: [development.md](./development.md).
94+
95+
This includes using Docker Compose, custom local domains, `.env` configurations, etc.

0 commit comments

Comments
 (0)