Skip to content

Commit ccea75c

Browse files
committed
update readme πŸ“
1 parent 2705d3b commit ccea75c

File tree

2 files changed

+65
-72
lines changed

2 files changed

+65
-72
lines changed

β€Ž.env.exampleβ€Ž

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
# Application Settings
2-
PROJECT_NAME=Hero API
3-
DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/heroes
4-
DEBUG=true
5-
6-
# JWT Settings
7-
JWT_SECRET=your-secret-key-change-in-production
8-
JWT_ALGORITHM=HS256
9-
JWT_EXPIRATION=30
1+
DATABASE_URL="your-database-url"
2+
JWT_SECRET="your-secret-key"

β€ŽREADME.mdβ€Ž

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,95 @@
1-
# Hero API
2-
3-
A FastAPI-based CRUD application for managing heroes, following best practices and modern Python async patterns.
4-
5-
## Features
6-
7-
- Full CRUD operations for heroes
8-
- Async SQLAlchemy with PostgreSQL
9-
- Alembic migrations
10-
- Clean architecture with repository pattern
11-
- Custom exception handling
12-
- Type hints and documentation
13-
14-
## Project Structure
15-
1+
# Hero API πŸ¦Έβ€β™‚οΈ
2+
A modern, production-ready FastAPI template for building scalable APIs.
3+
4+
## Features ✨
5+
- πŸ”„ Complete CRUD operations for heroes
6+
- πŸ“Š Async SQLAlchemy with PostgreSQL
7+
- πŸ”„ Automatic Alembic migrations
8+
- πŸ—οΈ Clean architecture with repository pattern
9+
- ⚠️ Custom exception handling
10+
- πŸ” CI and testing pipeline
11+
- 🧹 Linter setup with pre-commit hooks
12+
- πŸš‚ One-click Railway deployment
13+
14+
## Deploy Now! πŸš€
15+
[![Deploy on Railway](https://railway.com/button.svg)](https://railway.com/template/wbTudS?referralCode=beBXJA)
16+
17+
## Project Structure πŸ“
1618
```
17-
app/
18-
β”œβ”€β”€ core/
19-
β”‚ β”œβ”€β”€ config.py # Application configuration
20-
β”‚ └── database.py # Database setup and session management
21-
β”œβ”€β”€ heroes/
22-
β”‚ β”œβ”€β”€ exceptions.py # Custom exceptions
23-
β”‚ β”œβ”€β”€ models.py # SQLAlchemy models
24-
β”‚ β”œβ”€β”€ repository.py # Database operations
25-
β”‚ β”œβ”€β”€ routes.py # API endpoints
26-
β”‚ β”œβ”€β”€ schemas.py # Pydantic models
27-
β”‚ └── service.py # Business logic
28-
└── main.py # FastAPI application setup
19+
api/
20+
β”œβ”€β”€ core/ # Core functionality
21+
β”‚ β”œβ”€β”€ config.py # Environment and app configuration
22+
β”‚ β”œβ”€β”€ database.py # Database connection and sessions
23+
β”‚ β”œβ”€β”€ exceptions.py # Global exception handlers
24+
β”‚ β”œβ”€β”€ logging.py # Logging configuration
25+
β”‚ └── security.py # Authentication and security
26+
β”œβ”€β”€ src/
27+
β”‚ β”œβ”€β”€ heroes/ # Heroes module
28+
β”‚ β”‚ β”œβ”€β”€ models.py # Database models
29+
β”‚ β”‚ β”œβ”€β”€ repository.py # Data access layer
30+
β”‚ β”‚ β”œβ”€β”€ routes.py # API endpoints
31+
β”‚ β”‚ └── schemas.py # Pydantic models
32+
β”‚ └── users/ # Users module
33+
β”‚ β”œβ”€β”€ models.py # User models
34+
β”‚ β”œβ”€β”€ repository.py # User data access
35+
β”‚ β”œβ”€β”€ routes.py # User endpoints
36+
β”‚ └── schemas.py # User schemas
37+
β”œβ”€β”€ utils/ # Utility functions
38+
└── main.py # Application entry point
2939
```
3040

31-
## Requirements
32-
41+
## Requirements πŸ“‹
3342
- Python 3.8+
3443
- PostgreSQL
35-
- Dependencies listed in requirements.txt
3644

37-
## Setup
45+
## Setup πŸ› οΈ
46+
1. Install uv (follow instructions [here](https://docs.astral.sh/uv/#getting-started))
3847

39-
1. Create a virtual environment:
48+
2. Clone the repository:
4049
```bash
41-
python -m venv venv
42-
source venv/bin/activate # Linux/Mac
43-
venv\Scripts\activate # Windows
50+
git clone https://github.com/yourusername/minimalistic-fastapi-template.git
51+
cd minimalistic-fastapi-template
4452
```
4553

46-
2. Install dependencies:
54+
3. Install dependencies with uv:
4755
```bash
48-
pip install -r requirements.txt
49-
```
50-
51-
3. Create PostgreSQL database:
52-
```sql
53-
CREATE DATABASE hero_db;
56+
uv sync
5457
```
5558

56-
4. Set up environment variables (or create .env file):
57-
```
58-
DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/hero_db
59+
4. Set up environment variables:
60+
```bash
61+
cp .env.example .env
62+
# Edit .env with your database credentials
5963
```
6064

61-
5. Run database migrations:
65+
5. Start the application:
6266
```bash
63-
alembic upgrade head
67+
uv run uvicorn app.main:app
6468
```
6569

66-
6. Start the application:
70+
## Creating a Migration πŸ”„
71+
1. Make changes to your models
72+
2. Generate migration:
6773
```bash
68-
uvicorn app.main:app --reload
74+
alembic revision --autogenerate -m "your migration message"
6975
```
7076

71-
## API Endpoints
77+
Note: Migrations will be automatically applied when you start the application - no need to run `alembic upgrade head` manually!
7278

79+
## API Endpoints πŸ“Š
80+
### Heroes
7381
- `GET /heroes` - List all heroes
7482
- `GET /heroes/{id}` - Get a specific hero
7583
- `POST /heroes` - Create a new hero
7684
- `PATCH /heroes/{id}` - Update a hero
7785
- `DELETE /heroes/{id}` - Delete a hero
7886

79-
## Example Usage
87+
### Authentication
88+
- `POST /auth/register` - Register a new user
89+
- `POST /auth/login` - Login and get access token
90+
- `GET /auth/me` - Get current user profile
8091

92+
## Example Usage πŸ“
8193
Create a new hero:
8294
```bash
8395
curl -X POST "http://localhost:8000/heroes/" -H "Content-Type: application/json" -d '{
@@ -86,15 +98,3 @@ curl -X POST "http://localhost:8000/heroes/" -H "Content-Type: application/json"
8698
"powers": "Wall-crawling, super strength, spider-sense"
8799
}'
88100
```
89-
90-
## Development
91-
92-
To create a new database migration:
93-
```bash
94-
alembic revision --autogenerate -m "description"
95-
```
96-
97-
To apply migrations:
98-
```bash
99-
alembic upgrade head
100-
```

0 commit comments

Comments
Β (0)