Skip to content

renansouza12/Flashcard-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

31 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽด Flashcard Learning App


๐Ÿ“– Introduction

The Flashcard Learning App is a simple REST API for creating and studying flashcard decks. Whether you're learning a new language, preparing for exams, or just want to memorize anything, this app has you covered.

You can create decks, add cards, and practice with two different game modes: multiple choice (pick the right answer) and typing mode (type it from memory). It's straightforward, clean, and built with Spring Boot following solid architecture practices.


๐ŸŽฏ What Makes This Different?

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  ๐Ÿ“š CREATE โ†’ ๐ŸŽฏ ORGANIZE โ†’ ๐Ÿง  MASTER       โ”‚
โ”‚                                             โ”‚
โ”‚  Build flashcard decks                     โ”‚
โ”‚  Practice with interactive learning         โ”‚
โ”‚            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”ฎ Techs

๐ŸŸ  Java 17              โ†’ The foundation of reliability
๐Ÿƒ Spring Boot 3        โ†’ Rapid development, zero compromise
๐ŸŒ Spring Web           โ†’ RESTful elegance
๐Ÿ’พ Spring Data JPA      โ†’ Database magic without the boilerplate
โœ… Spring Validation    โ†’ Guard your data gates
๐Ÿฌ MySQL                โ†’ Rock-solid persistence
๐Ÿ“ฆ Maven                โ†’ Dependency harmony

Java Spring Boot MySQL Maven


๐Ÿš€ Run

Step 1: Clone Your Future

git clone https://github.com/YOUR_USERNAME/Flashcard-App.git
cd Flashcard-App

Step 2: Configure the Database

Create your MySQL database:

CREATE DATABASE flashcard_db;

Configure src/main/resources/application.properties:

spring.datasource.url=jdbc:mysql://localhost:3306/flashcard_db
spring.datasource.username=your_username
spring.datasource.password=your_password
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true

Step 3: Assemble Dependencies

mvn clean install

Step 4: Run the Application

mvn spring-boot:run

Your API is now live at: http://localhost:8080 ๐ŸŽ‰

Step 5: Run Tests

mvn test

๐ŸŽฎ API Playground

๐Ÿ“ฆ Flashcard Set Management

These endpoints let you create and manage your flashcard decks.

๐Ÿ†• Create a New Deck

POST /flashcards/create
Content-Type: application/json

{
  "title": "Basic English",
  "description": "Simple vocabulary words"
}

Response: 201 CREATED

{
  "id": 1,
  "title": "Basic English",
  "description": "Simple vocabulary words",
  "cards": []
}

๐Ÿ“‹ Get All Decks

GET /flashcards

Response: Array of all your flashcard sets

[
  {
    "id": 1,
    "title": "Basic English",
    "description": "Simple vocabulary words",
    "cards": [...]
  }
]

๐Ÿ” Find a Specific Deck

You can search by id, title, or description:

GET /flashcards/flashcard?id=1
GET /flashcards/flashcard?title=Basic English
GET /flashcards/flashcard?description=Simple vocabulary

Response: The matching flashcard set with all its cards


โœ๏ธ Update a Deck

Find by id or title, then update:

PUT /flashcards/flashcard?id=1
Content-Type: application/json

{
  "title": "Advanced English",
  "description": "Complex vocabulary"
}

Response: Updated flashcard set


๐Ÿ—‘๏ธ Delete a Deck

Remove by id, title, or description:

DELETE /flashcards/flashcard?id=1
DELETE /flashcards/flashcard?title=Basic English

Response: 200 OK with message "Flashcard deleted"


๐Ÿƒ Card Management

These endpoints let you add and manage individual cards within a deck.

โž• Add a Card to a Deck

Add a new card using the deck's ID:

POST /flashcards/1/card
Content-Type: application/json

{
  "term": "Dog",
  "definition": "Cachorro"
}

Response: 201 CREATED

{
  "id": 1,
  "term": "Dog",
  "definition": "Cachorro"
}

