A comprehensive collection of FastAPI applications demonstrating various web development concepts, data management techniques, and API design patterns.
This repository contains 5 distinct FastAPI applications, each showcasing different aspects of modern web API development:
- Student Result Management System - Academic record management with automatic grade calculation
- Mini Shopping API - E-commerce cart and product management system
- Job Application Tracker - Job search and application status management
- Notes App - File-based note management system
- Simple Contact App - Contact management with in-memory storage
KodeCampTask5/
βββ student_result_management/ # Academic records management
β βββ main.py # FastAPI app with student endpoints
β βββ models.py # Student model with grade calculation
β βββ storage.py # JSON file operations
β βββ README.md # Detailed documentation
β βββ students.json # Student data storage
β
βββ mini_shopping/ # E-commerce shopping system
β βββ main.py # FastAPI app with product/cart endpoints
β βββ models.py # Product model
β βββ cart.py # Cart management logic
β βββ storage.py # File operations
β βββ README.md # Detailed documentation
β βββ products.json # Product catalog
β βββ cart.json # Shopping cart data
β
βββ job_application_tracker/ # Job application management
β βββ main.py # FastAPI app with application endpoints
β βββ models.py # Job application models
β βββ file_handler.py # File operations with backup
β βββ README.md # Detailed documentation
β βββ applications.json # Application data storage
β
βββ notes_app/ # File-based note management
β βββ main.py # FastAPI app with note endpoints
β βββ models.py # Note models with validation
β βββ file_handler.py # OS module file operations
β βββ README.md # Detailed documentation
β βββ notes/ # Directory for note files
β βββ note1.txt
β βββ note2.txt
β
βββ simple_contact_app/ # Contact management system
β βββ main.py # FastAPI app with contact endpoints
β βββ models.py # Contact models with validation
β βββ README.md # Detailed documentation
β
βββ .venv/ # Python virtual environment
βββ .gitignore # Git ignore rules
βββ README.md # This file
- FastAPI - Modern, fast web framework for building APIs
- Pydantic - Data validation using Python type annotations
- Uvicorn - ASGI server for running FastAPI applications
- Python 3.8+ - Programming language
- JSON Files - Lightweight data persistence
- In-Memory Dictionary - Runtime data storage
- File System - Text file storage for notes
- Git - Version control
- GitHub - Remote repository hosting
- Virtual Environment - Isolated Python environment
- Logging - Application monitoring and debugging
Purpose: Manage student academic records with automatic grade calculation
Key Features:
- β Student registration with multiple subject scores
- β Automatic average calculation (rounded to 2 decimal places)
- β Letter grade assignment (A, B, C, D, F)
- β Case-insensitive student lookup
- β JSON data persistence
Endpoints:
POST /students/- Create student recordGET /students/{name}- Get student by nameGET /students/- Get all students
Purpose: E-commerce product browsing and cart management
Key Features:
- β Product catalog management
- β Shopping cart functionality
- β Add/remove items with quantities
- β Checkout with total calculation
- β Math module for price rounding
Endpoints:
GET /products/- Browse productsPOST /cart/add?product_id=1&qty=2- Add to cartGET /cart/checkout- Calculate totalsDELETE /cart/clear- Clear cart
Purpose: Track job applications and search status
Key Features:
- β Job application management (name, company, position, status)
- β Status filtering (pending, accepted, rejected, interview, withdrawn)
- β Comprehensive search functionality
- β Automatic backup system
- β Statistics and analytics
Endpoints:
POST /applications/- Create applicationGET /applications/- Get all applicationsGET /applications/search?status=pending- Search by statusGET /applications/stats- Get statistics
Purpose: File-based note management system
Key Features:
- β Create, read, update, delete notes
- β Each note saved as individual .txt file
- β OS module for file operations
- β File metadata tracking (size, timestamps)
- β Comprehensive error handling
Endpoints:
POST /notes/- Create noteGET /notes/{title}- Get notePOST /notes/{title}- Update noteDELETE /notes/{title}- Delete note
Purpose: Contact management with in-memory storage
Key Features:
- β Contact model (name, phone, email)
- β Path and query parameters
- β In-memory dictionary storage
- β Input validation and sanitization
- β Case-insensitive contact search
Endpoints:
POST /contacts/- Create contactGET /contacts/?name=John- Search contactsPOST /contacts/{name}- Update contactDELETE /contacts/{name}- Delete contact
# Python 3.8 or higher
python --version
# Git (for cloning)
git --version# Clone the repository
git clone https://github.com/mandeell/KodeCampTask5.git
cd KodeCampTask5
# Create virtual environment
python -m venv .venv
# Activate virtual environment
# Windows:
.venv\Scripts\activate
# macOS/Linux:
source .venv/bin/activate
# Install dependencies
pip install fastapi uvicorn pydanticEach application can be run independently:
cd student_result_management
uvicorn main:app --reload --port 8001
# Access: http://localhost:8001/docscd mini_shopping
uvicorn main:app --reload --port 8002
# Access: http://localhost:8002/docscd job_application_tracker
uvicorn main:app --reload --port 8003
# Access: http://localhost:8003/docscd notes_app
uvicorn main:app --reload --port 8004
# Access: http://localhost:8004/docscd simple_contact_app
uvicorn main:app --reload --port 8005
# Access: http://localhost:8005/docsEach application provides interactive API documentation:
- Swagger UI:
http://localhost:PORT/docs - ReDoc:
http://localhost:PORT/redoc - OpenAPI Schema:
http://localhost:PORT/openapi.json
- Navigate to the
/docsendpoint for any application - Explore available endpoints
- Test requests directly in the browser
- View request/response schemas
# Create a student
curl -X POST "http://localhost:8001/students/" \
-H "Content-Type: application/json" \
-d '{"name": "John Doe", "subject_scores": {"Math": 85, "English": 92}}'
# Add item to cart
curl -X POST "http://localhost:8002/cart/add?product_id=1&qty=2"
# Create job application
curl -X POST "http://localhost:8003/applications/" \
-H "Content-Type: application/json" \
-d '{"name": "Jane Smith", "company": "Tech Corp", "position": "Developer", "status": "pending"}'import requests
# Test student API
response = requests.post("http://localhost:8001/students/", json={
"name": "Alice Johnson",
"subject_scores": {"Math": 95, "Science": 88}
})
print(response.json())- β Comprehensive try-catch blocks
- β Proper HTTP status codes
- β Detailed error messages
- β Input validation with Pydantic
- β Type checking with Pydantic models
- β Custom field validators
- β Automatic data sanitization
- β Format validation (email, phone, etc.)
- β Application-level logging
- β Error tracking and debugging
- β Operation monitoring
- β Performance insights
- β Type hints throughout
- β Docstring documentation
- β Modular architecture
- β Separation of concerns
- Applications: Student Management, Shopping, Job Tracker
- Benefits: Human-readable, version control friendly
- Use Case: Persistent data that survives restarts
- Applications: Contact Management
- Benefits: Fast access, simple implementation
- Use Case: Session-based data, rapid prototyping
- Applications: Notes App
- Benefits: Individual file management, OS integration
- Use Case: Document management, content storage
- All user inputs validated with Pydantic models
- SQL injection prevention through parameterized queries
- XSS protection through input sanitization
- Sensitive information not exposed in error messages
- Proper HTTP status codes for different scenarios
- Graceful degradation on failures
- Path traversal protection in file operations
- Safe filename handling and sanitization
- Proper file permissions and access control
# Run with auto-reload for development
uvicorn main:app --reload --host 127.0.0.1 --port 8000# Run with production settings
uvicorn main:app --host 0.0.0.0 --port 8000 --workers 4FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- Follow PEP 8 guidelines
- Use type hints
- Add docstrings for functions
- Maintain consistent naming conventions
- Authentication & Authorization: JWT-based user authentication
- Database Integration: PostgreSQL/MongoDB support
- Caching: Redis caching for improved performance
- Testing: Comprehensive test suites with pytest
- Monitoring: Application metrics and health checks
- API Versioning: Support for multiple API versions
- Rate Limiting: Request throttling and abuse prevention
- Documentation: Enhanced API documentation with examples
- Microservices Architecture: Split into independent services
- Message Queues: Async processing with Celery/RQ
- Load Balancing: Multiple instance deployment
- CDN Integration: Static asset optimization
This project is open source and available under the MIT License.
- Documentation: Check individual app README files
- Issues: Report bugs via GitHub Issues
- Discussions: Use GitHub Discussions for questions
- Repository: https://github.com/mandeell/KodeCampTask5
- Author: mandeell
This project demonstrates:
- FastAPI Fundamentals: Building REST APIs with FastAPI
- Data Modeling: Using Pydantic for data validation
- File Operations: Different data storage approaches
- Error Handling: Robust error management strategies
- API Design: RESTful endpoint design principles
- Documentation: Auto-generated API documentation
- Project Structure: Organizing multi-application projects
- Version Control: Git workflow and repository management
- β 5 Complete Applications - Fully functional FastAPI apps
- β Comprehensive Documentation - Detailed README files for each app
- β Error Handling - Robust error management throughout
- β Data Validation - Input validation with Pydantic models
- β Multiple Storage Patterns - JSON, in-memory, and file system storage
- β Interactive Documentation - Auto-generated API docs
- β Version Control - Git repository with proper structure
- β Modular Design - Clean separation of concerns
Happy Coding! π