- 1. Overview
- 2. Project Document Structure
- 3. Quick Start
- 4. Technical Design
- 5. Performance Optimization
- 6. Testing
- 7. Deployment
- 8. API Documentation
This service provides a production-ready foundation for building RESTful APIs with FastAPI, featuring in-memory data storage and comprehensive testing capabilities. The service supports basic database operations (CRUD) and allows for simple join operations between datasets.
./README.md
Primary entry point for the project, containing quick start guide, installation instructions, and overview of all features and components.
./1_PRODUCT_REQUIREMENTS.md
Comprehensive documentation of product features, user stories, acceptance criteria, and business requirements.
./2_TECHNICAL_DESIGN.md
Detailed technical architecture, system design, implementation specifications, and architectural decisions.
./3_PERFORMANCE_OPTIMIZATION.md
Comprehensive performance optimization strategies, test results, and future optimization plans.
./4_CONTRIBUTING.md
Development standards, workflow guidelines, and contribution procedures for developers.
./backend/tests/TESTING_STRATEGY.md
Testing methodology, test organization, and execution guidelines.
./deploy/DEPLOYMENT.md
Complete deployment procedures, environment setup, and operational instructions.
- Clone the repository:
git clone https://github.com/yourusername/in-memory-db-service.git
cd in-memory-db-service
- View available commands:
make help
- Quick development setup:
make dev # Installs dependencies, formats code, runs linter and tests, starts the server
Command | Description |
---|---|
make install |
Install dependencies |
make run |
Run the application locally |
make test |
Run all tests |
make test-report |
Generate comprehensive test report |
make clean |
Clean up temporary files |
Command | Tool | Description |
---|---|---|
make format |
Black | Automatically format Python code to match PEP 8 style |
make lint |
Flake8 | Check code style and quality for potential errors |
For detailed technical specifications and architecture details, please refer to our comprehensive Technical Design Document. The document covers:
- System Architecture
- High-Level Architecture
- Component Overview
- Project Structure
- Model Hierarchy and Layer Analysis
- Layer Dependencies and Project Structure
- Layer-by-Layer Analysis
- Design Principles
- Interaction Flow Examples
- Design and Implementation Details
- Data Storage Implementation
- In-Memory Database Class
- Singleton Pattern Implementation
- Concurrency Handling
- Table-Level Locking
- Async Operations
- Data Storage Implementation
- Performance Optimizations
- Index Optimization
- Test Results of Index Optimization
- Future Optimizations
- Testing Strategy
- Deployment
- Security Considerations
- Input Validation
- Rate Limiting
- Error Handling
- Future Optimizations
- Planned Improvements
- Scaling Strategy
- Known Limitations
Key technical features include:
- In-memory data storage with table-level locking
- Singleton pattern implementation for database consistency
- Hash-based indexing with proven performance improvements
- Async/await support for non-blocking operations
- RESTful API with FastAPI framework
- Comprehensive error handling and validation
- Efficient data relationship management
For implementation details and guidelines, see:
For detailed performance optimization strategies and benchmarks, please refer to our Performance Optimization Document. The document covers:
Key performance improvements include:
- Hash-based indexing implementation with proven improvements:
- 59.9% faster worst-case user retrieval operations
- 43.3% improvement in table dump maximum latency
- 16.3% better worst-case relationship query performance
- 7.8% improvement in mean latency for table dumps
- 10.9% increase in operations per second for relationship endpoints
- O(1) lookup time for indexed fields with minimal memory overhead
Current focus areas include:
- Relationship-based query optimization
- Memory-efficient data structures
- Table-level operation performance
- Query response time improvements
Upcoming optimizations:
- Advanced caching strategies
- Query result pagination
- Additional index features
- Memory optimization techniques
For detailed metrics and implementation details, see:
- Implementation Strategy
- Index Types and Considerations
- Performance Test Results
- Theoretical Explanation
For comprehensive testing information, including test organization, implementation, execution, and reporting, please refer to our Testing Strategy Document.
The testing documentation covers:
- Test Directory Structure
- Test Categories and Organization
- Test Implementation Details
- Test Execution and Reporting
- Coverage Analysis
- Performance Testing
Quick reference for common test-related commands:
make test # Run all tests
make test-report # Generate comprehensive test report
For detailed deployment instructions, configurations, and commands, please refer to our comprehensive Deployment Guide. The guide covers:
- Quick Start and Installation
- Deployment Architecture
- Deployment Scenarios
- Resource Management
- Health Checks
- Logging
- Maintenance
For quick reference to deployment commands, see:
Documentation Type | URL | Description |
---|---|---|
Swagger UI | http://localhost:8000/docs |
Interactive API documentation with testing capability |
ReDoc | http://localhost:8000/redoc |
Alternative API documentation with better readability |
Below are examples of how to interact with the API using cURL. All responses are in JSON format.
- Create a new user:
curl -X POST http://localhost:8000/api/v1/users \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"full_name": "John Doe",
"password": "securepass123"
}'
- Get a user by ID:
curl -X GET http://localhost:8000/api/v1/users/550e8400-e29b-41d4-a716-446655440000
- List all users:
curl -X GET http://localhost:8000/api/v1/users
- Update a user:
curl -X PATCH http://localhost:8000/api/v1/users/550e8400-e29b-41d4-a716-446655440000 \
-H "Content-Type: application/json" \
-d '{
"full_name": "John Smith"
}'
- Delete a user:
curl -X DELETE http://localhost:8000/api/v1/users/550e8400-e29b-41d4-a716-446655440000
- Create a new order:
curl -X POST http://localhost:8000/api/v1/orders \
-H "Content-Type: application/json" \
-d '{
"user_id": "550e8400-e29b-41d4-a716-446655440000",
"amount": 99.99,
"description": "Premium Package",
"status": "pending"
}'
- Get an order by ID:
curl -X GET http://localhost:8000/api/v1/orders/550e8400-e29b-41d4-a716-446655441111
- List all orders:
curl -X GET http://localhost:8000/api/v1/orders
- Update an order:
curl -X PATCH http://localhost:8000/api/v1/orders/550e8400-e29b-41d4-a716-446655441111 \
-H "Content-Type: application/json" \
-d '{
"status": "completed"
}'
- Delete an order:
curl -X DELETE http://localhost:8000/api/v1/orders/550e8400-e29b-41d4-a716-446655441111
- Get all orders for a user:
curl -X GET http://localhost:8000/api/v1/users/550e8400-e29b-41d4-a716-446655440000/orders
- Get user associated with an order:
curl -X GET http://localhost:8000/api/v1/orders/550e8400-e29b-41d4-a716-446655441111/user
- Dump table contents (formatted):
curl -X GET http://localhost:8000/api/v1/tables/users/dump # For users table
curl -X GET http://localhost:8000/api/v1/tables/orders/dump # For orders table
- Dump table contents (raw):
curl -X GET http://localhost:8000/api/v1/db/dump/users # For users table
curl -X GET http://localhost:8000/api/v1/db/dump/orders # For orders table
- Clear table contents:
curl -X DELETE http://localhost:8000/api/v1/tables/users # Clear users table
curl -X DELETE http://localhost:8000/api/v1/tables/orders # Clear orders table
- Health check:
curl -X GET http://localhost:8000/api/v1/health
- Readiness check:
curl -X GET http://localhost:8000/api/v1/ready
Note: Replace the UUIDs in the examples with actual UUIDs from your system. All endpoints return appropriate HTTP status codes:
- 200: Successful operation
- 201: Resource created
- 400: Bad request
- 404: Resource not found
- 422: Validation error
- 500: Internal server error