Skip to content

Commit cdd3657

Browse files
committed
init
Refactoring
1 parent c539db8 commit cdd3657

File tree

103 files changed

+1874
-15603
lines changed

Some content is hidden

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

103 files changed

+1874
-15603
lines changed

.env.example

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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="Full Stack 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,http://localhost.tiangolo.com"
21+
SECRET_KEY=changethis
22+
FIRST_SUPERUSER=[email protected]
23+
FIRST_SUPERUSER_PASSWORD=changethis
24+
25+
# Emails
26+
SMTP_HOST=
27+
SMTP_USER=
28+
SMTP_PASSWORD=
29+
EMAILS_FROM_EMAIL=[email protected]
30+
SMTP_TLS=True
31+
SMTP_SSL=False
32+
SMTP_PORT=587
33+
34+
# Postgres
35+
POSTGRES_SERVER=localhost
36+
POSTGRES_PORT=5432
37+
POSTGRES_DB=app
38+
POSTGRES_USER=postgres
39+
POSTGRES_PASSWORD=changethis
40+
41+
SENTRY_DSN=
42+
43+
# Configure these with your own Docker registry images
44+
DOCKER_IMAGE_BACKEND=backend
45+
DOCKER_IMAGE_FRONTEND=frontend

CLAUDE.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is a full-stack FastAPI template with React frontend, built with modern tools and best practices. The project uses:
8+
- **Backend**: FastAPI, SQLModel (Pydantic + SQLAlchemy), PostgreSQL
9+
- **Frontend**: React, TypeScript, Vite, TanStack Router/Query, Chakra UI
10+
- **DevOps**: Docker Compose, Traefik, GitHub Actions
11+
12+
## Quick Start Commands
13+
14+
### Development Environment
15+
```bash
16+
# Start the full stack with Docker Compose
17+
docker compose watch
18+
19+
# URLs after starting:
20+
# Frontend: http://localhost:5173
21+
# Backend API: http://localhost:8000
22+
# API Docs: http://localhost:8000/docs
23+
# Adminer (DB): http://localhost:8080
24+
# Traefik UI: http://localhost:8090
25+
```
26+
27+
### Backend Development
28+
```bash
29+
# Install dependencies and activate environment
30+
cd backend
31+
uv sync
32+
source .venv/bin/activate
33+
34+
# Run backend locally (stop Docker service first)
35+
docker compose stop backend
36+
fastapi dev app/main.py
37+
38+
# Run backend tests
39+
./scripts/test.sh # or
40+
uv run pytest
41+
42+
# Run specific test
43+
uv run pytest tests/test_specific.py::test_function
44+
45+
# Database migrations
46+
docker compose exec backend alembic revision --autogenerate -m "message"
47+
docker compose exec backend alembic upgrade head
48+
```
49+
50+
### Frontend Development
51+
```bash
52+
# Install dependencies and start dev server
53+
cd frontend
54+
npm install
55+
npm run dev
56+
57+
# Generate API client after backend changes
58+
./scripts/generate-client.sh
59+
60+
# Run frontend linting
61+
npm run lint
62+
63+
# Run E2E tests
64+
npx playwright test
65+
npx playwright test --ui # Interactive mode
66+
```
67+
68+
## Architecture Overview
69+
70+
### Backend Structure
71+
```
72+
backend/
73+
├── app/
74+
│ ├── api/ # API routes organized by domain
75+
│ ├── core/ # Configuration, security, database setup
76+
│ ├── models.py # SQLModel database models
77+
│ ├── crud.py # Reusable CRUD operations
78+
│ └── tests/ # Pytest test files
79+
└── scripts/ # Development and deployment scripts
80+
```
81+
82+
### Frontend Structure
83+
```
84+
frontend/
85+
├── src/
86+
│ ├── client/ # Auto-generated OpenAPI client
87+
│ ├── components/ # Reusable UI components
88+
│ ├── routes/ # TanStack Router pages
89+
│ └── hooks/ # Custom React hooks
90+
└── tests/ # Playwright E2E tests
91+
```
92+
93+
## Code Quality & Testing
94+
95+
### Backend
96+
- **Linting**: Ruff (configured in pyproject.toml)
97+
- **Type checking**: MyPy (strict mode)
98+
- **Testing**: Pytest with coverage reports in `htmlcov/`
99+
- **Pre-commit**: Runs ruff format, linting, and basic checks
100+
101+
### Frontend
102+
- **Linting**: Biome (configured in biome.json)
103+
- **Type checking**: TypeScript strict mode
104+
- **Testing**: Playwright for E2E tests
105+
- **Pre-commit**: Runs linting and formatting
106+
107+
## Common Development Tasks
108+
109+
### Adding a new API endpoint
110+
1. Add model in `backend/app/models.py`
111+
2. Create migration: `alembic revision --autogenerate -m "Add new model"`
112+
3. Add CRUD operations in `backend/app/crud.py`
113+
4. Add route in appropriate file under `backend/app/api/routes/`
114+
5. Update frontend client: `./scripts/generate-client.sh`
115+
6. Add frontend components/routes as needed
116+
117+
### Database changes
118+
```bash
119+
# Create migration after model changes
120+
docker compose exec backend alembic revision --autogenerate -m "description"
121+
122+
# Apply migration
123+
docker compose exec backend alembic upgrade head
124+
125+
# Check current revision
126+
docker compose exec backend alembic current
127+
```
128+
129+
### Environment Variables
130+
Key variables in `.env`:
131+
- `SECRET_KEY` - JWT secret (generate with `python -c "import secrets; print(secrets.token_urlsafe(32))"`)
132+
- `POSTGRES_PASSWORD` - Database password
133+
- `FIRST_SUPERUSER_PASSWORD` - Initial admin password
134+
- `DOMAIN` - For local testing with subdomains (e.g., `localhost.tiangolo.com`)
135+
136+
## Testing Commands
137+
138+
```bash
139+
# Backend tests
140+
./scripts/test.sh # All tests
141+
uv run pytest tests/api/ # API tests only
142+
uv run pytest -x # Stop on first failure
143+
uv run pytest --cov=app # With coverage
144+
145+
# Frontend tests
146+
npm run test:e2e # Run Playwright tests
147+
npm run test:e2e -- --ui # Interactive mode
148+
npm run test:e2e -- --debug # Debug mode
149+
```
150+
151+
## Deployment
152+
See `deployment.md` for production deployment instructions using Docker Compose with Traefik for HTTPS.

0 commit comments

Comments
 (0)