๐ Frontend Repository
โจ Features โข ๐ Quick Start โข ๐ ๏ธ Tech Stack โข ๐ Project Structure โข ๐ค Contributing
Fokuso API is the robust Django REST backend that powers the Fokuso productivity platform. Built with modern development practices, it provides a comprehensive suite of APIs for focus management, spaced repetition learning, task organization, and productivity analytics.
The API implements Test Driven Development (TDD) principles and includes comprehensive documentation via Swagger UI, making it easy for developers to integrate and extend the platform's capabilities.
- Token-based Authentication: Secure user sessions with tokens
- User Registration & Login: Complete auth flow
- Profile Management: User data management
- Flashcard Management: CRUD operations for learning cards
- Deck Organization: Subject-based card grouping
- SM-2 Algorithm: Scientifically-proven spaced repetition
- Review Statistics: Comprehensive learning analytics
- Daily Progress Tracking: Monitor learning consistency
- Session Logging: Track focus and break periods
- Duration Recording: Precise time measurement
- Statistics Generation: Productivity insights and trends
- Streak Calculation: Consistency tracking
- Todo CRUD Operations: Complete task management
- Priority Levels: High, medium, low prioritization
- Category System: Work, personal, health, education, etc.
- Tag Management: Flexible organization system
- Due Date Tracking: Deadline management
- Event Management: Create, update, delete events
- Event Types: Focus, study, meeting, break, other
- Time Tracking: Start/end time with duration calculation
- Date Filtering: Efficient event querying
- Grouped Responses: Events organized by date
- Daily Review Stats: Flashcard performance tracking
- Focus Statistics: Session analytics and trends
- Progress Metrics: Comprehensive productivity insights
- Historical Data: Long-term trend analysis
Before you begin, ensure you have the following installed:
- Docker and Docker Compose
- Git
-
Clone the repository
git clone https://github.com/lowskydev/Fokuso-API.git cd Fokuso-API -
Start the services
docker compose up
-
Access the application
- API Documentation: http://127.0.0.1:8000/api/docs
- Admin Panel: http://127.0.0.1:8000/admin
-
Setup the Fokuso Frontend
Follow the instructions in the Frontend Repository to set up the frontend application.
# Start services
docker compose up
# Start services in background
docker compose up -d
# Stop services
docker compose down
# Run tests
docker compose run --rm app sh -c "python manage.py test"
# Create superuser
docker compose run --rm app sh -c "python manage.py createsuperuser"
# Apply migrations
docker compose run --rm app sh -c "python manage.py migrate"
# Code linting
docker compose run --rm app sh -c "flake8"
# Access Django shell
docker compose run --rm app sh -c "python manage.py shell"
# Create new migrations
docker compose run --rm app sh -c "python manage.py makemigrations"# Reset database (careful - this deletes all fokuso data)
docker compose down
docker volume rm fokuso-api_dev-db-data
docker compose up
# Backup database
docker compose exec db pg_dump -U devuser devdb > backup.sql
# Restore database
docker compose exec -T db psql -U devuser devdb < backup.sql- ๐ Django 3.2 - Robust web framework
- ๐ฅ Django REST Framework 3.12 - Powerful API toolkit
- ๐ drf-spectacular - OpenAPI 3 schema generation
- ๐ PostgreSQL 13 - Advanced relational database
- ๐ง psycopg2 - PostgreSQL adapter for Python
- ๐ณ Docker & Docker Compose - Containerization
- ๐ flake8 - Code linting and style checking
- ๐งช Django Test Framework - Comprehensive testing suite
- ๐ Token Authentication - Secure API access
- ๐ Swagger UI Documentation - Interactive API docs
- ๐ CORS Headers - Cross-origin resource sharing
- ๐ Pagination - Efficient data loading
- ๐ Filtering & Search - Advanced query capabilities
app/
โโโ ๐ app/ # Main application configuration
โ โโโ ๐ settings.py # Django settings
โ โโโ ๐ urls.py # URL routing
โ โโโ ๐ calc.py # Utility functions
โ
โโโ ๐ core/ # Core application models
โ โโโ ๐ models.py # Database models
โ โโโ ๐ admin.py # Admin interface
โ โโโ ๐ management/ # Custom management commands
โ
โโโ ๐ user/ # User authentication
โ โโโ ๐ views.py # Auth views
โ โโโ ๐ serializers.py # User serializers
โ โโโ ๐ urls.py # User URLs
โ
โโโ ๐ flashcards/ # Spaced repetition system
โ โโโ ๐ views.py # Flashcard views
โ โโโ ๐ serializers.py # Card serializers
โ โโโ ๐ sm2.py # SM-2 algorithm
โ โโโ ๐ urls.py # Flashcard URLs
โ
โโโ ๐ calendars/ # Calendar management
โ โโโ ๐ views.py # Calendar views
โ โโโ ๐ serializers.py # Event serializers
โ โโโ ๐ urls.py # Calendar URLs
โ
โโโ ๐ todos/ # Task management
โ โโโ ๐ views.py # Todo views
โ โโโ ๐ serializers.py # Task serializers
โ โโโ ๐ urls.py # Todo URLs
โ
โโโ ๐ stats/ # Analytics system
โ โโโ ๐ views.py # Statistics views
โ โโโ ๐ serializers.py # Stats serializers
โ โโโ ๐ urls.py # Stats URLs
โ
โโโ ๐ notes/ # Note management
โโโ ๐ views.py # Notes views
โโโ ๐ serializers.py # Note serializers
โโโ ๐ urls.py # Notes URLs
- Modular App Structure: Features separated into Django apps
- RESTful API Design: Consistent REST principles
- Token Authentication: Stateless authentication system
- Test-Driven Development: Comprehensive test coverage
- Docker Containerization: Consistent development environment
POST /api/user/create/ # User registration
POST /api/user/token/ # Login & token generation
GET /api/user/me/ # User profile
PATCH /api/user/me/ # Update profile
GET /api/flashcards/ # List flashcards
POST /api/flashcards/ # Create flashcard
GET /api/flashcards/{id}/ # Get flashcard
PATCH /api/flashcards/{id}/ # Update flashcard
DELETE /api/flashcards/{id}/ # Delete flashcard
POST /api/flashcards/{id}/review/ # Review flashcard
GET /api/flashcards/decks/ # List decks
POST /api/flashcards/decks/ # Create deck
GET /api/calendars/events/ # List events
POST /api/calendars/events/ # Create event
GET /api/calendars/events/{id}/ # Get event
PATCH /api/calendars/events/{id}/ # Update event
DELETE /api/calendars/events/{id}/ # Delete event
GET /api/calendars/events/grouped/ # Events grouped by date
GET /api/calendars/events/today/ # Today's events
GET /api/todos/ # List todos
POST /api/todos/ # Create todo
GET /api/todos/{id}/ # Get todo
PATCH /api/todos/{id}/ # Update todo
DELETE /api/todos/{id}/ # Delete todo
GET /api/todos/tags/ # List tags
POST /api/todos/tags/ # Create tag
POST /api/stats/session/ # Log focus session
GET /api/stats/sessions/ # List sessions
GET /api/stats/user-stats/ # User statistics
GET /api/stats/weekly-data/ # Weekly analytics
GET /api/stats/hourly-data/ # Hourly analytics
Fokuso API follows Test-Driven Development principles with comprehensive test coverage:
# Run all tests
docker compose run --rm app sh -c "python manage.py test"
# Run specific app tests
docker compose run --rm app sh -c "python manage.py test flashcards"
# Run specific test class
docker compose run --rm app sh -c "python manage.py test flashcards.tests.test_flashcards_api"- Unit Tests: Model and utility function testing
- API Tests: Comprehensive endpoint testing
- Integration Tests: Feature workflow testing
- Authentication Tests: Security validation
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Write tests for your new feature
- Implement your feature following TDD principles
- Run the test suite to ensure everything passes
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Django best practices and PEP 8 style guide
- Write comprehensive tests for all new features
- Update API documentation for new endpoints
- Use meaningful commit messages
- Ensure all tests pass before submitting PR
lowskydev ๐ Project Leader & Full-Stack Developer |
lyes0000 โก Backend Developer |
This project is licensed under the MIT License - see the LICENSE file for details.
- Django Software Foundation for the excellent web framework
- Django REST Framework for powerful API tools
- PostgreSQL for reliable database technology
- Docker for consistent development environments
Made with โค๏ธ by the Fokuso team
