evwiki/README.md
2025-05-30 07:04:14 +02:00

208 lines
5.5 KiB
Markdown

# E-WIKI - Electric Vehicle Database
A modern Symfony application for browsing and searching electric vehicle information. This application provides a clean, search-engine-like interface for exploring electric vehicle brands, models, and specifications.
## Features
- **Modern Search Interface**: Google-like search experience for electric vehicles
- **Brand Directory**: Browse popular electric vehicle manufacturers
- **Vehicle Database**: Comprehensive information about electric car models and revisions
- **RESTful API**: JSON API endpoints for integration
- **PostgreSQL Integration**: Relational database for structured data storage
- **Responsive Design**: Mobile-friendly interface without external CSS frameworks
## Technology Stack
- **Backend**: Symfony 7.2 (PHP 8.3+)
- **Database**: PostgreSQL with native PDO
- **Frontend**: Vanilla JavaScript with modern CSS
- **Architecture**: Clean Architecture with SOLID principles
## Requirements
- PHP 8.3 or higher
- PostgreSQL 13 or higher
- Composer
- PostgreSQL PHP Extension (pdo_pgsql)
## Installation
1. **Clone the repository**
```bash
git clone <repository-url>
cd evwiki
```
2. **Install dependencies**
```bash
composer install
```
3. **Configure environment**
```bash
cp .env.local.example .env.local
```
Edit `.env.local` and set your PostgreSQL connection:
```
APP_ENV=dev
APP_SECRET=your-secret-key-here
DATABASE_DSN="pgsql:host=localhost;port=5432;dbname=evwiki"
DATABASE_USER=postgres
DATABASE_PASSWORD=postgres
```
4. **Start PostgreSQL**
Make sure PostgreSQL is running on your system.
5. **Initialize the database**
```bash
php bin/console app:database:init
```
6. **Start the development server**
```bash
symfony server:start
```
Or use PHP's built-in server:
```bash
php -S localhost:8000 -t public/
```
## Docker Setup
You can also run the application using Docker:
1. **Start the services**
```bash
docker-compose up -d
```
2. **Initialize the database in the container**
```bash
docker-compose exec app php bin/console app:database:init
```
## Project Structure
```
src/
├── Command/ # Console commands
├── Application/
│ └── Controller/ # HTTP controllers
├── Domain/
│ ├── Model/ # Domain models
│ └── Repository/ # Repository interfaces
├── Infrastructure/
│ └── PostgreSQL/ # PostgreSQL implementation
│ ├── PostgreSQLClient.php
│ └── Repository/ # Concrete repositories
└── Kernel.php # Application kernel
templates/
├── base.html.twig # Base template
└── home/ # Home page templates
database/
└── schema.sql # PostgreSQL schema
config/
├── bundles.php # Bundle configuration
├── packages/ # Package configurations
├── routes.yaml # Route definitions
└── services.yaml # Service container
```
## API Endpoints
### Search
- `GET /api/search?query={term}` - Search for vehicles, brands, or models
### Brands
- `GET /api/brands` - Get all brands
- `GET /api/brands/{brandId}/models` - Get models for a specific brand
### Models
- `GET /api/models/category/{category}` - Get models by category
## Architecture
This application follows clean architecture principles:
### Domain Layer
- **Models**: Core domain models (`Brand`, `CarModel`, `CarRevision`)
- **Repositories**: Data access interfaces
### Application Layer
- **Controllers**: HTTP request handlers
- **Commands**: Console commands for data management
### Infrastructure Layer
- **PostgreSQL**: Database implementation with native PDO
- **Templates**: Twig templates for rendering
### Key Design Principles
1. **SOLID Principles**: Each class has a single responsibility
2. **Dependency Injection**: All dependencies are injected via constructor
3. **Clean Architecture**: Domain logic is independent of infrastructure
4. **Readable Code**: Self-documenting code with descriptive names
## Database Commands
### Initialize Database
Initialize the database with schema and sample data:
```bash
php bin/console app:database:init
```
### Console Commands
List all available commands:
```bash
php bin/console list
```
## Database Schema
The application uses PostgreSQL with the following main tables:
- **brands**: Electric vehicle manufacturers
- **car_models**: Vehicle models belonging to brands
- **car_revisions**: Specific revisions of car models with detailed specifications
All database operations are handled through repositories following the Repository pattern, using native PDO for optimal performance.
## Styling Guidelines
- **No External CSS Frameworks**: Pure CSS following modern standards
- **Mobile-First**: Responsive design approach
- **Clean Design**: Minimalist interface focusing on content
## Environment Variables
Required environment variables:
- `APP_ENV`: Application environment (dev/prod)
- `APP_SECRET`: Secret key for Symfony
- `DATABASE_DSN`: PostgreSQL DSN connection string
- `DATABASE_USER`: PostgreSQL username
- `DATABASE_PASSWORD`: PostgreSQL password
## Contributing
1. Follow PSR-12 coding standards
2. Write clean, self-documenting code
3. Use dependency injection
4. Follow SOLID principles
5. Avoid else statements
6. Use meaningful variable and method names
## License
This project is licensed under the MIT License.
## Support
For support and questions, please open an issue in the repository.