Skip to content

Latest commit

 

History

History
340 lines (276 loc) · 5.86 KB

File metadata and controls

340 lines (276 loc) · 5.86 KB

SolarMed AI Development Guide

Development Environment Setup

Prerequisites

  • Node.js (v16 or higher)
  • Python (v3.8 or higher)
  • Git
  • Docker (optional)
  • VS Code or similar IDE

Frontend Setup

  1. Install Node.js dependencies:
cd frontend
npm install
  1. Configure environment variables:
cp .env.example .env
# Edit .env with your configuration
  1. Start development server:
npm run dev

Backend Setup

  1. Create Python virtual environment:
cd backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Start development server:
uvicorn main:app --reload

Project Structure

Frontend

frontend/
├── src/
│   ├── components/     # Reusable Vue components
│   ├── views/         # Page components
│   ├── services/      # API and business logic
│   ├── stores/        # Vuex state management
│   ├── utils/         # Utility functions
│   ├── assets/        # Static assets
│   └── App.vue        # Root component
├── public/            # Static files
└── package.json       # Dependencies and scripts

Backend

backend/
├── app/
│   ├── api/          # API endpoints
│   ├── core/         # Core functionality
│   ├── models/       # Database models
│   ├── schemas/      # Pydantic schemas
│   └── services/     # Business logic
├── tests/            # Test suite
└── main.py          # Application entry

Development Workflow

Git Workflow

  1. Create feature branch:
git checkout -b feature/your-feature-name
  1. Make changes and commit:
git add .
git commit -m "Description of changes"
  1. Push changes:
git push origin feature/your-feature-name
  1. Create pull request on GitHub

Code Style

  • Frontend: ESLint + Prettier
  • Backend: Black + isort
  • Follow Vue.js style guide
  • Use TypeScript where possible

Testing

  1. Frontend tests:
npm run test:unit    # Unit tests
npm run test:e2e     # End-to-end tests
  1. Backend tests:
pytest               # Run all tests
pytest -v           # Verbose output
pytest -k "test_name" # Run specific test

Key Components Development

Frontend Components

Creating a New Component

  1. Create component file:
touch src/components/YourComponent.vue
  1. Basic structure:
<template>
  <!-- Component template -->
</template>

<script setup>
// Component logic
</script>

<style scoped>
/* Component styles */
</style>

State Management

  1. Create store module:
// stores/yourModule.js
export const useYourStore = defineStore('yourModule', {
  state: () => ({
    // State properties
  }),
  actions: {
    // Actions
  }
});

Backend Development

Creating API Endpoints

  1. Create route file:
# api/your_endpoint.py
from fastapi import APIRouter

router = APIRouter()

@router.get("/your-endpoint")
async def your_endpoint():
    return {"message": "Hello World"}
  1. Add to main router:
# api/router.py
from .your_endpoint import router as your_router

router.include_router(your_router)

Database Models

  1. Create model:
# models/your_model.py
from sqlalchemy import Column, Integer, String
from .base import Base

class YourModel(Base):
    __tablename__ = "your_table"
    
    id = Column(Integer, primary_key=True)
    name = Column(String)

Offline-First Development

Service Worker

  1. Update service worker:
// public/sw.js
self.addEventListener('install', (event) => {
  // Cache assets
});

self.addEventListener('fetch', (event) => {
  // Handle requests
});

IndexedDB

  1. Create store:
// utils/offlineStorage.js
const db = {
  yourStore: 'your_store'
};

Sync Manager

  1. Implement sync:
// services/syncManager.js
class SyncManager {
  async sync() {
    // Sync logic
  }
}

Performance Optimization

Frontend

  1. Code splitting
  2. Lazy loading
  3. Asset optimization
  4. Caching strategies

Backend

  1. Database indexing
  2. Query optimization
  3. Response caching
  4. Connection pooling

Security Considerations

Frontend

  1. Input validation
  2. XSS prevention
  3. CSRF protection
  4. Secure storage

Backend

  1. Authentication
  2. Authorization
  3. Data validation
  4. Rate limiting

Deployment

Development

  1. Start services:
# Frontend
npm run dev

# Backend
uvicorn main:app --reload

Production

  1. Build frontend:
npm run build
  1. Start backend:
uvicorn main:app --host 0.0.0.0 --port 8000

Docker

  1. Build images:
docker-compose build
  1. Start containers:
docker-compose up -d

Monitoring and Debugging

Frontend

  1. Browser DevTools
  2. Vue DevTools
  3. Performance monitoring
  4. Error tracking

Backend

  1. Logging
  2. Debug mode
  3. Performance metrics
  4. Error reporting

Contributing Guidelines

  1. Fork the repository
  2. Create feature branch
  3. Make changes
  4. Run tests
  5. Submit PR

Resources

Documentation

Tools

Support

Getting Help

  1. Check documentation
  2. Search issues
  3. Create new issue
  4. Contact maintainers

Reporting Bugs

  1. Check existing issues
  2. Create detailed report
  3. Include reproduction steps
  4. Provide environment info