171 lines
4.4 KiB
Markdown
171 lines
4.4 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
|
|
- **MongoDB Integration**: NoSQL database for flexible data storage
|
|
- **Responsive Design**: Mobile-friendly interface without external CSS frameworks
|
|
|
|
## Technology Stack
|
|
|
|
- **Backend**: Symfony 7.2 (PHP 8.2+)
|
|
- **Database**: MongoDB with Doctrine ODM
|
|
- **Frontend**: Vanilla JavaScript with modern CSS
|
|
- **Architecture**: Clean Architecture with SOLID principles
|
|
|
|
## Requirements
|
|
|
|
- PHP 8.2 or higher
|
|
- MongoDB 4.4 or higher
|
|
- Composer
|
|
- MongoDB PHP Extension
|
|
|
|
## 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 MongoDB connection:
|
|
```
|
|
APP_ENV=dev
|
|
APP_SECRET=your-secret-key-here
|
|
MONGODB_URI=mongodb://localhost:27017
|
|
```
|
|
|
|
4. **Start MongoDB**
|
|
Make sure MongoDB is running on your system.
|
|
|
|
5. **Seed the database**
|
|
```bash
|
|
php bin/console app:seed-data
|
|
```
|
|
|
|
6. **Start the development server**
|
|
```bash
|
|
symfony server:start
|
|
```
|
|
|
|
Or use PHP's built-in server:
|
|
```bash
|
|
php -S localhost:8000 -t public/
|
|
```
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
src/
|
|
├── Command/ # Console commands
|
|
├── Controller/ # HTTP controllers
|
|
├── Document/ # MongoDB document models
|
|
├── Repository/ # Data access layer
|
|
├── Service/ # Business logic layer
|
|
└── Kernel.php # Application kernel
|
|
|
|
templates/
|
|
├── base.html.twig # Base template
|
|
└── home/ # Home page templates
|
|
|
|
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
|
|
- **Documents**: MongoDB document models (`Brand`, `CarModel`, `CarRevision`)
|
|
- **Repositories**: Data access interfaces
|
|
|
|
### Application Layer
|
|
- **Services**: Business logic (`CarSearchService`)
|
|
- **Commands**: Console commands for data management
|
|
|
|
### Infrastructure Layer
|
|
- **Controllers**: HTTP request handlers
|
|
- **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. **No Else Statements**: Code uses early returns for better readability
|
|
4. **Readable Names**: Self-documenting code with descriptive names
|
|
|
|
## Development
|
|
|
|
### Adding New Data
|
|
|
|
Use the seed command to populate the database:
|
|
```bash
|
|
php bin/console app:seed-data
|
|
```
|
|
|
|
### Console Commands
|
|
|
|
List all available commands:
|
|
```bash
|
|
php bin/console list
|
|
```
|
|
|
|
### Database Operations
|
|
|
|
The application uses MongoDB with Doctrine ODM. All database operations are handled through repositories following the Repository pattern.
|
|
|
|
## Styling Guidelines
|
|
|
|
- **No External CSS Frameworks**: Pure CSS following modern standards
|
|
- **Responsive Design**: Mobile-first approach
|
|
- **Modern UI**: Clean, minimalist design inspired by search engines
|
|
- **Accessibility**: Semantic HTML and proper contrast ratios
|
|
|
|
## 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.
|