# {project_name}

FastAPI application built with [infomankit](https://github.com/ai-infoman/infoman-pykit).

## Quick Start

### 1. Setup Environment

```bash
# Copy environment config (or use the generated .env directly)
cp config/.env.dev .env

# Update database credentials and other settings in .env
```

### 2. Install Dependencies

```bash
pip install -e .
```

### 3. Run Application

#### Development Mode (Foreground)
```bash
# Using make (recommended for development)
make dev

# Or using main.py
python main.py

# Or using infoman-serve directly
infoman-serve --app app.app:application --reload
```

#### Service Mode (Background)
```bash
# Start as background service
./service.sh start

# Check service status
./service.sh status

# View logs
./service.sh logs

# Stop service
./service.sh stop
```

### 4. Access API Documentation

- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc

## Project Structure

```
{project_name}/
├── app/                    # Application code
│   ├── models/            # Database models
│   ├── routers/           # API routes
│   ├── services/          # Business logic
│   ├── repository/        # Data access layer
│   ├── utils/             # Utilities
│   ├── static/            # Static files
│   └── template/          # HTML templates
├── config/                # Configuration files
│   ├── .env.dev          # Development config
│   └── .env.prod         # Production config
├── doc/                   # Documentation
├── logs/                  # Application logs
├── main.py               # Entry point
├── Makefile              # Development commands
└── service.sh            # Service management script
```

## Development

### Using Makefile (Development Tools)

For **development** and **one-time** commands:

```bash
make help         # Show all available commands
make dev          # Run development server (foreground)
make test         # Run tests
make lint         # Run linter
make format       # Format code
make clean        # Clean temporary files
```

### Using service.sh (Service Management)

For **background service** management:

```bash
./service.sh start     # Start service in background
./service.sh stop      # Stop service
./service.sh restart   # Restart service
./service.sh status    # Show service status
./service.sh logs      # Follow application logs
./service.sh errors    # Follow error logs
```

**When to use each:**
- **Makefile**: Development, debugging, testing, code quality checks
- **service.sh**: Running service in background (testing, staging environments)

## Docker Support

Generate Docker configuration:

```bash
infomankit docker
```

This creates a `docker/` directory with:
- Dockerfile
- docker-compose.yml
- MySQL configuration
- Database initialization scripts

## Configuration

Edit `.env` file to configure:
- Database connection
- JWT settings
- CORS origins
- Redis connection
- Logging settings

See `config/README.md` for detailed documentation.

## License

MIT
