cp
This commit is contained in:
parent
d67d5d7e05
commit
d8a6cffcb4
159
README.md
159
README.md
@ -17,27 +17,25 @@ SEREACT is a secure API for storing, organizing, and retrieving images with adva
|
|||||||
```
|
```
|
||||||
sereact/
|
sereact/
|
||||||
├── images/ # Sample images for testing
|
├── images/ # Sample images for testing
|
||||||
├── sereact/ # Main application code
|
├── deployment/ # Deployment configurations
|
||||||
│ ├── deployment/ # Deployment configurations
|
│ ├── cloud-run/ # Google Cloud Run configuration
|
||||||
│ │ ├── cloud-run/ # Google Cloud Run configuration
|
│ └── terraform/ # Infrastructure as code
|
||||||
│ │ └── terraform/ # Infrastructure as code
|
├── docs/ # Documentation
|
||||||
│ ├── docs/ # Documentation
|
│ └── api/ # API documentation
|
||||||
│ │ └── api/ # API documentation
|
├── scripts/ # Utility scripts
|
||||||
│ ├── scripts/ # Utility scripts
|
├── src/ # Source code
|
||||||
│ ├── src/ # Source code
|
│ ├── api/ # API endpoints and routers
|
||||||
│ │ ├── api/ # API endpoints
|
│ │ └── v1/ # API version 1 routes
|
||||||
│ │ │ └── v1/ # API version 1
|
│ ├── auth/ # Authentication and authorization
|
||||||
│ │ ├── core/ # Core modules
|
│ ├── config/ # Configuration management
|
||||||
│ │ ├── db/ # Database models and repositories
|
│ ├── models/ # Database models
|
||||||
│ │ │ ├── models/ # Data models
|
│ ├── services/ # Business logic services
|
||||||
│ │ │ ├── providers/ # Database providers
|
│ └── utils/ # Utility functions
|
||||||
│ │ │ └── repositories/ # Database operations
|
├── tests/ # Test code
|
||||||
│ │ ├── schemas/ # API schemas (request/response)
|
│ ├── api/ # API tests
|
||||||
│ │ └── services/ # Business logic services
|
│ ├── auth/ # Authentication tests
|
||||||
│ └── tests/ # Test code
|
│ ├── models/ # Model tests
|
||||||
│ ├── api/ # API tests
|
│ └── services/ # Service tests
|
||||||
│ ├── db/ # Database tests
|
|
||||||
│ └── services/ # Service tests
|
|
||||||
├── main.py # Application entry point
|
├── main.py # Application entry point
|
||||||
├── requirements.txt # Python dependencies
|
├── requirements.txt # Python dependencies
|
||||||
└── README.md # This file
|
└── README.md # This file
|
||||||
@ -410,4 +408,121 @@ Firestore security rules enforce the following access patterns:
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This project is licensed under the MIT License - see the LICENSE file for details.
|
This project is licensed under the MIT License - see the LICENSE file for details.
|
||||||
|
|
||||||
|
## API Modules Architecture
|
||||||
|
|
||||||
|
The SEREACT API is organized into the following key modules to ensure separation of concerns and maintainable code:
|
||||||
|
|
||||||
|
```
|
||||||
|
src/
|
||||||
|
├── api/ # API endpoints and routers
|
||||||
|
│ └── v1/ # API version 1 routes
|
||||||
|
├── auth/ # Authentication and authorization
|
||||||
|
├── config/ # Configuration management
|
||||||
|
├── models/ # Database models
|
||||||
|
├── services/ # Business logic services
|
||||||
|
└── utils/ # Utility functions
|
||||||
|
```
|
||||||
|
|
||||||
|
### Module Responsibilities
|
||||||
|
|
||||||
|
#### Router Module
|
||||||
|
- Defines API endpoints and routes
|
||||||
|
- Handles HTTP requests and responses
|
||||||
|
- Validates incoming request data
|
||||||
|
- Directs requests to appropriate services
|
||||||
|
- Implements API versioning
|
||||||
|
|
||||||
|
#### Auth Module
|
||||||
|
- Manages user authentication
|
||||||
|
- Handles API key validation and verification
|
||||||
|
- Implements role-based access control
|
||||||
|
- Provides security middleware
|
||||||
|
- Manages user sessions and tokens
|
||||||
|
|
||||||
|
#### Services Module
|
||||||
|
- Contains core business logic
|
||||||
|
- Orchestrates operations across multiple resources
|
||||||
|
- Implements domain-specific rules and workflows
|
||||||
|
- Integrates with external services (Cloud Vision, Storage)
|
||||||
|
- Handles image processing and embedding generation
|
||||||
|
|
||||||
|
#### Models Module
|
||||||
|
- Defines data structures and schemas
|
||||||
|
- Provides database entity representations
|
||||||
|
- Handles data validation and serialization
|
||||||
|
- Implements data relationships and constraints
|
||||||
|
- Manages database migrations
|
||||||
|
|
||||||
|
#### Utils Module
|
||||||
|
- Provides helper functions and utilities
|
||||||
|
- Implements common functionality used across modules
|
||||||
|
- Handles error processing and logging
|
||||||
|
- Provides formatting and conversion utilities
|
||||||
|
- Implements reusable middleware components
|
||||||
|
|
||||||
|
#### Config Module
|
||||||
|
- Manages application configuration
|
||||||
|
- Handles environment variable loading
|
||||||
|
- Provides centralized settings management
|
||||||
|
- Configures service connections and credentials
|
||||||
|
- Defines application constants and defaults
|
||||||
|
|
||||||
|
### Module Interactions
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
||||||
|
│ │ │ │ │ │
|
||||||
|
│ Router │ ───────▶│ Services │ ◀───────│ Config │
|
||||||
|
│ Module │ │ Module │ │ Module │
|
||||||
|
│ │ │ │ │ │
|
||||||
|
└──────┬──────┘ └──────┬──────┘ └─────────────┘
|
||||||
|
│ │
|
||||||
|
│ │
|
||||||
|
▼ ▼
|
||||||
|
┌─────────────┐ ┌─────────────┐
|
||||||
|
│ │ │ │
|
||||||
|
│ Auth │ │ Models │
|
||||||
|
│ Module │ │ Module │
|
||||||
|
│ │ │ │
|
||||||
|
└──────┬──────┘ └──────┬──────┘
|
||||||
|
│ │
|
||||||
|
│ │
|
||||||
|
└───────────────────────┘
|
||||||
|
│
|
||||||
|
▼
|
||||||
|
┌─────────────┐
|
||||||
|
│ │
|
||||||
|
│ Utils │
|
||||||
|
│ Module │
|
||||||
|
│ │
|
||||||
|
└─────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
The modules interact in the following ways:
|
||||||
|
- **Request Flow**:
|
||||||
|
- Client request arrives at the Router Module
|
||||||
|
- Auth Module validates the request authentication
|
||||||
|
- Router delegates to appropriate Service functions
|
||||||
|
- Service uses Models to interact with the database
|
||||||
|
- Service returns data to Router which formats the response
|
||||||
|
|
||||||
|
- **Cross-Cutting Concerns**:
|
||||||
|
- Config Module provides settings to all other modules
|
||||||
|
- Utils Module provides helper functions across the application
|
||||||
|
- Auth Module secures access to routes and services
|
||||||
|
|
||||||
|
- **Dependency Direction**:
|
||||||
|
- Router depends on Services and Auth
|
||||||
|
- Services depend on Models and Config
|
||||||
|
- Models depend on Utils for helper functions
|
||||||
|
- Auth depends on Models for user information
|
||||||
|
- All modules may use Utils and Config
|
||||||
|
|
||||||
|
This modular architecture provides several benefits:
|
||||||
|
- **Maintainability**: Changes in one module have minimal impact on others
|
||||||
|
- **Testability**: Modules can be tested in isolation with mocked dependencies
|
||||||
|
- **Scalability**: New features can be added by extending existing modules
|
||||||
|
- **Reusability**: Common functionality is centralized for consistent implementation
|
||||||
|
- **Security**: Authentication and authorization are handled consistently
|
||||||
Loading…
x
Reference in New Issue
Block a user