๐Ÿ” Find a Specific Card

Search by id, term, or definition:

GET /flashcards/card?id=1
GET /flashcards/card?term=Dog
GET /flashcards/card?definition=Cachorro

Response: The matching card


โœ๏ธ Update a Card

Find by id, term, or definition, then update:

PUT /flashcards/card?id=1
Content-Type: application/json

{
  "term": "House",
  "definition": "Casa"
}

Response: Updated card


๐Ÿ—‘๏ธ Delete a Card

Remove by id, term, or definition:

DELETE /flashcards/card?id=1
DELETE /flashcards/card?term=Dog

Response: 200 OK with message "Card deleted successfully"


๐ŸŽฏ Game Modes (Learning & Practice)

This is where the magic happens! These endpoints power the interactive learning experience.

๐ŸŽฒ Multiple Choice Mode

What it does: Gives you a random card's term and 4 possible definitions to choose from. Perfect for quick practice!

How it works: The system picks a random card from your deck, shows you the term, and generates 3 wrong answers + 1 correct answer (shuffled randomly).

GET /game/multiple-choice?id=1
GET /game/multiple-choice?title=Basic English

Response:

{
  "term": "Dog",
  "options": [
    "Casa",
    "Gato", 
    "Cachorro",
    "Livro"
  ],
  "correctAnswer": "Cachorro"
}

Simple explanation: You get a term and 4 choices. Pick the right definition!


โŒจ๏ธ Typing Mode - Get Question

What it does: Gives you either a term or definition, and you have to type the answer yourself. Harder than multiple choice!

How it works: The system randomly picks a card and randomly decides whether to show you the term (you type the definition) or the definition (you type the term).

GET /game/typing/question?id=1
GET /game/typing/question?title=Basic English

Response:

{
  "question": "Dog",
  "isTermQuestion": true
}
  • If isTermQuestion: true โ†’ you saw the term, now type the definition
  • If isTermQuestion: false โ†’ you saw the definition, now type the term

Simple explanation: You get a word/definition and must type the matching answer from memory.


โœ… Typing Mode - Check Answer

What it does: After you type your answer, this checks if you got it right or wrong.

How it works: Send back the question, whether it was a term question, and your typed answer. The system compares your answer with the correct one.

POST /game/typing/check
Content-Type: application/json

{
  "question": "Dog",
  "isTermQuestion": true,
  "answer": "Cachorro"
}

Response:

{
  "correct": true,
  "correctAnswer": "Cachorro"
}
  • correct: true โ†’ You got it right! ๐ŸŽ‰
  • correct: false โ†’ Wrong answer, but you'll see what the correct one was

Simple explanation: Submit your typed answer and find out if you're right or wrong. If wrong, you'll see the correct answer.


๐Ÿ›๏ธ Architecture

This project follows separation of concerns like a sacred law:

๐Ÿ“ฆ Flashcard-App
โ”œโ”€โ”€ ๐ŸŽฏ Controllers    โ†’ Your API gateway
โ”œโ”€โ”€ ๐Ÿ’ผ Services       โ†’ Business logic lives here
โ”œโ”€โ”€ ๐Ÿ—„๏ธ Repositories   โ†’ Data access layer
โ”œโ”€โ”€ ๐Ÿ—๏ธ Models         โ†’ Your domain entities
โ””โ”€โ”€ โœ… Validators     โ†’ Keep chaos at bay

๐ŸŽ“ Learning Outcomes

By creating this project, I learned:

  • โœ… RESTful API design patterns
  • โœ… Spring Boot ecosystem fluency
  • โœ… JPA/Hibernate relationship management
  • โœ… Clean architecture principles
  • โœ… Request validation strategies
  • โœ… Database modeling for real-world apps
  • โœ… Game logic implementation
  • โœ… DTO pattern usage

๐Ÿค Contributing

Found a bug? Have an idea? Want to add something else?

  1. Fork this repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“œ License

This project is open source and available under the MIT License.


Built with โ˜• and Spring Boot.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages